Skip to content

Commit

Permalink
Add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
asimonok committed Nov 23, 2023
1 parent 549da7d commit c3b8e37
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/utils/variable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,32 @@ describe('Variable Utils', () => {
);
});

it('Should adjust values if they not defined in url for non array', () => {
jest.mocked(locationService.getSearch).mockImplementation(
() =>
({
getAll: jest.fn(() => []),
}) as any
);
jest.mocked(locationService.getSearchObject).mockImplementation(() => ({}));
const variable = {
name: 'variable',
type: VariableType.CUSTOM,
current: {
value: 'selected1',
},
multi: true,
};
selectVariableValues(['value1', 'value2'], variable as any);

expect(locationService.partial).toHaveBeenCalledWith(
{
[`var-${variable.name}`]: ['value1', 'value2', 'selected1'],
},
true
);
});

it('Should deselect all value if it not defined in url ', () => {
jest.mocked(locationService.getSearch).mockImplementation(
() =>
Expand Down

0 comments on commit c3b8e37

Please sign in to comment.