@unchainedshop/core-assortments 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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-assortments",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"main": "lib/assortments-index.js",
|
|
5
5
|
"types": "lib/assortments-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",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^22.13.4",
|
|
41
|
-
"
|
|
42
|
-
"ts-jest": "^29.2.5",
|
|
41
|
+
"tsx": "^4.19.2",
|
|
43
42
|
"typescript": "^5.7.3"
|
|
44
43
|
}
|
|
45
44
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
1
2
|
import { buildFindSelector } from './configureAssortmentsModule.js';
|
|
3
|
+
import assert from 'node:assert';
|
|
2
4
|
|
|
3
5
|
describe('buildFindSelector', () => {
|
|
4
6
|
it('Return the correct filter when passed no argument', () => {
|
|
5
|
-
|
|
7
|
+
assert.deepStrictEqual(buildFindSelector({}), { isRoot: true, isActive: true, deleted: null });
|
|
6
8
|
});
|
|
7
9
|
it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves, slugs, tags', () => {
|
|
8
|
-
|
|
10
|
+
assert.deepStrictEqual(
|
|
9
11
|
buildFindSelector({
|
|
10
12
|
queryString: 'hello world',
|
|
11
13
|
assortmentIds: ['assortment-1', 'assortment-2'],
|
|
@@ -15,18 +17,19 @@ describe('buildFindSelector', () => {
|
|
|
15
17
|
slugs: ['assortment-slug-1', 'assortment-slug-2'],
|
|
16
18
|
tags: ['assortment-tag'],
|
|
17
19
|
}),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
{
|
|
21
|
+
sequence: 1,
|
|
22
|
+
_id: { $in: ['assortment-1', 'assortment-2'] },
|
|
23
|
+
slugs: { $in: ['assortment-slug-1', 'assortment-slug-2'] },
|
|
24
|
+
tags: { $all: ['assortment-tag'] },
|
|
25
|
+
deleted: null,
|
|
26
|
+
$text: { $search: 'hello world' },
|
|
27
|
+
},
|
|
28
|
+
);
|
|
26
29
|
});
|
|
27
30
|
|
|
28
31
|
it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves, slugs', () => {
|
|
29
|
-
|
|
32
|
+
assert.deepStrictEqual(
|
|
30
33
|
buildFindSelector({
|
|
31
34
|
queryString: 'hello world',
|
|
32
35
|
assortmentIds: ['assortment-1', 'assortment-2'],
|
|
@@ -35,18 +38,19 @@ describe('buildFindSelector', () => {
|
|
|
35
38
|
includeLeaves: true,
|
|
36
39
|
slugs: ['assortment-slug-1', 'assortment-slug-2'],
|
|
37
40
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
{
|
|
42
|
+
sequence: 1,
|
|
43
|
+
deleted: null,
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
_id: { $in: ['assortment-1', 'assortment-2'] },
|
|
46
|
+
slugs: { $in: ['assortment-slug-1', 'assortment-slug-2'] },
|
|
47
|
+
$text: { $search: 'hello world' },
|
|
48
|
+
},
|
|
49
|
+
);
|
|
46
50
|
});
|
|
47
51
|
|
|
48
52
|
it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive, includeLeaves', () => {
|
|
49
|
-
|
|
53
|
+
assert.deepStrictEqual(
|
|
50
54
|
buildFindSelector({
|
|
51
55
|
queryString: 'hello world',
|
|
52
56
|
assortmentIds: ['assortment-1', 'assortment-2'],
|
|
@@ -54,65 +58,64 @@ describe('buildFindSelector', () => {
|
|
|
54
58
|
includeInactive: true,
|
|
55
59
|
includeLeaves: true,
|
|
56
60
|
}),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
{
|
|
62
|
+
sequence: 1,
|
|
63
|
+
deleted: null,
|
|
64
|
+
_id: { $in: ['assortment-1', 'assortment-2'] },
|
|
65
|
+
$text: { $search: 'hello world' },
|
|
66
|
+
},
|
|
67
|
+
);
|
|
64
68
|
});
|
|
65
69
|
|
|
66
70
|
it('Return the correct filter when passed queryString, assortmentId, assortmentSelector, includeInactive', () => {
|
|
67
|
-
|
|
71
|
+
assert.deepStrictEqual(
|
|
68
72
|
buildFindSelector({
|
|
69
73
|
queryString: 'hello world',
|
|
70
74
|
assortmentIds: ['assortment-1', 'assortment-2'],
|
|
71
75
|
assortmentSelector: { sequence: 1 },
|
|
72
76
|
includeInactive: true,
|
|
73
77
|
}),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
{
|
|
79
|
+
sequence: 1,
|
|
80
|
+
deleted: null,
|
|
81
|
+
_id: { $in: ['assortment-1', 'assortment-2'] },
|
|
82
|
+
$text: { $search: 'hello world' },
|
|
83
|
+
},
|
|
84
|
+
);
|
|
81
85
|
});
|
|
82
86
|
it('Return the correct filter when passed queryString, assortmentId, assortmentSelector', () => {
|
|
83
|
-
|
|
87
|
+
assert.deepStrictEqual(
|
|
84
88
|
buildFindSelector({
|
|
85
89
|
queryString: 'hello world',
|
|
86
90
|
assortmentIds: ['assortment-1', 'assortment-2'],
|
|
87
91
|
assortmentSelector: { sequence: 1 },
|
|
88
92
|
}),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
{
|
|
94
|
+
sequence: 1,
|
|
95
|
+
deleted: null,
|
|
96
|
+
_id: { $in: ['assortment-1', 'assortment-2'] },
|
|
97
|
+
$text: { $search: 'hello world' },
|
|
98
|
+
},
|
|
99
|
+
);
|
|
96
100
|
});
|
|
97
101
|
|
|
98
102
|
it('Return the correct filter when passed assortmentId, assortmentSelector', () => {
|
|
99
|
-
|
|
103
|
+
assert.deepStrictEqual(
|
|
100
104
|
buildFindSelector({
|
|
101
105
|
assortmentIds: ['assortment-1', 'assortment-2'],
|
|
102
106
|
assortmentSelector: { sequence: 1 },
|
|
103
107
|
}),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
{
|
|
109
|
+
sequence: 1,
|
|
110
|
+
deleted: null,
|
|
111
|
+
_id: { $in: ['assortment-1', 'assortment-2'] },
|
|
112
|
+
},
|
|
113
|
+
);
|
|
110
114
|
});
|
|
111
115
|
|
|
112
116
|
it('Return the correct filter when passed assortmentSelector', () => {
|
|
113
|
-
|
|
117
|
+
assert.deepStrictEqual(buildFindSelector({ assortmentSelector: { sequence: 1 } }), {
|
|
114
118
|
deleted: null,
|
|
115
|
-
|
|
116
119
|
sequence: 1,
|
|
117
120
|
});
|
|
118
121
|
});
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
fillToSameLengthArray,
|
|
6
6
|
fillUp,
|
|
7
7
|
} from './zipTreeByDeepness.js';
|
|
8
|
+
import { describe, it } from 'node:test';
|
|
9
|
+
import assert from 'node:assert';
|
|
8
10
|
|
|
9
11
|
describe('divideTreeByLevels', () => {
|
|
10
12
|
it('should return the expected result', () => {
|
|
@@ -24,7 +26,7 @@ describe('divideTreeByLevels', () => {
|
|
|
24
26
|
},
|
|
25
27
|
];
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
assert.deepStrictEqual(divideTreeByLevels(array), expected);
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
|
|
@@ -35,7 +37,7 @@ describe('fillUp', () => {
|
|
|
35
37
|
|
|
36
38
|
const result = fillUp(arr, size);
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
assert.deepStrictEqual(result, [1, 2, 3, null, null]);
|
|
39
41
|
});
|
|
40
42
|
});
|
|
41
43
|
|
|
@@ -46,7 +48,7 @@ describe('fillToSameLengthArray', () => {
|
|
|
46
48
|
|
|
47
49
|
const result = fillToSameLengthArray(a, b);
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
assert.deepStrictEqual(result, [
|
|
50
52
|
[1, 2, 3],
|
|
51
53
|
[4, 5, null],
|
|
52
54
|
]);
|
|
@@ -61,6 +63,6 @@ describe('concatItemsByLevels', () => {
|
|
|
61
63
|
{ level: 1, items: ['e', 'f'] },
|
|
62
64
|
];
|
|
63
65
|
const result = concatItemsByLevels(levelArray);
|
|
64
|
-
|
|
66
|
+
assert.equal(result.length, 2);
|
|
65
67
|
});
|
|
66
68
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Tree } from '@unchainedshop/utils';
|
|
2
2
|
import zipTreeBySimplyFlattening from './zipTreeBySimplyFlattening.js';
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
import assert from 'node:assert';
|
|
3
5
|
|
|
4
6
|
describe('zipTreeBySimplyFlattening', () => {
|
|
5
7
|
it('should return the expected result', () => {
|
|
6
8
|
const array: Tree<string> = ['a', ['b', ['c', 'd']], 'e'];
|
|
7
9
|
const expected = ['a', 'b', 'c', 'd', 'e'];
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
assert.deepStrictEqual(zipTreeBySimplyFlattening(array), expected);
|
|
10
12
|
});
|
|
11
13
|
});
|
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
|
-
};
|