Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added delete test #79

Merged
merged 2 commits into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions libs/movex/src/lib/movex-store/MemoryMovexStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,38 @@ describe('CRUD Operations', () => {
expect(expectedCounter.state[0].count).toBe(9);
expect(expectedTester.state[0].val).toBe('aha');
});

test('delete', async () => {
const store = new MemoryMovexStore<{
counter: () => { count: number };
}>();

await store
.create('counter:15', {
count: 15,
})
.resolveUnwrap();

await store
.create('counter:1', {
count: 1,
})
.resolveUnwrap();

store.updateState('counter:1', (prev) => ({
...prev,
count: prev.count + 9,
}));

const expectedCounter = await store.get('counter:1').resolveUnwrap();
expect(expectedCounter.state[0].count).toBe(10);

store.remove('counter:15');

const expectedStore = await store.all();
expect(expectedStore.counter?.['counter:15']).toBeUndefined();
expect(expectedStore.counter?.['counter:1']).toBeDefined();
});
});

describe('Multiple Resource Types', () => {
Expand Down