Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
terryttsai committed May 4, 2022
1 parent da215d2 commit efffd4f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ beforeEach(() => {
tenantId: "US_ND",
content: contentFixture.racialDisparitiesNarrative,
categoryFilter: contentFixture.demographicCategories.raceOrEthnicity,
getToken: () => Promise.resolve("Test token"),
});

render(<RaceOrEthnicityFilterSelect narrative={narrative} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ beforeEach(() => {
narrative = RacialDisparitiesNarrative.build({
tenantId: "US_ND",
content: contentFixture.racialDisparitiesNarrative,
getToken: () => Promise.resolve("Test token"),
});

render(<SupervisionTypeFilterSelect narrative={narrative} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const getMetric = async () => {
localityLabels: undefined,
dataTransformer: mockTransformer,
sourceFileName: mockSourceFileName,
getToken: () => Promise.resolve("Test token"),
});

await metric.hydrate();
Expand Down
1 change: 1 addition & 0 deletions spotlight-client/src/contentModels/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default abstract class Metric<RecordFormat extends MetricRecord>
// we don't really need the entire Tenant object,
// only the ID for use in the API request
readonly tenantId: TenantId;

readonly getToken: () => Promise<string>;

// data properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ beforeEach(() => {
tenantId: testTenantId,
content: contentFixture.racialDisparitiesNarrative,
categoryFilter: contentFixture.demographicCategories.raceOrEthnicity,
getToken: () => Promise.resolve("Test token"),
});
});

Expand Down Expand Up @@ -280,6 +281,7 @@ describe("available categories", () => {
tenantId: testTenantId,
content: contentFixture.racialDisparitiesNarrative,
categoryFilter: undefined,
getToken: () => Promise.resolve("Test token"),
});
expect(narrative.allCategories).toMatchSnapshot();
});
Expand Down Expand Up @@ -309,6 +311,7 @@ describe("supervision types", () => {
supervisionTypes: ["parole"],
},
categoryFilter: contentFixture.demographicCategories.raceOrEthnicity,
getToken: () => Promise.resolve("Test token"),
});

reactImmediately(() => {
Expand Down
25 changes: 20 additions & 5 deletions spotlight-client/src/contentModels/Tenant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ test.each([
["partial", partialFixture],
])("create a %s Tenant", (type, fixture) => {
retrieveContentMock.mockReturnValue(fixture);
const tenant = createTenant({ tenantId: "US_ND" });
const tenant = createTenant({
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});
expect(tenant.name).toBe(fixture.name);
expect(tenant.description).toBe(fixture.description);
expect(tenant.coBrandingCopy).toBe(fixture.coBrandingCopy);
Expand All @@ -48,7 +51,10 @@ test.each([
])("tenant has %s Metrics", (type, fixture) => {
retrieveContentMock.mockReturnValue(fixture);

const tenant = createTenant({ tenantId: "US_ND" });
const tenant = createTenant({
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});

const expectedMetrics = Object.keys(fixture.metrics).filter(isMetricTypeId);
expectedMetrics.forEach((metricId) =>
Expand All @@ -63,7 +69,10 @@ test.each([
])("tenant has %s system narratives", (type, fixture) => {
retrieveContentMock.mockReturnValue(fixture);

const tenant = createTenant({ tenantId: "US_ND" });
const tenant = createTenant({
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});

const expectedNarratives = Object.keys(tenant.systemNarratives).filter(
isSystemNarrativeTypeId
Expand All @@ -80,7 +89,10 @@ test.each([
test("tenant has racial disparities narrative", () => {
retrieveContentMock.mockReturnValue(exhaustiveFixture);

const tenant = createTenant({ tenantId: "US_ND" });
const tenant = createTenant({
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});

expect(tenant.racialDisparitiesNarrative).toBeInstanceOf(
RacialDisparitiesNarrative
Expand All @@ -90,7 +102,10 @@ test("tenant has racial disparities narrative", () => {
test("tenant does not have racial disparities narrative", () => {
retrieveContentMock.mockReturnValue(partialFixture);

const tenant = createTenant({ tenantId: "US_ND" });
const tenant = createTenant({
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});

expect(tenant.racialDisparitiesNarrative).toBeUndefined();
});
4 changes: 4 additions & 0 deletions spotlight-client/src/metricsApi/fetchMetrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe("fetchMetrics", () => {
const response = await fetchMetrics({
metricNames,
tenantId,
getToken: () => Promise.resolve("Test token"),
});

expect(Object.keys(response)).toEqual(metricNames);
Expand Down Expand Up @@ -75,6 +76,7 @@ describe("fetchMetrics", () => {
await fetchMetrics({
metricNames: ["this_file_does_not_exist"],
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});
} catch (e) {
expect(e.message).toMatch("500");
Expand All @@ -95,6 +97,7 @@ describe("fetchAndTransformMetric", () => {
sourceFileName,
transformFn,
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});

expect(transformedData).toEqual([
Expand Down Expand Up @@ -129,6 +132,7 @@ describe("fetchAndTransformMetric", () => {
sourceFileName,
transformFn: jest.fn(),
tenantId: "US_ND",
getToken: () => Promise.resolve("Test token"),
});
} catch (e) {
expect(e.message).toBe(ERROR_MESSAGES.noMetricData);
Expand Down

0 comments on commit efffd4f

Please sign in to comment.