Skip to content

Commit

Permalink
add a test that Map set works correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeistrich committed Jun 20, 2024
1 parent af5769b commit 5e709c4
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/mapset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,58 @@ describe('Map default behavior', () => {
]),
);
});
test('Map set works correctly', () => {
interface TableState {
columnFilters: any;
sorting: any;
pagination: any;
search: string;
}

const tablesState$ = observable({
tables: new Map<string, TableState>([
[
'XX',
{
columnFilters: 'hi1',
sorting: ['hi2'],
pagination: { hi3: 'hi4' },
search: 'hi5',
},
],
]),
});

expect(tablesState$.get()).toEqual({
tables: new Map([
[
'XX',
{
columnFilters: 'hi1',
sorting: ['hi2'],
pagination: { hi3: 'hi4' },
search: 'hi5',
},
],
]),
});

tablesState$.tables.get('XX').sorting.set([]);

expect(tablesState$.get()).toEqual({
tables: new Map([
[
'XX',
{
columnFilters: 'hi1',
sorting: [],
pagination: { hi3: 'hi4' },
search: 'hi5',
},
],
]),
});
});
});

describe('Map is observable', () => {
Expand Down

0 comments on commit 5e709c4

Please sign in to comment.