@unchainedshop/core-orders 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-orders",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "main": "lib/orders-index.js",
5
5
  "types": "lib/orders-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": "NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --forceExit",
13
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --detectOpenHandles --forceExit"
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
- "jest": "^29.7.0",
42
- "ts-jest": "^29.2.5",
41
+ "tsx": "^4.19.2",
43
42
  "typescript": "^5.7.3"
44
43
  }
45
44
  }
@@ -1,3 +1,5 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { OrderStatus } from '../db/OrdersCollection.js';
2
4
  import { buildFindByIdSelector as buildFindByIdSelectorForDelivery } from './configureOrderDeliveriesModule.js';
3
5
  import { buildFindOrderDiscountByIdSelector } from './configureOrderDiscountsModule.js';
@@ -11,50 +13,54 @@ import buildFindSelectorForOrder from './buildFindSelector.js';
11
13
  describe('OrderPosition', () => {
12
14
  describe('buildFindSelector', () => {
13
15
  it('Return filter object when passed no argument', () => {
14
- expect(buildFindSelectorForOrder({})).toEqual({ status: { $ne: null } });
16
+ assert.deepStrictEqual(buildFindSelectorForOrder({}), { status: { $ne: null } });
15
17
  });
16
18
 
17
- it('Return filter object when passed no argument includeCarts, queryString, status, userId and (status should take precedence over includeCarts', () => {
18
- expect(
19
+ it('Return filter object when passed includeCarts, queryString, status, userId and (status should take precedence over includeCarts)', () => {
20
+ assert.deepStrictEqual(
19
21
  buildFindSelectorForOrder({
20
22
  includeCarts: false,
21
23
  queryString: 'hello world',
22
24
  status: [OrderStatus.CONFIRMED],
23
25
  userId: 'admin-id',
24
26
  }),
25
- ).toEqual({
26
- userId: 'admin-id',
27
- status: {
28
- $in: ['CONFIRMED'],
27
+ {
28
+ userId: 'admin-id',
29
+ status: {
30
+ $in: ['CONFIRMED'],
31
+ },
32
+ $text: { $search: 'hello world' },
29
33
  },
30
- $text: { $search: 'hello world' },
31
- });
34
+ );
32
35
  });
33
36
 
34
- it('Return filter object when passed no argument includeCarts, queryString, userId ', () => {
35
- expect(
37
+ it('Return filter object when passed includeCarts, queryString, userId', () => {
38
+ assert.deepStrictEqual(
36
39
  buildFindSelectorForOrder({
37
40
  includeCarts: true,
38
41
  queryString: 'hello world',
39
42
  userId: 'admin-id',
40
43
  }),
41
- ).toEqual({
42
- userId: 'admin-id',
43
-
44
- $text: { $search: 'hello world' },
45
- });
44
+ {
45
+ userId: 'admin-id',
46
+ $text: { $search: 'hello world' },
47
+ },
48
+ );
46
49
  });
47
50
 
48
- it('Return filter object when passed no argument queryString, userId ', () => {
49
- expect(buildFindSelectorForOrder({ queryString: 'hello world', userId: 'admin-id' })).toEqual({
50
- userId: 'admin-id',
51
- $text: { $search: 'hello world' },
52
- status: { $ne: null },
53
- });
51
+ it('Return filter object when passed queryString, userId', () => {
52
+ assert.deepStrictEqual(
53
+ buildFindSelectorForOrder({ queryString: 'hello world', userId: 'admin-id' }),
54
+ {
55
+ userId: 'admin-id',
56
+ $text: { $search: 'hello world' },
57
+ status: { $ne: null },
58
+ },
59
+ );
54
60
  });
55
61
 
56
- it('Return filter object when passed no argument queryString ', () => {
57
- expect(buildFindSelectorForOrder({ queryString: 'hello world' })).toEqual({
62
+ it('Return filter object when passed queryString', () => {
63
+ assert.deepStrictEqual(buildFindSelectorForOrder({ queryString: 'hello world' }), {
58
64
  $text: { $search: 'hello world' },
59
65
  status: { $ne: null },
60
66
  });
@@ -65,7 +71,7 @@ describe('OrderPosition', () => {
65
71
  describe('OrderDelivery', () => {
66
72
  describe('buildFindByIdSelector', () => {
67
73
  it('Return correct db _id selector', () => {
68
- expect(buildFindByIdSelectorForDelivery('order-delivery-id')).toEqual({
74
+ assert.deepStrictEqual(buildFindByIdSelectorForDelivery('order-delivery-id'), {
69
75
  _id: 'order-delivery-id',
70
76
  });
71
77
  });
@@ -75,7 +81,7 @@ describe('OrderDelivery', () => {
75
81
  describe('OrderDiscount', () => {
76
82
  describe('buildFindByIdSelector', () => {
77
83
  it('Return correct db _id selector', () => {
78
- expect(buildFindOrderDiscountByIdSelector('order-discount-id')).toEqual({
84
+ assert.deepStrictEqual(buildFindOrderDiscountByIdSelector('order-discount-id'), {
79
85
  _id: 'order-discount-id',
80
86
  });
81
87
  });
@@ -85,16 +91,21 @@ describe('OrderDiscount', () => {
85
91
  describe('OrderPayment', () => {
86
92
  describe('buildFindByIdSelector', () => {
87
93
  it('Return correct db _id selector', () => {
88
- expect(buildFindOrderPaymentByIdSelector('order-payment-id')).toEqual({ _id: 'order-payment-id' });
94
+ assert.deepStrictEqual(buildFindOrderPaymentByIdSelector('order-payment-id'), {
95
+ _id: 'order-payment-id',
96
+ });
89
97
  });
90
98
  });
91
99
 
92
100
  describe('buildFindByContextDataSelector', () => {
93
101
  it('Return correct db context field selector object', () => {
94
- expect(buildFindByContextDataSelector({ first: 'first value', second: 'second value' })).toEqual({
95
- 'context.first': 'first value',
96
- 'context.second': 'second value',
97
- });
102
+ assert.deepStrictEqual(
103
+ buildFindByContextDataSelector({ first: 'first value', second: 'second value' }),
104
+ {
105
+ 'context.first': 'first value',
106
+ 'context.second': 'second value',
107
+ },
108
+ );
98
109
  });
99
110
  });
100
111
  });
@@ -102,7 +113,7 @@ describe('OrderPayment', () => {
102
113
  describe('OrderPosition', () => {
103
114
  describe('buildFindByIdSelector', () => {
104
115
  it('Return correct db _id selector', () => {
105
- expect(buildFindOrderPositionByIdSelector('order-position-id')).toEqual({
116
+ assert.deepStrictEqual(buildFindOrderPositionByIdSelector('order-position-id'), {
106
117
  _id: 'order-position-id',
107
118
  });
108
119
  });
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
- };