Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit dc22276

Browse files
committed
fix(tests): Fixes getEntities tests.
1 parent a92f7c8 commit dc22276

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

src/tests/getEntities/paginationTest.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ import Cursor from '../../types/Cursor';
55
import Filter from '../../types/Filter';
66
import Pagination from '../../types/Pagination';
77
import Sort from '../../types/Sort';
8-
import { TestEntity, testEntity, testId, TestId } from '../utils/testEntity';
8+
import { TestEntity, testEntity, TestId } from '../utils/testEntity';
99

1010
export default (facade: Facade<TestId, TestEntity>) => {
11-
const firstEntity = { ...testEntity, id: 'first_entity_id' };
12-
const secondEntity = { ...testEntity, id: 'second_entity_id' };
11+
const firstId = { id: 'test_id_1' };
12+
const secondId = { id: 'test_id_2' };
13+
const firstEntity = { ...testEntity, ...firstId };
14+
const secondEntity = { ...testEntity, ...secondId };
1315
const sort: Sort<TestEntity> = { id: true };
1416
const filter: Filter<TestEntity> = {};
1517

1618
const createTestEntities = async () => {
17-
await facade.createEntity({ id: testId, entity: firstEntity });
18-
await facade.createEntity({ id: testId, entity: secondEntity });
19+
await facade.createEntity({ id: firstId, entity: firstEntity });
20+
await facade.createEntity({ id: secondId, entity: secondEntity });
1921
};
2022

2123
const paginate = (cursor: Cursor, forward: boolean) => {

src/tests/getEntities/sortTest.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import Facade from '../../Facade';
44
import Filter from '../../types/Filter';
55
import Pagination from '../../types/Pagination';
66
import Sort from '../../types/Sort';
7-
import { TestEntity, testEntity, TestId, testId } from '../utils/testEntity';
7+
import { TestEntity, testEntity, TestId } from '../utils/testEntity';
88

99
export default (facade: Facade<TestId, TestEntity>) => {
10-
const firstEntity = { ...testEntity, stringProp: 'a', numberProp: 1 };
11-
const secondEntity = { ...testEntity, stringProp: 'b', numberProp: 2 };
10+
const firstId = { id: 'test_id_1' };
11+
const secondId = { id: 'test_id_2' };
12+
const firstEntity = { ...testEntity, ...firstId, stringProp: 'a', numberProp: 1 };
13+
const secondEntity = { ...testEntity, ...secondId, stringProp: 'b', numberProp: 2 };
1214

1315
const assertSort = async (sortedEntities: TestEntity[], sort: Sort<TestEntity>) => {
1416
const filter: Filter<TestEntity> = {};
@@ -21,38 +23,38 @@ export default (facade: Facade<TestId, TestEntity>) => {
2123
};
2224

2325
it('should sort by one ascending property when entities are ordered', async () => {
24-
await facade.createEntity({ id: testId, entity: firstEntity });
25-
await facade.createEntity({ id: testId, entity: secondEntity });
26+
await facade.createEntity({ id: firstId, entity: firstEntity });
27+
await facade.createEntity({ id: secondId, entity: secondEntity });
2628
await assertSort([firstEntity, secondEntity], { stringProp: true });
2729
});
2830

2931
it('should sort by one ascending property when entities are unordered', async () => {
30-
await facade.createEntity({ id: testId, entity: secondEntity });
31-
await facade.createEntity({ id: testId, entity: firstEntity });
32+
await facade.createEntity({ id: secondId, entity: secondEntity });
33+
await facade.createEntity({ id: firstId, entity: firstEntity });
3234
await assertSort([firstEntity, secondEntity], { stringProp: true });
3335
});
3436

3537
it('should sort by one descending property when entities are ordered', async () => {
36-
await facade.createEntity({ id: testId, entity: secondEntity });
37-
await facade.createEntity({ id: testId, entity: firstEntity });
38+
await facade.createEntity({ id: secondId, entity: secondEntity });
39+
await facade.createEntity({ id: firstId, entity: firstEntity });
3840
await assertSort([secondEntity, firstEntity], { stringProp: false });
3941
});
4042

4143
it('should sort by one descending property when entities are unordered', async () => {
42-
await facade.createEntity({ id: testId, entity: firstEntity });
43-
await facade.createEntity({ id: testId, entity: secondEntity });
44+
await facade.createEntity({ id: firstId, entity: firstEntity });
45+
await facade.createEntity({ id: secondId, entity: secondEntity });
4446
await assertSort([secondEntity, firstEntity], { stringProp: false });
4547
});
4648

4749
it('should sort by two properties when ascending first and descending second', async () => {
48-
await facade.createEntity({ id: testId, entity: firstEntity });
49-
await facade.createEntity({ id: testId, entity: secondEntity });
50+
await facade.createEntity({ id: firstId, entity: firstEntity });
51+
await facade.createEntity({ id: secondId, entity: secondEntity });
5052
await assertSort([secondEntity, firstEntity], { stringProp: true, numberProp: false });
5153
});
5254

5355
it('should sort by two properties when descending first and ascending second', async () => {
54-
await facade.createEntity({ id: testId, entity: firstEntity });
55-
await facade.createEntity({ id: testId, entity: secondEntity });
56+
await facade.createEntity({ id: firstId, entity: firstEntity });
57+
await facade.createEntity({ id: secondId, entity: secondEntity });
5658
await assertSort([secondEntity, firstEntity], { stringProp: false, numberProp: true });
5759
});
5860
};

0 commit comments

Comments
 (0)