@unchainedshop/core-worker 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/buildQuerySelector.test.ts +19 -17
- package/jest.config.js +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-worker",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"main": "lib/worker-index.js",
|
|
5
5
|
"types": "lib/worker-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",
|
|
@@ -37,8 +37,7 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/breejs__later": "^4.1.5",
|
|
39
39
|
"@types/node": "^22.13.4",
|
|
40
|
-
"
|
|
41
|
-
"ts-jest": "^29.2.5",
|
|
40
|
+
"tsx": "^4.19.2",
|
|
42
41
|
"typescript": "^5.7.3"
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
1
3
|
import { WorkStatus } from '../worker-index.js';
|
|
2
4
|
import { buildQuerySelector } from './configureWorkerModule.js';
|
|
3
5
|
|
|
4
6
|
describe('Worker', () => {
|
|
5
7
|
describe('buildQuerySelector', () => {
|
|
6
8
|
it('Return correct filter object when passed no argument', () => {
|
|
7
|
-
|
|
9
|
+
assert.deepStrictEqual(buildQuerySelector({}), { deleted: { $exists: false } });
|
|
8
10
|
});
|
|
9
11
|
|
|
10
|
-
it('Return correct filter object
|
|
12
|
+
it('Return correct filter object when passed create, queryString, scheduled, status, types & workId', () => {
|
|
11
13
|
const selector = buildQuerySelector({
|
|
12
14
|
created: {
|
|
13
15
|
start: new Date('2022-12-04T17:13:09.285Z'),
|
|
@@ -22,7 +24,7 @@ describe('Worker', () => {
|
|
|
22
24
|
types: ['EMAIL'],
|
|
23
25
|
workId: 'work-id',
|
|
24
26
|
});
|
|
25
|
-
|
|
27
|
+
assert.deepStrictEqual(selector, {
|
|
26
28
|
_id: 'work-id',
|
|
27
29
|
$or: [
|
|
28
30
|
{
|
|
@@ -55,7 +57,7 @@ describe('Worker', () => {
|
|
|
55
57
|
types: ['EMAIL'],
|
|
56
58
|
workId: 'work-id',
|
|
57
59
|
});
|
|
58
|
-
|
|
60
|
+
assert.deepStrictEqual(selector, {
|
|
59
61
|
_id: 'work-id',
|
|
60
62
|
$or: [
|
|
61
63
|
{
|
|
@@ -83,7 +85,7 @@ describe('Worker', () => {
|
|
|
83
85
|
types: ['EMAIL'],
|
|
84
86
|
workId: 'work-id',
|
|
85
87
|
});
|
|
86
|
-
|
|
88
|
+
assert.deepStrictEqual(selector, {
|
|
87
89
|
_id: 'work-id',
|
|
88
90
|
$or: [
|
|
89
91
|
{
|
|
@@ -106,7 +108,7 @@ describe('Worker', () => {
|
|
|
106
108
|
types: ['EMAIL'],
|
|
107
109
|
workId: 'work-id',
|
|
108
110
|
});
|
|
109
|
-
|
|
111
|
+
assert.deepStrictEqual(selector, {
|
|
110
112
|
_id: 'work-id',
|
|
111
113
|
$or: [
|
|
112
114
|
{
|
|
@@ -121,7 +123,7 @@ describe('Worker', () => {
|
|
|
121
123
|
|
|
122
124
|
it('Return correct filter object when passed types & workId', () => {
|
|
123
125
|
const selector = buildQuerySelector({ types: ['EMAIL'], workId: 'work-id' });
|
|
124
|
-
|
|
126
|
+
assert.deepStrictEqual(selector, {
|
|
125
127
|
_id: 'work-id',
|
|
126
128
|
deleted: { $exists: false },
|
|
127
129
|
type: { $in: ['EMAIL'] },
|
|
@@ -130,19 +132,19 @@ describe('Worker', () => {
|
|
|
130
132
|
|
|
131
133
|
it('Return correct filter object when passed workId', () => {
|
|
132
134
|
const selector = buildQuerySelector({ workId: 'work-id' });
|
|
133
|
-
|
|
135
|
+
assert.deepStrictEqual(selector, {
|
|
134
136
|
_id: 'work-id',
|
|
135
137
|
deleted: { $exists: false },
|
|
136
138
|
});
|
|
137
139
|
});
|
|
138
140
|
|
|
139
|
-
it('Create
|
|
141
|
+
it('Create start should be set to start of unix timestamp if created.start not provided', () => {
|
|
140
142
|
const selector = buildQuerySelector({
|
|
141
143
|
workId: 'work-id',
|
|
142
144
|
created: { end: new Date('2022-12-04T17:13:09.285Z') },
|
|
143
145
|
});
|
|
144
146
|
|
|
145
|
-
|
|
147
|
+
assert.deepStrictEqual(selector, {
|
|
146
148
|
_id: 'work-id',
|
|
147
149
|
deleted: { $exists: false },
|
|
148
150
|
created: {
|
|
@@ -152,32 +154,32 @@ describe('Worker', () => {
|
|
|
152
154
|
});
|
|
153
155
|
});
|
|
154
156
|
|
|
155
|
-
it('Create
|
|
157
|
+
it('Create start should be set to start or unix timestamp if created.end not provided', () => {
|
|
156
158
|
const selector = buildQuerySelector({
|
|
157
159
|
workId: 'work-id',
|
|
158
160
|
created: { start: new Date('2022-12-04T17:13:09.285Z') },
|
|
159
161
|
});
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
assert.deepStrictEqual(selector, {
|
|
162
164
|
_id: 'work-id',
|
|
163
165
|
deleted: { $exists: false },
|
|
164
166
|
created: { $gte: new Date('2022-12-04T17:13:09.285Z') },
|
|
165
167
|
});
|
|
166
168
|
|
|
167
|
-
|
|
169
|
+
assert.deepStrictEqual(buildQuerySelector({ workId: 'work-id', created: {} }), {
|
|
168
170
|
_id: 'work-id',
|
|
169
171
|
deleted: { $exists: false },
|
|
170
172
|
created: { $gte: new Date(0) },
|
|
171
173
|
});
|
|
172
174
|
});
|
|
173
175
|
|
|
174
|
-
it('scheduled
|
|
176
|
+
it('scheduled start should be set to start of unix timestamp if scheduled.start not provided', () => {
|
|
175
177
|
const selector = buildQuerySelector({
|
|
176
178
|
workId: 'work-id',
|
|
177
179
|
scheduled: { end: new Date('2022-12-04T17:13:09.285Z') },
|
|
178
180
|
});
|
|
179
181
|
|
|
180
|
-
|
|
182
|
+
assert.deepStrictEqual(selector, {
|
|
181
183
|
_id: 'work-id',
|
|
182
184
|
deleted: { $exists: false },
|
|
183
185
|
scheduled: {
|
|
@@ -193,13 +195,13 @@ describe('Worker', () => {
|
|
|
193
195
|
scheduled: { start: new Date('2022-12-04T17:13:09.285Z') },
|
|
194
196
|
});
|
|
195
197
|
|
|
196
|
-
|
|
198
|
+
assert.deepStrictEqual(selector, {
|
|
197
199
|
_id: 'work-id',
|
|
198
200
|
deleted: { $exists: false },
|
|
199
201
|
scheduled: { $gte: new Date('2022-12-04T17:13:09.285Z') },
|
|
200
202
|
});
|
|
201
203
|
|
|
202
|
-
|
|
204
|
+
assert.deepStrictEqual(buildQuerySelector({ workId: 'work-id', scheduled: {} }), {
|
|
203
205
|
_id: 'work-id',
|
|
204
206
|
deleted: { $exists: false },
|
|
205
207
|
scheduled: { $gte: new Date(0) },
|
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
|
-
};
|