Skip to content

Commit

Permalink
Add nextOptions test
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindet committed Oct 27, 2023
1 parent 3c69490 commit 6de0a48
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/core/test/porcelain.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { jest } from '@jest/globals';
import Graffy from '../Graffy.js';
import GraffyFill from '@graffy/fill';
import { page, ref } from '@graffy/testing';
import { jest } from '@jest/globals';
import Graffy from '../Graffy.js';

test('Porcelain read', async () => {
const store = new Graffy();
Expand Down Expand Up @@ -403,3 +403,17 @@ test('onReadWithNext', async () => {
},
});
});

test('modified_next_options', async () => {
// @ts-ignore bad jest mockResolvedValue definitions?
const mockOnRead = jest.fn().mockResolvedValue({ 123: { name: 'Alice' } });
const query = { 123: { name: true } };
const store = new Graffy();
store.use(GraffyFill());
store.onRead('user', (query, _options, next) => {
return next(query, { bar: true });
});
store.onRead('user', mockOnRead);
await store.read('user', query, { foo: 2 });
expect(mockOnRead).toBeCalledWith(query, { bar: true }, expect.any(Function));
});

0 comments on commit 6de0a48

Please sign in to comment.