@unchainedshop/mongodb 3.1.0 → 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/mongodb",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "MongoDB provider for unchained platform",
|
|
5
5
|
"main": "lib/mongodb-index.js",
|
|
6
6
|
"types": "lib/mongodb-index.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"build": "tsc -b",
|
|
11
11
|
"prepublishOnly": "npm run clean && npm run build",
|
|
12
12
|
"watch": "tsc -w",
|
|
13
|
-
"test": "
|
|
14
|
-
"test:watch": "
|
|
13
|
+
"test": "tsx --test",
|
|
14
|
+
"test:watch": "tsx --test --watch"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -50,8 +50,7 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^22.13.
|
|
54
|
-
"jest": "^29.7.0",
|
|
53
|
+
"@types/node": "^22.13.4",
|
|
55
54
|
"typescript": "^5.7.3"
|
|
56
55
|
}
|
|
57
56
|
}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
1
3
|
import { insensitiveTrimmedRegexOperator } from './insensitive-trimmed-regex-operator.js';
|
|
2
4
|
|
|
3
5
|
describe('Email Regex Operator', () => {
|
|
4
6
|
it('should accept + mails', () => {
|
|
5
7
|
const input = 'test+test@test.com';
|
|
6
|
-
|
|
8
|
+
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
9
|
+
$regex: /^test\+test@test\.com$/i,
|
|
10
|
+
});
|
|
7
11
|
});
|
|
12
|
+
|
|
8
13
|
it('should trim mails', () => {
|
|
9
14
|
const input = ' test-two+test@test.com';
|
|
10
|
-
|
|
15
|
+
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
16
|
+
$regex: /^test-two\+test@test\.com$/i,
|
|
17
|
+
});
|
|
11
18
|
});
|
|
19
|
+
|
|
12
20
|
it('should not transform case', () => {
|
|
13
21
|
const input = ' tesT+tesT@test.com ';
|
|
14
|
-
|
|
22
|
+
assert.deepStrictEqual(insensitiveTrimmedRegexOperator(input), {
|
|
23
|
+
$regex: /^tesT\+tesT@test\.com$/i,
|
|
24
|
+
});
|
|
15
25
|
});
|
|
16
26
|
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
1
3
|
import { SortDirection } from '@unchainedshop/utils';
|
|
2
4
|
import { buildSortOptions, generateDbObjectId } from './mongodb-index.js';
|
|
3
5
|
|
|
4
6
|
describe('Mongo', () => {
|
|
5
7
|
it('Init', () => {
|
|
6
|
-
|
|
8
|
+
assert(true);
|
|
7
9
|
});
|
|
8
10
|
|
|
9
11
|
describe('buildSortOptions', () => {
|
|
@@ -12,27 +14,27 @@ describe('Mongo', () => {
|
|
|
12
14
|
{ key: 'name', value: SortDirection.ASC },
|
|
13
15
|
{ key: 'age', value: SortDirection.DESC },
|
|
14
16
|
];
|
|
15
|
-
|
|
17
|
+
assert.deepStrictEqual(buildSortOptions(sort), { name: 1, age: -1 });
|
|
16
18
|
});
|
|
17
19
|
});
|
|
18
20
|
|
|
19
21
|
describe('generateDbObjectId', () => {
|
|
20
22
|
it('generateDbObjectId with default digits', () => {
|
|
21
23
|
const result = generateDbObjectId();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
assert.strictEqual(typeof result, 'string');
|
|
25
|
+
assert.strictEqual(result.length, 24);
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
it('generateDbObjectId with odd digits', () => {
|
|
27
29
|
const result = generateDbObjectId(23);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
assert.strictEqual(typeof result, 'string');
|
|
31
|
+
assert.strictEqual(result.length, 23);
|
|
30
32
|
});
|
|
31
33
|
|
|
32
34
|
it('generateDbObjectId with even digits', () => {
|
|
33
35
|
const result = generateDbObjectId(24);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
assert.strictEqual(typeof result, 'string');
|
|
37
|
+
assert.strictEqual(result.length, 24);
|
|
36
38
|
});
|
|
37
39
|
});
|
|
38
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
|
-
};
|