Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/field-types/single_reference.subtest.js
const assert = require("assert"); | const assert = require("assert"); | ||||
const locreq = require("locreq")(__dirname); | const locreq = require("locreq")(__dirname); | ||||
const axios = require("axios"); | |||||
const { create_resource_as } = locreq("test_utils"); | |||||
const { with_running_app } = locreq("test_utils/with-test-app.js"); | const { with_running_app } = locreq("test_utils/with-test-app.js"); | ||||
const assert_throws_async = locreq("test_utils/assert_throws_async.js"); | const assert_throws_async = locreq("test_utils/assert_throws_async.js"); | ||||
const A = "/api/v1/collections/A"; | const A = "/api/v1/collections/A"; | ||||
const B = "/api/v1/collections/B"; | const B = "/api/v1/collections/B"; | ||||
const C = "/api/v1/collections/C"; | const C = "/api/v1/collections/C"; | ||||
const Seals = "/api/v1/collections/seals"; | const Seals = "/api/v1/collections/seals"; | ||||
const Water_Areas = "/api/v1/collections/water_areas"; | const Water_Areas = "/api/v1/collections/water_areas"; | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | with_running_app(async ({ app, base_url, rest_api }) => { | ||||
} | } | ||||
for (let c_id of c_ids) { | for (let c_id of c_ids) { | ||||
const { id } = await rest_api.post(B, { | const { id } = await rest_api.post(B, { | ||||
reference_to_c: c_id, | reference_to_c: c_id, | ||||
}); | }); | ||||
b_ids.push(id); | b_ids.push(id); | ||||
} | } | ||||
for (let b_id of b_ids) { | for (let b_id of b_ids) { | ||||
const a = await rest_api.post(A, { reference_to_b: b_id }); | await rest_api.post(A, { reference_to_b: b_id }); | ||||
} | } | ||||
const { items } = await rest_api | const { items } = await rest_api | ||||
.get( | .get( | ||||
`${A}?filter[reference_to_b][reference_to_c][number]=3&format[reference_to_b]=deep-expand:2` | `${A}?filter[reference_to_b][reference_to_c][number]=3&format[reference_to_b]=deep-expand:2` | ||||
) | ) | ||||
.catch(console.error); | .catch(console.error); | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | items.maksiu = await rest_api.post(Seals, { | ||||
name: "Maksiu", | name: "Maksiu", | ||||
water_area: items.baltic_sea.id, | water_area: items.baltic_sea.id, | ||||
}); | }); | ||||
} | } | ||||
it("should work", async () => | it("should work", async () => | ||||
with_running_app(async ({ app, rest_api }) => { | with_running_app(async ({ app, rest_api }) => { | ||||
await setup(app, rest_api); | await setup(app, rest_api); | ||||
await rest_api.get(`${Seals}?format[water_area]=expand`); | |||||
const { items: seals } = await rest_api.get( | |||||
`${Seals}?format[water_area]=expand` | |||||
); | |||||
//TODO: will be implemented in next phase | //TODO: will be implemented in next phase | ||||
})); | })); | ||||
}); | }); |