Skip to content

Commit

Permalink
test(Ydoc): test GetYdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
nonumpa committed Sep 7, 2023
1 parent 3b8d566 commit 6aab45b
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/graphql/queries/__fixtures__/GetYdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default {
'/ydocs/doc/foo': {
data: '',
versions: [
{
createdAt: '2020-02-09T15:11:04.472Z',
snapshot: '',
},
{
createdAt: '2020-02-09T15:11:04.472Z',
snapshot: '',
},
{
createdAt: '2020-02-09T15:11:04.472Z',
snapshot: '',
},
{
createdAt: '2020-02-09T15:11:04.472Z',
snapshot: '',
},
],
},
'/articles/doc/foo2': {
data: '',
versions: [],
},
'/articles/doc/foo3': {
data: '',
versions: [],
},
};
26 changes: 26 additions & 0 deletions src/graphql/queries/__tests__/GetYdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import gql from 'util/GraphQL';
import { loadFixtures, unloadFixtures } from 'util/fixtures';
import fixtures from '../__fixtures__/GetYdoc';

describe('GetReplyAndGetArticle', () => {
beforeAll(() => loadFixtures(fixtures));

describe('GetYdoc', () => {
it('should get the specified article & associated replies from ID', async () => {
expect(
await gql`
{
GetYdoc(id: "foo") {
data
versions {
createdAt
snapshot
}
}
}
`({}, { user: { id: 'fakeUser', appId: 'LINE' } })
).toMatchSnapshot();
});
});
afterAll(() => unloadFixtures(fixtures));
});
29 changes: 29 additions & 0 deletions src/graphql/queries/__tests__/__snapshots__/GetYdoc.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GetReplyAndGetArticle GetYdoc should get the specified article & associated replies from ID 1`] = `
Object {
"data": Object {
"GetYdoc": Object {
"data": "",
"versions": Array [
Object {
"createdAt": "2020-02-09T15:11:04.472Z",
"snapshot": "",
},
Object {
"createdAt": "2020-02-09T15:11:04.472Z",
"snapshot": "",
},
Object {
"createdAt": "2020-02-09T15:11:04.472Z",
"snapshot": "",
},
Object {
"createdAt": "2020-02-09T15:11:04.472Z",
"snapshot": "",
},
],
},
},
}
`;

0 comments on commit 6aab45b

Please sign in to comment.