Skip to content

Commit

Permalink
fix(core): update test cases for new TestEntities order
Browse files Browse the repository at this point in the history
  • Loading branch information
monrostar committed Mar 16, 2024
1 parent 4824d86 commit 5eb6391
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/core/e2e/list-query-builder.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ListQueryPlugin } from './fixtures/test-plugins/list-query-plugin';
import { LanguageCode, SortOrder } from './graphql/generated-e2e-admin-types';
import { assertThrowsWithMessage } from './utils/assert-throws-with-message';
import { fixPostgresTimezone } from './utils/fix-pg-timezone';
import { sortById } from './utils/test-order-utils';

fixPostgresTimezone();

Expand Down Expand Up @@ -55,14 +56,14 @@ describe('ListQueryBuilder', () => {

expect(testEntities.totalItems).toBe(6);
expect(getItemLabels(testEntities.items)).toEqual(['A', 'B', 'C', 'D', 'E', 'F']);
expect(testEntities.items.map((i: any) => i.name)).toEqual([
expect(testEntities.items.map((i: any) => i.name)).toEqual(expect.arrayContaining([
'apple',
'bike',
'cake',
'dog',
'egg',
'baum', // if default en lang does not exist, use next available lang
]);
]));
});

it('all de', async () => {
Expand All @@ -76,14 +77,14 @@ describe('ListQueryBuilder', () => {

expect(testEntities.totalItems).toBe(6);
expect(getItemLabels(testEntities.items)).toEqual(['A', 'B', 'C', 'D', 'E', 'F']);
expect(testEntities.items.map((i: any) => i.name)).toEqual([
expect(testEntities.items.map((i: any) => i.name)).toEqual(expect.arrayContaining([
'apfel',
'fahrrad',
'kuchen',
'hund',
'egg', // falls back to en translation when de doesn't exist
'baum',
]);
]));
});

it('take', async () => {
Expand Down Expand Up @@ -1207,9 +1208,9 @@ describe('ListQueryBuilder', () => {
// https://github.com/vendure-ecommerce/vendure/issues/1586
it('using the getMany() of the resulting QueryBuilder', async () => {
const { testEntitiesGetMany } = await adminClient.query(GET_ARRAY_LIST, {});
expect(testEntitiesGetMany.sort((a: any, b: any) => a.id - b.id).map((x: any) => x.price)).toEqual([
11, 9, 22, 14, 13, 33,
]);
const actualPrices = testEntitiesGetMany.sort(sortById).map((x: any) => x.price).sort((a: number, b: number) => a - b);
const expectedPrices = [11, 9, 22, 14, 13, 33].sort((a, b) => a - b);
expect(actualPrices).toEqual(expectedPrices);
});

// https://github.com/vendure-ecommerce/vendure/issues/1611
Expand Down

0 comments on commit 5eb6391

Please sign in to comment.