Skip to content

Commit

Permalink
fix type warnings in confirmHelper.test.ts
Browse files Browse the repository at this point in the history
this test still had LabelOptions type for the userInput values instead of the UserInputEntry type.
It didn't cause the tests to fail because inferFinalLabels and verifiabilityForTrip only check that the values exist - they don't care what properties they have.
Anyhow, the types line up now.
  • Loading branch information
JGreenlee committed Dec 7, 2023
1 parent 8e78f79 commit 1a35e1f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions www/__tests__/confirmHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
} from '../js/survey/multilabel/confirmHelper';

import initializedI18next from '../js/i18nextInit';
import { CompositeTrip } from '../js/types/diaryTypes';
import { CompositeTrip, UserInputEntry } from '../js/types/diaryTypes';
import { UserInputMap } from '../js/diary/LabelTabContext';
window['i18next'] = initializedI18next;
mockLogger();

Expand Down Expand Up @@ -134,9 +135,9 @@ describe('confirmHelper', () => {

it('gives no final inference when there are user labels and no inferred labels', () => {
const fakeTrip = {} as CompositeTrip;
const fakeUserInput = {
MODE: labelOptionByValue('bike', 'MODE'),
PURPOSE: labelOptionByValue('shopping', 'PURPOSE'),
const fakeUserInput: UserInputMap = {
MODE: { data: { label: 'bike' } } as UserInputEntry,
PURPOSE: { data: { label: 'shopping' } } as UserInputEntry,
};
const final = inferFinalLabels(fakeTrip, fakeUserInput);
expect(final.MODE?.value).toBeUndefined();
Expand All @@ -149,8 +150,8 @@ describe('confirmHelper', () => {
inferred_labels: [{ labels: { mode_confirm: 'walk', purpose_confirm: 'exercise' }, p: 0.9 }],
} as CompositeTrip;
const fakeUserInput = {
MODE: labelOptionByValue('bike', 'MODE'),
PURPOSE: labelOptionByValue('shopping', 'PURPOSE'),
MODE: { data: { label: 'bike' } } as UserInputEntry,
PURPOSE: { data: { label: 'shopping' } } as UserInputEntry,
};
const final = inferFinalLabels(fakeTrip, fakeUserInput);
expect(final.MODE?.value).toBeUndefined();
Expand All @@ -165,7 +166,9 @@ describe('confirmHelper', () => {
{ labels: { mode_confirm: 'walk', purpose_confirm: 'exercise' }, p: 0.9 },
],
} as CompositeTrip;
const fakeUserInput = { MODE: labelOptionByValue('bike', 'MODE') };
const fakeUserInput = {
MODE: { data: { label: 'bike' } } as UserInputEntry,
};
const final = inferFinalLabels(fakeTrip, fakeUserInput);
expect(final.MODE?.value).toEqual('bike');
expect(final.PURPOSE?.value).toEqual('shopping');
Expand Down

0 comments on commit 1a35e1f

Please sign in to comment.