-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
59 deletions.
There are no files selected for viewing
66 changes: 31 additions & 35 deletions
66
packages/core-enrollments/src/module/buildFindSelector.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
46
packages/core-events/src/module/buildFindSelector.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({}) | ||
}); | ||
}) |