Skip to content

Commit

Permalink
Fix double describe
Browse files Browse the repository at this point in the history
  • Loading branch information
pozylon committed Oct 21, 2024
1 parent 6f49f4e commit ac0eb1a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 59 deletions.
66 changes: 31 additions & 35 deletions packages/core-enrollments/src/module/buildFindSelector.test.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
import { EnrollmentStatus } from "@unchainedshop/core-enrollments";
import { buildFindSelector } from "./configureEnrollmentsModule.js";

describe('buildFindSelector', () => {
it('Should correct filter when passed status, userId and queryString', () => {
expect(buildFindSelector({queryString: "Hello World", status: [EnrollmentStatus.ACTIVE], userId: 'admin-id'})).toEqual({
deleted: null,
status: { '$in': [ 'ACTIVE' ] },
userId: 'admin-id',
'$text': { '$search': 'Hello World' }
})
});
it('Should correct filter when passed userId and queryString', () => {

expect(buildFindSelector({queryString: "Hello World", userId: 'admin-id'})).toEqual({
deleted: null,
userId: 'admin-id',
'$text': { '$search': 'Hello World' }
})
});

it('Should correct filter when passed queryString', () => {

expect(buildFindSelector({queryString: "Hello World"})).toEqual({
deleted: null,
'$text': { '$search': 'Hello World' }
})
});



describe('buildFindSelector', () => {
it('Should correct filter when passed status, userId and queryString', async () => {
expect(buildFindSelector({queryString: "Hello World", status: [EnrollmentStatus.ACTIVE], userId: 'admin-id'})).toEqual({
deleted: null,
status: { '$in': [ 'ACTIVE' ] },
userId: 'admin-id',
'$text': { '$search': 'Hello World' }
})
});
it('Should correct filter when passed userId and queryString', async () => {

expect(buildFindSelector({queryString: "Hello World", userId: 'admin-id'})).toEqual({
deleted: null,
userId: 'admin-id',
'$text': { '$search': 'Hello World' }
})
});

it('Should correct filter when passed queryString', async () => {

expect(buildFindSelector({queryString: "Hello World"})).toEqual({
deleted: null,
'$text': { '$search': 'Hello World' }
})
});

it('Should correct filter when passed no argument', async () => {

expect(buildFindSelector({})).toEqual({
deleted: null,
})
});
})
it('Should correct filter when passed no argument', () => {

expect(buildFindSelector({})).toEqual({
deleted: null,
})
});
})
46 changes: 22 additions & 24 deletions packages/core-events/src/module/buildFindSelector.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import { buildFindSelector } from "./configureEventsModule.js";

describe('Event', () => {
describe('buildFindSelector', () => {
it('Return correct filter object when passed create, queryString, types', () => {
describe('buildFindSelector', () => {
it('Return correct filter object when passed create, queryString, types', () => {
expect(buildFindSelector({created: new Date("2022-12-03T18:23:38.278Z"), queryString: "Hello world", types: ['PRODUCT_CREATED']})).toEqual({
type: { '$in': [ 'PRODUCT_CREATED' ] },
'$text': { '$search': 'Hello world' },
created: { '$gte': new Date( "2022-12-03T18:23:38.278Z" )}
})
});
type: { '$in': [ 'PRODUCT_CREATED' ] },
'$text': { '$search': 'Hello world' },
created: { '$gte': new Date( "2022-12-03T18:23:38.278Z" )}
})
});

it('Return correct filter object when passed create, queryString', () => {
expect(buildFindSelector({created: new Date("2022-12-03T18:23:38.278Z"), queryString: "Hello world"})).toEqual({
'$text': { '$search': 'Hello world' },
created: { '$gte': new Date( "2022-12-03T18:23:38.278Z" )}
})
});
it('Return correct filter object when passed create, queryString', () => {
expect(buildFindSelector({created: new Date("2022-12-03T18:23:38.278Z"), queryString: "Hello world"})).toEqual({
'$text': { '$search': 'Hello world' },
created: { '$gte': new Date( "2022-12-03T18:23:38.278Z" )}
})
});

it('Return correct filter object when passed create', () => {
expect(buildFindSelector({created: new Date("2022-12-03T18:23:38.278Z")})).toEqual({
created: { '$gte': new Date( "2022-12-03T18:23:38.278Z" )}
})
});
it('Return correct filter object when passed create', () => {
expect(buildFindSelector({created: new Date("2022-12-03T18:23:38.278Z")})).toEqual({
created: { '$gte': new Date( "2022-12-03T18:23:38.278Z" )}
})
});

it('Return correct filter object when passed no argument', () => {
expect(buildFindSelector({})).toEqual({})
});
})
});
it('Return correct filter object when passed no argument', () => {
expect(buildFindSelector({})).toEqual({})
});
})

0 comments on commit ac0eb1a

Please sign in to comment.