@unchainedshop/core-events 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -5
- package/src/module/buildFindSelector.test.ts +17 -13
- package/jest.config.js +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-events",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"main": "lib/events-index.js",
|
|
5
5
|
"types": "lib/events-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"build": "tsc -b",
|
|
10
10
|
"prepublishOnly": "npm run clean && npm run build",
|
|
11
11
|
"watch": "tsc -w",
|
|
12
|
-
"test": "
|
|
13
|
-
"test:watch": "
|
|
12
|
+
"test": "tsx --test",
|
|
13
|
+
"test:watch": "tsx --test --watch"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -36,8 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.13.4",
|
|
39
|
-
"
|
|
40
|
-
"ts-jest": "^29.2.5",
|
|
39
|
+
"tsx": "^4.19.2",
|
|
41
40
|
"typescript": "^5.7.3"
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -1,36 +1,40 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
1
3
|
import { buildFindSelector } from './configureEventsModule.js';
|
|
2
4
|
|
|
3
5
|
describe('buildFindSelector', () => {
|
|
4
6
|
it('Return correct filter object when passed create, queryString, types', () => {
|
|
5
|
-
|
|
7
|
+
assert.deepStrictEqual(
|
|
6
8
|
buildFindSelector({
|
|
7
9
|
created: new Date('2022-12-03T18:23:38.278Z'),
|
|
8
10
|
queryString: 'Hello world',
|
|
9
11
|
types: ['PRODUCT_CREATED'],
|
|
10
12
|
}),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
{
|
|
14
|
+
type: { $in: ['PRODUCT_CREATED'] },
|
|
15
|
+
$text: { $search: 'Hello world' },
|
|
16
|
+
created: { $gte: new Date('2022-12-03T18:23:38.278Z') },
|
|
17
|
+
},
|
|
18
|
+
);
|
|
16
19
|
});
|
|
17
20
|
|
|
18
21
|
it('Return correct filter object when passed create, queryString', () => {
|
|
19
|
-
|
|
22
|
+
assert.deepStrictEqual(
|
|
20
23
|
buildFindSelector({ created: new Date('2022-12-03T18:23:38.278Z'), queryString: 'Hello world' }),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
{
|
|
25
|
+
$text: { $search: 'Hello world' },
|
|
26
|
+
created: { $gte: new Date('2022-12-03T18:23:38.278Z') },
|
|
27
|
+
},
|
|
28
|
+
);
|
|
25
29
|
});
|
|
26
30
|
|
|
27
31
|
it('Return correct filter object when passed create', () => {
|
|
28
|
-
|
|
32
|
+
assert.deepStrictEqual(buildFindSelector({ created: new Date('2022-12-03T18:23:38.278Z') }), {
|
|
29
33
|
created: { $gte: new Date('2022-12-03T18:23:38.278Z') },
|
|
30
34
|
});
|
|
31
35
|
});
|
|
32
36
|
|
|
33
37
|
it('Return correct filter object when passed no argument', () => {
|
|
34
|
-
|
|
38
|
+
assert.deepStrictEqual(buildFindSelector({}), {});
|
|
35
39
|
});
|
|
36
40
|
});
|
package/jest.config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
|
2
|
-
export default {
|
|
3
|
-
preset: 'ts-jest/presets/default-esm', // or other ESM presets
|
|
4
|
-
testEnvironment: 'node',
|
|
5
|
-
extensionsToTreatAsEsm: ['.ts'],
|
|
6
|
-
transform: {
|
|
7
|
-
'^.+\\.tsx?$': [
|
|
8
|
-
'ts-jest',
|
|
9
|
-
{
|
|
10
|
-
useESM: true,
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
},
|
|
14
|
-
moduleNameMapper: {
|
|
15
|
-
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
16
|
-
},
|
|
17
|
-
};
|