@unchainedshop/core-assortments 2.0.0-rc.4 → 2.0.0

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/jest.config.js CHANGED
@@ -11,4 +11,7 @@ export default {
11
11
  },
12
12
  ],
13
13
  },
14
+ moduleNameMapper: {
15
+ '(.+)\\.js': '$1',
16
+ },
14
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-assortments",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0",
4
4
  "main": "lib/assortments-index.js",
5
5
  "exports": {
6
6
  ".": "./lib/assortments-index.js",
@@ -31,10 +31,10 @@
31
31
  },
32
32
  "homepage": "https://github.com/unchainedshop/unchained#readme",
33
33
  "dependencies": {
34
- "@unchainedshop/events": "^2.0.0-rc.4",
35
- "@unchainedshop/file-upload": "^2.0.0-rc.4",
36
- "@unchainedshop/logger": "^2.0.0-rc.4",
37
- "@unchainedshop/utils": "^2.0.0-rc.4",
34
+ "@unchainedshop/events": "^2.0.0",
35
+ "@unchainedshop/file-upload": "^2.0.0",
36
+ "@unchainedshop/logger": "^2.0.0",
37
+ "@unchainedshop/utils": "^2.0.0",
38
38
  "locale": "^0.1.0",
39
39
  "ramda": "^0.28.0",
40
40
  "simpl-schema": "=3.2.0"
@@ -42,10 +42,10 @@
42
42
  "devDependencies": {
43
43
  "@types/locale": "^0.1.1",
44
44
  "@types/node": "^18.11.18",
45
- "@unchainedshop/types": "^2.0.0-rc.4",
45
+ "@unchainedshop/types": "^2.0.0",
46
46
  "cross-env": "^7.0.3",
47
- "jest": "^29.3.1",
48
- "ts-jest": "^29.0.3",
47
+ "jest": "^29.4.1",
48
+ "ts-jest": "^29.0.5",
49
49
  "typescript": "^4.9.4"
50
50
  }
51
51
  }
@@ -1,10 +1,8 @@
1
- import { Tree } from "@unchainedshop/types/common.js";
2
- import { buildFindSelector } from "../lib/module/configureAssortmentsModule.js";
3
- import { divideTreeByLevels, concatItemsByLevels, fillToSameLengthArray, fillUp } from "../lib/utils/tree-zipper/zipTreeByDeepness.js";
1
+ import { buildFindSelector } from "./configureAssortmentsModule.js";
2
+
4
3
 
5
4
 
6
5
 
7
- describe('Assortment', () => {
8
6
  describe('buildFindSelector', () => {
9
7
  it('Return the correct filter when passed no argument', async () => {
10
8
  expect(buildFindSelector({})).toEqual({ isRoot: true, isActive: true, "deleted": null, })
@@ -90,74 +88,4 @@ describe('Assortment', () => {
90
88
  });
91
89
  })
92
90
 
93
-
94
-
95
- describe('divideTreeByLevels', () => {
96
- it('should return the expected result', () => {
97
- const array: Tree<string> = [
98
- 'a',
99
- [
100
- 'b',
101
- [
102
- 'c',
103
- 'd',
104
- ],
105
- ],
106
- 'e',
107
- ];
108
- const expected = [
109
- {
110
- level: 0,
111
- items: ['a', 'e'],
112
- },
113
- {
114
- level: 1,
115
- items: ['b'],
116
- },
117
- {
118
- level: 2,
119
- items: ['c', 'd'],
120
- },
121
- ];
122
-
123
- expect(divideTreeByLevels(array)).toEqual(expected);
124
- });
125
- });
126
-
127
-
128
- describe('fillUp', () => {
129
- it('should fill empty spaces with null based on the passed size parameter', () => {
130
- const arr = [1, 2, 3];
131
- const size = 5;
132
-
133
- const result = fillUp(arr, size);
134
-
135
- expect(result).toEqual([1, 2, 3, null, null]);
136
-
137
- })
138
-
139
- });
140
-
141
- describe('fillToSameLengthArray', () => {
142
- it('should fill missing value place with null', () => {
143
- const a = [1, 2, 3];
144
- const b = [4, 5];
145
-
146
- const result = fillToSameLengthArray(a, b);
147
-
148
- expect(result).toEqual([[1, 2, 3], [4, 5, null]]);
149
- })
150
- });
151
-
152
- test('concatItemsByLevels', () => {
153
- const levelArray = [ { level: 1, items: ['a', 'b'] },
154
- { level: 2, items: ['c', 'd'] },
155
- { level: 1, items: ['e', 'f'] },
156
- ];
157
- const result = concatItemsByLevels(levelArray);
158
- expect(result.length).toBe(2);
159
-
160
- });
161
-
162
-
163
- });
91
+
@@ -0,0 +1,66 @@
1
+ import { Tree } from '@unchainedshop/types/common.js';
2
+ import { concatItemsByLevels, divideTreeByLevels, fillToSameLengthArray, fillUp } from './zipTreeByDeepness.js';
3
+
4
+
5
+ describe('divideTreeByLevels', () => {
6
+ it('should return the expected result', () => {
7
+ const array: Tree<string> = ['a', ['b', ['c', 'd']], 'e'];
8
+ const expected = [
9
+ {
10
+ level: 0,
11
+ items: ['a', 'e'],
12
+ },
13
+ {
14
+ level: 1,
15
+ items: ['b'],
16
+ },
17
+ {
18
+ level: 2,
19
+ items: ['c', 'd'],
20
+ },
21
+ ];
22
+
23
+ expect(divideTreeByLevels(array)).toEqual(expected);
24
+ });
25
+ });
26
+
27
+ describe('fillUp', () => {
28
+ it('should fill empty spaces with null based on the passed size parameter', () => {
29
+ const arr = [1, 2, 3];
30
+ const size = 5;
31
+
32
+ const result = fillUp(arr, size);
33
+
34
+ expect(result).toEqual([1, 2, 3, null, null]);
35
+ });
36
+ });
37
+
38
+ describe('fillToSameLengthArray', () => {
39
+ it('should fill missing value place with null', () => {
40
+ const a = [1, 2, 3];
41
+ const b = [4, 5];
42
+
43
+ const result = fillToSameLengthArray(a, b);
44
+
45
+ expect(result).toEqual([
46
+ [1, 2, 3],
47
+ [4, 5, null],
48
+ ]);
49
+ });
50
+ });
51
+
52
+
53
+
54
+ describe("concatItemsByLevels", () => {
55
+ it('should concatenate the array and create array with length 2', () => {
56
+ const levelArray = [
57
+ { level: 1, items: ['a', 'b'] },
58
+ { level: 2, items: ['c', 'd'] },
59
+ { level: 1, items: ['e', 'f'] },
60
+ ];
61
+ const result = concatItemsByLevels(levelArray);
62
+ expect(result.length).toBe(2);
63
+ });
64
+
65
+
66
+ })
package/tsconfig.json CHANGED
@@ -1,29 +1,11 @@
1
1
  {
2
+ "extends": "../shared/base.tsconfig.json",
2
3
  "compilerOptions": {
3
- "allowJs": true,
4
- "allowSyntheticDefaultImports": true,
5
- "declaration": true,
6
- "esModuleInterop": true,
7
- "experimentalDecorators": true,
8
- "forceConsistentCasingInFileNames": true,
9
- "lib": [
10
- "esnext"
11
- ],
12
- "module": "Node16",
13
- "moduleResolution": "Node16",
14
- "noImplicitReturns": true,
15
- "noUnusedLocals": false,
4
+ "rootDir": "src",
16
5
  "outDir": "lib",
17
- "preserveWatchOutput": true,
18
- "skipLibCheck": true,
19
- "sourceMap": true,
20
- "target": "ES2022",
21
- "types": [
22
- "node",
23
- "jest"
24
- ]
25
6
  },
7
+ "exclude": ["**/*.test.ts", "**/*.test.js", "tests"],
26
8
  "include": [
27
- "src"
9
+ "./src"
28
10
  ]
29
11
  }