Skip to content

Commit

Permalink
test(test): update
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Nov 22, 2024
1 parent c2ddb57 commit 636ddd9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
10 changes: 5 additions & 5 deletions test/immer-non-support.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,9 @@ test('CustomSet', () => {
}
}

const s = new CustomSet();
const newS = create(
s,
const state = new CustomSet();
const newState = create(
state,
(draft) => {
draft.add(1);
// @ts-ignore
Expand All @@ -683,9 +683,9 @@ test('CustomSet', () => {
mark: () => 'immutable',
}
);
expect(newS instanceof CustomSet).toBeTruthy();
expect(newState instanceof CustomSet).toBeTruthy();
// @ts-ignore
expect(newS.getIdentity()).toBe('CustomSet');
expect(newState.getIdentity()).toBe('CustomSet');
}
});

Expand Down
78 changes: 39 additions & 39 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4114,7 +4114,7 @@ describe('set - new API', () => {
const difference = Set.prototype.difference;
// @ts-ignore
delete Set.prototype.difference;
const odds = new Set([{a: 1}]);
const odds = new Set([{ a: 1 }]);
const state = create({ odds }, (draft) => {
// @ts-ignore
draft.odds.values().next().value.a = 2;
Expand Down Expand Up @@ -4220,49 +4220,49 @@ describe('set - new API', () => {
});

test('CustomSet', () => {
class CustomSet extends Set {
getIdentity() {
return 'CustomSet';
}
class CustomSet extends Set {
getIdentity() {
return 'CustomSet';
}
}

const s = new CustomSet();
const newS = create(
s,
(draft) => {
draft.add(1);
// @ts-ignore
expect(draft.getIdentity()).toBe('CustomSet');
},
{
mark: () => 'immutable',
}
);
expect(newS instanceof CustomSet).toBeTruthy();
// @ts-ignore
expect(newS.getIdentity()).toBe('CustomSet');
const state = new CustomSet();
const newState = create(
state,
(draft) => {
draft.add(1);
// @ts-ignore
expect(draft.getIdentity()).toBe('CustomSet');
},
{
mark: () => 'immutable',
}
);
expect(newState instanceof CustomSet).toBeTruthy();
// @ts-ignore
expect(newState.getIdentity()).toBe('CustomSet');
});

test('CustomMap', () => {
class CustomMap extends Map {
getIdentity() {
return 'CustomMap';
}
class CustomMap extends Map {
getIdentity() {
return 'CustomMap';
}
}

const state = new CustomMap();
const newState = create(
state,
(draft) => {
draft.set(1, 1);
// @ts-ignore
expect(draft.getIdentity()).toBe('CustomMap');
},
{
mark: () => 'immutable',
}
);
expect(newState instanceof CustomMap).toBeTruthy();
// @ts-ignore
expect(newState.getIdentity()).toBe('CustomMap');
const state = new CustomMap();
const newState = create(
state,
(draft) => {
draft.set(1, 1);
// @ts-ignore
expect(draft.getIdentity()).toBe('CustomMap');
},
{
mark: () => 'immutable',
}
);
expect(newState instanceof CustomMap).toBeTruthy();
// @ts-ignore
expect(newState.getIdentity()).toBe('CustomMap');
});

0 comments on commit 636ddd9

Please sign in to comment.