Skip to content

Commit 46f7d5d

Browse files
committed
test(model): config() method can change request config
1 parent 4b12b18 commit 46f7d5d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/model.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,4 +1041,28 @@ describe('Model methods', () => {
10411041
comment.text = 'Hola!'
10421042
await comment.save()
10431043
})
1044+
1045+
test('config() method can change request config', async () => {
1046+
axiosMock.onGet('http://localhost/posts').reply((config) => {
1047+
expect(config.params).toEqual({
1048+
foo: 'bar'
1049+
})
1050+
1051+
return [200, postsResponse]
1052+
})
1053+
1054+
const posts = await Post.config({
1055+
params: {
1056+
foo: 'bar'
1057+
}
1058+
}).get()
1059+
1060+
posts.forEach((post) => {
1061+
expect(post).toBeInstanceOf(Post)
1062+
expect(post.user).toBeInstanceOf(User)
1063+
post.relationships.tags.forEach((tag) => {
1064+
expect(tag).toBeInstanceOf(Tag)
1065+
})
1066+
})
1067+
})
10441068
})

0 commit comments

Comments
 (0)