Skip to content

Commit 7723a64

Browse files
committed
Use the Vuex-ORM convenience methods in the tests
1 parent 316679d commit 7723a64

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

test/integration/VuexORMApollo.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ query Post($id: ID!) {
145145
}
146146
`.trim() + "\n");
147147

148-
const post = store.getters['entities/posts/query']().withAll().where('id', 42).first();
148+
const post = Post.query().withAll().where('id', 42).first();
149149
expect(post.title).toEqual('Example Post 5');
150150
expect(post.comments.length).toEqual(1);
151151
expect(post.comments[0].content).toEqual('Works!');
@@ -375,7 +375,7 @@ mutation CreatePost($post: PostInput!) {
375375
};
376376

377377
const request = await sendWithMockFetch(response, async () => {
378-
const user = store.getters['entities/users/find'](1);
378+
const user = User.find(1);
379379
user.name = 'Snoopy';
380380

381381
await store.dispatch('entities/users/push', { data: user });
@@ -427,7 +427,7 @@ mutation DeleteUser($id: ID!) {
427427

428428
describe('custom mutation', () => {
429429
it('sends the correct query to the API', async () => {
430-
const post = store.getters['entities/posts/find'](1);
430+
const post = Post.find(1);
431431
const response = {
432432
data: {
433433
upvotePost: {
@@ -492,7 +492,7 @@ mutation UpvotePost($post: PostInput!, $captchaToken: String!) {
492492
let user = insertedData.users[0];
493493
expect(user.$isPersisted).toBeFalsy();
494494

495-
user = store.getters['entities/users/find'](user.id);
495+
user = User.find(user.id);
496496
expect(user.$isPersisted).toBeFalsy();
497497
});
498498

@@ -556,7 +556,7 @@ mutation UpvotePost($post: PostInput!, $captchaToken: String!) {
556556
await store.dispatch('entities/users/fetch', { filter: { id: 1 } });
557557
});
558558

559-
const user = store.getters['entities/users/find'](1);
559+
const user = User.find(1);
560560
expect(user.$isPersisted).toBeTruthy();
561561
});
562562
});

test/unit/QueryBuilder.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe('QueryBuilder', () => {
185185

186186
describe('.transformOutgoingData', () => {
187187
it('transforms models to a useful data hashmap', () => {
188-
const user = store.getters['entities/users/query']().first();
188+
const user = User.query().first();
189189
const transformedData = queryBuilder.transformOutgoingData(vuexOrmApollo.context.getModel('user'), user);
190190
expect(transformedData).toEqual({ id: 1, name: 'Charlie Brown' });
191191
});

0 commit comments

Comments
 (0)