Skip to content
This repository was archived by the owner on Mar 28, 2022. It is now read-only.

Commit 4e4f107

Browse files
committed
Add custom queries to fixturesModel and behaviorsModel
1 parent 5c08af8 commit 4e4f107

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/providers.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export const behaviorsModel = new Api(`${adminApiPaths.BEHAVIORS}/:name`, {
2828
tags: [TAG]
2929
});
3030

31+
behaviorsModel.addCustomQuery({
32+
findByName: name => ({
33+
urlParams: {
34+
name
35+
}
36+
})
37+
});
38+
3139
export const fixturesCollection = new Api(adminApiPaths.FIXTURES, {
3240
defaultValue: [],
3341
uuid: "fixtures-collection",
@@ -39,3 +47,11 @@ export const fixturesModel = new Api(`${adminApiPaths.FIXTURES}/:id`, {
3947
uuid: "fixtures-model",
4048
tags: [TAG]
4149
});
50+
51+
fixturesModel.addCustomQuery({
52+
findById: id => ({
53+
urlParams: {
54+
id
55+
}
56+
})
57+
});

test/src/providers.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { behaviorsModel, fixturesModel } from "../../src/providers";
2+
3+
describe("behaviorsModel findByName custom query", () => {
4+
it("should return name urlParam", () => {
5+
expect(behaviorsModel.test.customQueries.findByName("foo")).toEqual({
6+
urlParams: {
7+
name: "foo"
8+
}
9+
});
10+
});
11+
});
12+
13+
describe("fixturesModel findById custom query", () => {
14+
it("should return name urlParam", () => {
15+
expect(fixturesModel.test.customQueries.findById("foo")).toEqual({
16+
urlParams: {
17+
id: "foo"
18+
}
19+
});
20+
});
21+
});

0 commit comments

Comments
 (0)