@unchainedshop/plugins 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.
@@ -5,6 +5,7 @@ try {
5
5
  // eslint-disable-next-line
6
6
  // @ts-ignore
7
7
  checkoutNodeJssdk = await import('@paypal/checkout-server-sdk');
8
+ // TODO: npm warn deprecated @paypal/checkout-server-sdk@1.0.3: Package no longer supported. The author suggests using the @paypal/paypal-server-sdk package instead: https://www.npmjs.com/package/@paypal/paypal-server-sdk. Contact Support at https://www.npmjs.com/support for more info.
8
9
  }
9
10
  catch {
10
11
  /* */
@@ -1 +1 @@
1
- {"version":3,"file":"paypal-checkout.js","sourceRoot":"","sources":["../../src/payment/paypal-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,IAAI,iBAAiB,CAAC;AACtB,IAAI,CAAC;IACH,2BAA2B;IAC3B,aAAa;IACb,iBAAiB,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;AAClE,CAAC;AAAC,MAAM,CAAC;IACP,KAAK;AACP,CAAC;AAED,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,CAAC,CAAC;AAEtD,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,kBAAkB,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAExF;;;;;GAKG;AACH,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,MAAM,QAAQ,GAAG,gBAAgB,CAAC;IAClC,MAAM,YAAY,GAAG,aAAa,CAAC;IAEnC,OAAO,kBAAkB,KAAK,MAAM;QAClC,CAAC,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,YAAY,CAAC;QACvE,CAAC,CAAC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 @@
1
1
  {
2
2
  "name": "@unchainedshop/plugins",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "main": "lib/plugins-index.js",
5
5
  "types": "lib/plugins-index.d.ts",
6
6
  "exports": {
@@ -12,8 +12,8 @@
12
12
  "build": "tsc -b",
13
13
  "prepublishOnly": "npm run clean && npm run build",
14
14
  "watch": "tsc -w",
15
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --forceExit",
16
- "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --detectOpenHandles --forceExit"
15
+ "test": "tsx --test",
16
+ "test:watch": "tsx --test --watch"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
@@ -151,7 +151,6 @@
151
151
  "expiry-map": "^2.0.0",
152
152
  "express": "^5.0.1",
153
153
  "fastify": "^5.2.1",
154
- "jest": "^29.7.0",
155
154
  "mime-types": "^2.1.35",
156
155
  "minio": "^8.0.4",
157
156
  "nodemailer": "^6.10.0",
@@ -160,7 +159,7 @@
160
159
  "postfinancecheckout": "^4.5.0",
161
160
  "stripe": "^17.6.0",
162
161
  "tiny-secp256k1": "^2.2.3",
163
- "ts-jest": "^29.2.5",
162
+ "tsx": "^4.19.2",
164
163
  "twilio": "^5.4.4",
165
164
  "typescript": "^5.7.3",
166
165
  "web-push": "^3.6.7",
@@ -1,3 +1,5 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import generateSignature from './generateSignature';
2
4
 
3
5
  describe('Datatrans Signature', () => {
@@ -8,7 +10,8 @@ describe('Datatrans Signature', () => {
8
10
  timestamp: '12424123412',
9
11
  body: '{"card":{"3D":{"authenticationResponse":"D"},"alias":"70119122433810042","expiryMonth":"12","expiryYear":"21","info":{"brand":"VISA CREDIT","country":"GB","issuer":"DATATRANS","type":"credit","usage":"consumer"},"masked":"424242xxxxxx4242"},"currency":"CHF","detail":{"authorize":{"acquirerAuthorizationCode":"100055"}},"history":[{"action":"init","date":"2021-09-03T08:00:32Z","ip":"212.232.234.26","source":"api","success":true},{"action":"authorize","date":"2021-09-03T08:00:55Z","ip":"212.232.234.26","source":"redirect","success":true}],"language":"de","paymentMethod":"VIS","refno":"1NTU1NQ=","refno2":"user","status":"authorized","transactionId":"card_check_authorized","type":"card_check"}',
10
12
  };
11
- expect(await generateSignature({ security, signKey })(timestamp, body)).toEqual(
13
+ assert.strictEqual(
14
+ await generateSignature({ security, signKey })(timestamp, body),
12
15
  '5118c93025fdb16a110cdde3aa7669422da320cfe9478e35b531f45c4619d4db',
13
16
  );
14
17
  });
@@ -12,6 +12,7 @@ try {
12
12
  // eslint-disable-next-line
13
13
  // @ts-ignore
14
14
  checkoutNodeJssdk = await import('@paypal/checkout-server-sdk');
15
+ // TODO: npm warn deprecated @paypal/checkout-server-sdk@1.0.3: Package no longer supported. The author suggests using the @paypal/paypal-server-sdk package instead: https://www.npmjs.com/package/@paypal/paypal-server-sdk. Contact Support at https://www.npmjs.com/support for more info.
15
16
  } catch {
16
17
  /* */
17
18
  }
@@ -1,37 +1,41 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { HundredOff } from './discount-100-off.js';
2
4
 
3
5
  describe('HundredOff', () => {
4
6
  it('isManualAdditionAllowed', async () => {
5
7
  let x;
6
- expect(await HundredOff.isManualAdditionAllowed(x)).toBeTruthy();
8
+ assert.strictEqual(await HundredOff.isManualAdditionAllowed(x), true);
7
9
  });
8
10
  it('isManualRemovalAllowed', async () => {
9
- expect(await HundredOff.isManualRemovalAllowed()).toBeTruthy();
11
+ assert.strictEqual(await HundredOff.isManualRemovalAllowed(), true);
10
12
  });
11
13
  it('isValidForSystemTriggering', async () => {
12
14
  const context = {};
13
15
  const actions = await HundredOff.actions({ context } as any);
14
- expect(await actions.isValidForSystemTriggering()).toBeFalsy();
16
+ assert.strictEqual(await actions.isValidForSystemTriggering(), false);
15
17
  });
16
18
  it('isValidForCodeTriggering', async () => {
17
19
  const context = {};
18
20
  const actions = await HundredOff.actions({ context } as any);
19
- expect(await actions.isValidForCodeTriggering({ code: '100OFF' })).toBeTruthy();
20
- expect(await actions.isValidForCodeTriggering({ code: 'wrongcode' })).toBeFalsy();
21
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: '100OFF' }), true);
22
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: 'wrongcode' }), false);
21
23
  });
22
24
 
23
25
  it('discountForPricingAdapterKey', async () => {
24
26
  const context = {};
25
27
  const actions = await HundredOff.actions({ context } as any);
26
- expect(
28
+ assert.deepStrictEqual(
27
29
  actions.discountForPricingAdapterKey({
28
30
  pricingAdapterKey: 'shop.unchained.pricing.order-discount',
29
31
  } as any),
30
- ).toEqual({ fixedRate: 10000 });
31
- expect(
32
+ { fixedRate: 10000 },
33
+ );
34
+ assert.strictEqual(
32
35
  actions.discountForPricingAdapterKey({
33
36
  pricingAdapterKey: 'shop.unchained.pricing.other-discount',
34
37
  } as any),
35
- ).toBeNull();
38
+ null,
39
+ );
36
40
  });
37
41
  });
@@ -1,48 +1,52 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { HalfPriceManual } from './discount-half-price-manual.js';
2
4
 
3
5
  describe('HalfPriceManual', () => {
4
6
  it('isManualAdditionAllowed', async () => {
5
7
  let x;
6
- expect(await HalfPriceManual.isManualAdditionAllowed(x)).toBeTruthy();
8
+ assert.strictEqual(await HalfPriceManual.isManualAdditionAllowed(x), true);
7
9
  });
8
10
 
9
11
  it('isManualRemovalAllowed', async () => {
10
- expect(await HalfPriceManual.isManualRemovalAllowed()).toBeTruthy();
12
+ assert.strictEqual(await HalfPriceManual.isManualRemovalAllowed(), true);
11
13
  });
12
14
 
13
15
  it('isValidForSystemTriggering', async () => {
14
16
  const context = {};
15
17
  const actions = await HalfPriceManual.actions({ context } as any);
16
- expect(await actions.isValidForSystemTriggering()).toBeFalsy();
18
+ assert.strictEqual(await actions.isValidForSystemTriggering(), false);
17
19
  });
18
20
 
19
21
  it('isValidForCodeTriggering', async () => {
20
22
  const context = {};
21
23
  const actions = await HalfPriceManual.actions({ context } as any);
22
- expect(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' })).toBeTruthy();
23
- expect(await actions.isValidForCodeTriggering({ code: 'othercode' })).toBeFalsy();
24
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: 'HALFPRICE' }), true);
25
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: 'othercode' }), false);
24
26
  });
25
27
 
26
28
  it('discountForPricingAdapterKey', async () => {
27
29
  const context = {};
28
30
  const actions = await HalfPriceManual.actions({ context } as any);
29
- expect(
31
+ assert.deepStrictEqual(
30
32
  actions.discountForPricingAdapterKey({
31
33
  pricingAdapterKey: 'shop.unchained.pricing.product-discount',
32
34
  } as any),
33
- ).toEqual({ rate: 0.5 });
34
- expect(
35
+ { rate: 0.5 },
36
+ );
37
+ assert.strictEqual(
35
38
  actions.discountForPricingAdapterKey({
36
39
  pricingAdapterKey: 'shop.unchained.pricing.other-discount',
37
40
  } as any),
38
- ).toBeNull();
41
+ null,
42
+ );
39
43
  });
40
44
 
41
45
  it('Actions', async () => {
42
46
  const context = {};
43
47
  const actions = await HalfPriceManual.actions({ context } as any);
44
- expect(typeof actions.isValidForSystemTriggering).toBe('function');
45
- expect(typeof actions.isValidForCodeTriggering).toBe('function');
46
- expect(typeof actions.discountForPricingAdapterKey).toBe('function');
48
+ assert.strictEqual(typeof actions.isValidForSystemTriggering, 'function');
49
+ assert.strictEqual(typeof actions.isValidForCodeTriggering, 'function');
50
+ assert.strictEqual(typeof actions.discountForPricingAdapterKey, 'function');
47
51
  });
48
52
  });
@@ -1,48 +1,52 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { HalfPrice } from './discount-half-price.js';
2
4
 
3
5
  describe('HalfPrice', () => {
4
6
  it('isManualAdditionAllowed', async () => {
5
- expect(await HalfPrice.isManualAdditionAllowed('')).toBeFalsy();
7
+ assert.strictEqual(await HalfPrice.isManualAdditionAllowed(''), false);
6
8
  });
7
9
 
8
10
  it('isManualRemovalAllowed', async () => {
9
- expect(await HalfPrice.isManualRemovalAllowed()).toBeFalsy();
11
+ assert.strictEqual(await HalfPrice.isManualRemovalAllowed(), false);
10
12
  });
11
13
 
12
14
  it('isValidForSystemTriggering', async () => {
13
15
  const context = {
14
16
  modules: {
15
17
  users: {
16
- findUserById: import.meta.jest.fn(() => Promise.resolve({ tags: ['half-price'] })),
18
+ findUserById: async () => ({ tags: ['half-price'] }),
17
19
  },
18
20
  },
19
21
  order: { userId: 'user-id' },
20
22
  };
21
23
  const actions = await HalfPrice.actions({ context } as any);
22
- expect(await actions.isValidForSystemTriggering()).toBeTruthy();
24
+ assert.strictEqual(await actions.isValidForSystemTriggering(), true);
23
25
 
24
- context.modules.users.findUserById.mockImplementationOnce(() => Promise.resolve({ tags: [] }));
25
- expect(await actions.isValidForSystemTriggering()).toBeFalsy();
26
+ context.modules.users.findUserById = async () => ({ tags: [] });
27
+ assert.strictEqual(await actions.isValidForSystemTriggering(), false);
26
28
  });
29
+
27
30
  it('discountForPricingAdapterKey', async () => {
28
31
  const context = {};
29
32
  const actions = await HalfPrice.actions({ context } as any);
30
- expect(
33
+ assert.deepStrictEqual(
31
34
  actions.discountForPricingAdapterKey({
32
35
  pricingAdapterKey: 'shop.unchained.pricing.product-discount',
33
36
  } as any),
34
- ).toEqual({ rate: 0.5 });
35
- expect(
37
+ { rate: 0.5 },
38
+ );
39
+ assert.strictEqual(
36
40
  actions.discountForPricingAdapterKey({
37
41
  pricingAdapterKey: 'shop.unchained.pricing.other-discount',
38
42
  } as any),
39
- ).toBeNull();
43
+ null,
44
+ );
40
45
  });
41
46
 
42
47
  it('isValidForCodeTriggering', async () => {
43
48
  const context = {};
44
49
  const actions = await HalfPrice.actions({ context } as any);
45
-
46
- expect(await actions.isValidForCodeTriggering({ code: '' })).toBeFalsy();
50
+ assert.strictEqual(await actions.isValidForCodeTriggering({ code: '' }), false);
47
51
  });
48
52
  });
@@ -1,7 +1,10 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
1
4
  import { DeliveryFreePrice } from './free-delivery.js';
2
5
 
3
6
  describe('DeliveryFreePrice', () => {
4
7
  it('should return true', () => {
5
- expect(DeliveryFreePrice.isActivatedFor(undefined as any)).toBeTruthy();
8
+ assert.strictEqual(DeliveryFreePrice.isActivatedFor(undefined as any), true);
6
9
  });
7
10
  });
@@ -1,3 +1,5 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { rangeMatcher } from '../enrollments/licensed.js';
2
4
 
3
5
  describe('rangeMatcher', () => {
@@ -13,24 +15,24 @@ describe('rangeMatcher', () => {
13
15
  it('matches correctly when the date is within the range', () => {
14
16
  const range = { start: yesterday, end: tomorrow };
15
17
  const matcher = rangeMatcher(now);
16
- expect(matcher(range)).toBe(true);
18
+ assert.strictEqual(matcher(range), true);
17
19
  });
18
20
 
19
21
  it('does not match when the date is before the start of the range', () => {
20
22
  const range = { start: tomorrow, end: tomorrow };
21
23
  const matcher = rangeMatcher(yesterday);
22
- expect(matcher(range)).toBe(false);
24
+ assert.strictEqual(matcher(range), false);
23
25
  });
24
26
 
25
27
  it('does not match when the date is after the end of the range', () => {
26
28
  const range = { start: yesterday, end: yesterday };
27
29
  const matcher = rangeMatcher(tomorrow);
28
- expect(matcher(range)).toBe(false);
30
+ assert.strictEqual(matcher(range), false);
29
31
  });
30
32
 
31
33
  it('matches correctly when the date is not provided', () => {
32
34
  const range = { start: yesterdayTimestamp, end: tomorrowTimestamp };
33
35
  const matcher = rangeMatcher();
34
- expect(matcher(range)).toBe(true);
36
+ assert.strictEqual(matcher(range), true);
35
37
  });
36
38
  });
@@ -1,7 +1,9 @@
1
1
  import { OrderDelivery } from './order-delivery.js';
2
+ import { describe, it } from 'node:test';
3
+ import assert from 'node:assert';
2
4
 
3
5
  describe('OrderDelivery ', () => {
4
6
  it('isActivatedFor', () => {
5
- expect(OrderDelivery.isActivatedFor({} as any)).toBeTruthy();
7
+ assert.equal(OrderDelivery.isActivatedFor({} as any), true);
6
8
  });
7
9
  });
@@ -1,7 +1,10 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
1
4
  import { OrderDiscount } from './order-discount.js';
2
5
 
3
6
  describe('OrderDelivery ', () => {
4
7
  it('isActivatedFor', () => {
5
- expect(OrderDiscount.isActivatedFor({} as any)).toBeTruthy();
8
+ assert.equal(OrderDiscount.isActivatedFor({} as any), true);
6
9
  });
7
10
  });
@@ -1,3 +1,5 @@
1
+ import { describe, it } from 'node:test';
2
+
1
3
  describe('Plugins', () => {
2
4
  it.todo('Plugins Tests');
3
5
  });
@@ -1,47 +1,54 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+
1
4
  import { getTaxRate, isDeliveryAddressInSwitzerland } from './product-swiss-tax.js';
2
5
 
3
6
  describe('ProductSwissTax', () => {
4
7
  describe('getTaxRate', () => {
5
8
  it('default rate', () => {
6
- expect(
9
+ assert.strictEqual(
7
10
  getTaxRate({
8
11
  product: {} as any,
9
12
  order: {} as any,
10
13
  } as any),
11
- ).toBe(0.081);
14
+ 0.081,
15
+ );
12
16
  });
13
17
 
14
18
  it('reduced rate', () => {
15
- expect(
19
+ assert.strictEqual(
16
20
  getTaxRate({
17
21
  product: {
18
22
  tags: ['swiss-tax-category:reduced'],
19
23
  },
20
24
  order: {},
21
25
  } as any),
22
- ).toBe(0.026);
26
+ 0.026,
27
+ );
23
28
  });
24
29
 
25
30
  it('special rate', () => {
26
- expect(
31
+ assert.strictEqual(
27
32
  getTaxRate({
28
33
  product: {
29
34
  tags: ['swiss-tax-category:special'],
30
35
  },
31
36
  order: {},
32
37
  } as any),
33
- ).toBe(0.038);
38
+ 0.038,
39
+ );
34
40
  });
35
41
 
36
42
  it('default rate', () => {
37
- expect(
43
+ assert.strictEqual(
38
44
  getTaxRate({
39
45
  product: {
40
46
  tags: ['swiss-tax-category:default'],
41
47
  },
42
48
  order: {},
43
49
  } as any),
44
- ).toBe(0.081);
50
+ 0.081,
51
+ );
45
52
  });
46
53
  });
47
54
 
@@ -50,12 +57,12 @@ describe('ProductSwissTax', () => {
50
57
  modules: {
51
58
  orders: {
52
59
  deliveries: {
53
- findDelivery: import.meta.jest.fn(async ({ orderDeliveryId }) => {
60
+ findDelivery: async ({ orderDeliveryId }) => {
54
61
  if (orderDeliveryId === 'CH' || orderDeliveryId === 'LI')
55
62
  return { context: { address: { countryCode: 'CH' } } };
56
63
  if (orderDeliveryId === null) return { context: { address: null } };
57
64
  return { context: { address: { countryCode: 'RT' } } };
58
- }),
65
+ },
59
66
  },
60
67
  },
61
68
  },
@@ -66,26 +73,29 @@ describe('ProductSwissTax', () => {
66
73
  country: 'CH',
67
74
  };
68
75
  it('Should return true when passed country code CH', async () => {
69
- expect(
76
+ assert.strictEqual(
70
77
  await isDeliveryAddressInSwitzerland({ ...context, country: 'ch', order: null } as any),
71
- ).toBe(true);
78
+ true,
79
+ );
72
80
  });
73
81
 
74
82
  it('Should return true when passed country code LI', async () => {
75
- expect(
83
+ assert.strictEqual(
76
84
  await isDeliveryAddressInSwitzerland({ ...context, country: 'LI', order: null } as any),
77
- ).toBe(true);
85
+ true,
86
+ );
78
87
  });
79
88
 
80
89
  it('Should return false when country is neither CH nor LI and order is null', async () => {
81
- expect(
90
+ assert.strictEqual(
82
91
  await isDeliveryAddressInSwitzerland({ ...context, country: 'ET', order: null } as any),
83
- ).toBe(false);
92
+ false,
93
+ );
84
94
  });
85
95
 
86
96
  it('Order should take precedence over country parameter', async () => {
87
97
  // not CH or LI order so returns false
88
- expect(
98
+ assert.strictEqual(
89
99
  await isDeliveryAddressInSwitzerland({
90
100
  ...context,
91
101
  country: 'CH',
@@ -94,11 +104,12 @@ describe('ProductSwissTax', () => {
94
104
  billingAddress: { countryCode: 'ET' },
95
105
  },
96
106
  } as any),
97
- ).toBe(false);
107
+ false,
108
+ );
98
109
  });
99
110
 
100
111
  it('If order is not from CH and LI but billingAddress is, it should take precedence over country ', async () => {
101
- expect(
112
+ assert.strictEqual(
102
113
  await isDeliveryAddressInSwitzerland({
103
114
  ...context,
104
115
  country: 'IT',
@@ -107,11 +118,12 @@ describe('ProductSwissTax', () => {
107
118
  billingAddress: { countryCode: 'CH' },
108
119
  },
109
120
  } as any),
110
- ).toBe(true);
121
+ true,
122
+ );
111
123
  });
112
124
 
113
125
  it('Should return false if billingAddress is neither CH or LI and order does not have address', async () => {
114
- expect(
126
+ assert.strictEqual(
115
127
  await isDeliveryAddressInSwitzerland({
116
128
  ...context,
117
129
  country: null,
@@ -120,7 +132,8 @@ describe('ProductSwissTax', () => {
120
132
  billingAddress: { countryCode: 'HH' },
121
133
  },
122
134
  } as any),
123
- ).toBe(false);
135
+ false,
136
+ );
124
137
  });
125
138
  });
126
139
  });
@@ -1,18 +1,20 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
1
3
  import { SwissTaxCategories } from './ch';
2
4
 
3
5
  describe('SwissTaxCategories', () => {
4
6
  it('DEFAULT rate', () => {
5
- expect(SwissTaxCategories.DEFAULT.rate(new Date(2023, 1, 1))).toBe(0.077);
6
- expect(SwissTaxCategories.DEFAULT.rate(new Date(2024, 1, 1))).toBe(0.081);
7
+ assert.strictEqual(SwissTaxCategories.DEFAULT.rate(new Date(2023, 1, 1)), 0.077);
8
+ assert.strictEqual(SwissTaxCategories.DEFAULT.rate(new Date(2024, 1, 1)), 0.081);
7
9
  });
8
10
 
9
11
  it('REDUCED rate', () => {
10
- expect(SwissTaxCategories.REDUCED.rate(new Date(2023, 1, 1))).toBe(0.025);
11
- expect(SwissTaxCategories.REDUCED.rate(new Date(2024, 1, 1))).toBe(0.026);
12
+ assert.strictEqual(SwissTaxCategories.REDUCED.rate(new Date(2023, 1, 1)), 0.025);
13
+ assert.strictEqual(SwissTaxCategories.REDUCED.rate(new Date(2024, 1, 1)), 0.026);
12
14
  });
13
15
 
14
16
  it('SPECIAL rate', () => {
15
- expect(SwissTaxCategories.SPECIAL.rate(new Date(2023, 1, 1))).toBe(0.037);
16
- expect(SwissTaxCategories.SPECIAL.rate(new Date(2024, 1, 1))).toBe(0.038);
17
+ assert.strictEqual(SwissTaxCategories.SPECIAL.rate(new Date(2023, 1, 1)), 0.037);
18
+ assert.strictEqual(SwissTaxCategories.SPECIAL.rate(new Date(2024, 1, 1)), 0.038);
17
19
  });
18
20
  });
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
- };