@velocitycareerlabs/server-webwallet 1.26.0-dev-build.1f5f235dd → 1.26.0-dev-build.1a6aed3a4

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.
@@ -1,3 +1,43 @@
1
+ const { expect } = require('expect');
2
+ const {
3
+ after,
4
+ afterEach,
5
+ before,
6
+ beforeEach,
7
+ describe,
8
+ it,
9
+ mock,
10
+ } = require('node:test');
11
+
12
+ const getPresentationRequest = mock.fn(() =>
13
+ Promise.resolve(presentationRequestMock)
14
+ );
15
+ const getCredentialManifest = mock.fn(() =>
16
+ Promise.resolve(getCredentialManifestMock)
17
+ );
18
+ const submitPresentation = mock.fn(() => Promise.resolve(submissionResultMock));
19
+ const getAuthToken = mock.fn(() =>
20
+ Promise.resolve({
21
+ value: 'mock_auth_token',
22
+ accessToken: { value: 'mock_access_token' },
23
+ refreshToken: { value: 'mock_refresh_token' },
24
+ })
25
+ );
26
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
27
+ namedExports: {
28
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
29
+ VCLProvider: {
30
+ getInstance: mock.fn(() => ({
31
+ initialize: mock.fn(() => Promise.resolve(null)),
32
+ getPresentationRequest,
33
+ getCredentialManifest,
34
+ submitPresentation,
35
+ getAuthToken,
36
+ })),
37
+ },
38
+ },
39
+ });
40
+
1
41
  const nock = require('nock');
2
42
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
3
43
  const { ObjectId } = require('mongodb');
@@ -5,49 +45,20 @@ const { jwtDecode } = require('@verii/jwt');
5
45
  const { errorResponseMatcher } = require('@verii/tests-helpers');
6
46
  const { omit } = require('lodash/fp');
7
47
  const {
8
- VCLProvider,
9
48
  VCLPresentationRequestDescriptor,
10
49
  VCLDeepLink,
11
50
  } = require('@verii/vnf-nodejs-wallet-sdk');
51
+ const {
52
+ presentationRequestMock,
53
+ submissionResultMock,
54
+ getCredentialManifestMock,
55
+ } = require('./mocks');
12
56
 
13
57
  const initAccountsFactory = require('../factories/accounts');
14
58
 
15
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
16
- const {
17
- presentationRequestMock,
18
- submissionResultMock,
19
- getCredentialManifestMock,
20
- } = require('./mocks');
21
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
22
-
23
- return {
24
- ...originalModule,
25
- VCLProvider: {
26
- getInstance: jest.fn().mockReturnValue({
27
- initialize: jest.fn().mockResolvedValue(null),
28
- getPresentationRequest: jest
29
- .fn()
30
- .mockResolvedValue(presentationRequestMock),
31
- getCredentialManifest: jest
32
- .fn()
33
- .mockResolvedValue(getCredentialManifestMock),
34
- submitPresentation: jest.fn().mockResolvedValue(submissionResultMock),
35
- getAuthToken: jest.fn().mockResolvedValue({
36
- value: 'mock_auth_token',
37
- accessToken: { value: 'mock_access_token' },
38
- refreshToken: { value: 'mock_refresh_token' },
39
- }),
40
- }),
41
- },
42
- };
43
- });
44
-
45
- const vclSdk = VCLProvider.getInstance();
46
-
47
59
  const buildFastify = require('../helpers/webwallet-build-fastify');
48
60
  const { CredentialMocks } = require('../mocks/credentials');
49
61
  const { presentationSubmissionMock } = require('./mocks');
50
- const { submissionResultMock } = require('./mocks/submission-result');
51
62
  const { WebWalletServerError } = require('../../src/errors/error-codes');
52
63
 
53
64
  const idToken =
@@ -60,7 +71,7 @@ describe('Test disclosure credentials controller', () => {
60
71
  const userId = '1234567890';
61
72
  const did = 'did:example:123';
62
73
 
63
- beforeAll(async () => {
74
+ before(async () => {
64
75
  fastify = buildFastify();
65
76
 
66
77
  await fastify.ready();
@@ -74,17 +85,18 @@ describe('Test disclosure credentials controller', () => {
74
85
  });
75
86
 
76
87
  beforeEach(async () => {
88
+ getPresentationRequest.mock.resetCalls();
89
+ getAuthToken.mock.resetCalls();
77
90
  nock('https://localhost/').get('/.well-known/jwks.json').reply(200, jwks);
78
91
  });
79
92
 
80
93
  afterEach(async () => {
81
94
  nock.cleanAll();
82
- jest.clearAllMocks();
83
95
  await mongoDb().collection('disclosures').deleteMany();
84
96
  await mongoDb().collection('feeds').deleteMany();
85
97
  });
86
98
 
87
- afterAll(async () => {
99
+ after(async () => {
88
100
  nock.restore();
89
101
  await mongoDb().collection('accounts').deleteMany();
90
102
  await fastify.close();
@@ -104,12 +116,12 @@ describe('Test disclosure credentials controller', () => {
104
116
 
105
117
  expect(response.statusCode).toBe(200);
106
118
 
107
- expect(vclSdk.getPresentationRequest).toHaveBeenCalledTimes(1);
108
- expect(vclSdk.getPresentationRequest).toHaveBeenCalledWith(
119
+ expect(getPresentationRequest.mock.callCount()).toEqual(1);
120
+ expect(getPresentationRequest.mock.calls[0].arguments).toEqual([
109
121
  new VCLPresentationRequestDescriptor(
110
122
  new VCLDeepLink(inspectionDeepLink)
111
- )
112
- );
123
+ ),
124
+ ]);
113
125
 
114
126
  expect(response.json).toEqual({
115
127
  presentation: {
@@ -193,22 +205,22 @@ describe('Test disclosure credentials controller', () => {
193
205
 
194
206
  expect(response.statusCode).toBe(200);
195
207
 
196
- expect(vclSdk.getPresentationRequest).toHaveBeenCalledTimes(1);
197
- expect(vclSdk.getPresentationRequest).toHaveBeenCalledWith(
208
+ expect(getPresentationRequest.mock.callCount()).toEqual(1);
209
+ expect(getPresentationRequest.mock.calls[0].arguments).toEqual([
198
210
  new VCLPresentationRequestDescriptor(
199
211
  new VCLDeepLink(inspectionDeepLink),
200
212
  null,
201
213
  null,
202
214
  null
203
- )
204
- );
215
+ ),
216
+ ]);
205
217
 
206
218
  const { payload: presentation } = jwtDecode(
207
219
  presentationRequestMock.jwt.encodedJwt
208
220
  );
209
221
 
210
- expect(vclSdk.submitPresentation).toHaveBeenCalledTimes(1);
211
- expect(vclSdk.submitPresentation).toHaveBeenCalledWith(
222
+ expect(submitPresentation.mock.callCount()).toEqual(1);
223
+ expect(submitPresentation.mock.calls[0].arguments).toEqual([
212
224
  expect.objectContaining({
213
225
  exchangeId: submissionResultMock.exchange.id,
214
226
  submitUri: presentationSubmissionMock.submitUri,
@@ -221,8 +233,8 @@ describe('Test disclosure credentials controller', () => {
221
233
  },
222
234
  ],
223
235
  }),
224
- null
225
- );
236
+ null,
237
+ ]);
226
238
  const savedDisclosure = await mongoDb()
227
239
  .collection('disclosures')
228
240
  .findOne();
@@ -258,8 +270,8 @@ describe('Test disclosure credentials controller', () => {
258
270
  feed: true,
259
271
  };
260
272
 
261
- vclSdk.getPresentationRequest.mockResolvedValueOnce(
262
- presentationRequestFeedMock
273
+ getPresentationRequest.mock.mockImplementationOnce(() =>
274
+ Promise.resolve(presentationRequestFeedMock)
263
275
  );
264
276
 
265
277
  const response = await fastify.injectJson({
@@ -282,7 +294,7 @@ describe('Test disclosure credentials controller', () => {
282
294
 
283
295
  expect(response.statusCode).toBe(200);
284
296
 
285
- expect(vclSdk.getAuthToken).toHaveBeenCalledTimes(1);
297
+ expect(getAuthToken.mock.callCount()).toEqual(1);
286
298
 
287
299
  const savedDisclosure = await mongoDb()
288
300
  .collection('disclosures')
@@ -410,8 +422,8 @@ describe('Test disclosure credentials controller', () => {
410
422
  feed: true,
411
423
  };
412
424
 
413
- vclSdk.getPresentationRequest.mockResolvedValueOnce(
414
- presentationRequestFeedMock
425
+ getPresentationRequest.mock.mockImplementationOnce(() =>
426
+ Promise.resolve(presentationRequestFeedMock)
415
427
  );
416
428
 
417
429
  const response = await fastify.injectJson({
@@ -428,7 +440,7 @@ describe('Test disclosure credentials controller', () => {
428
440
 
429
441
  expect(response.statusCode).toBe(200);
430
442
 
431
- expect(vclSdk.getAuthToken).toHaveBeenCalledTimes(1);
443
+ expect(getAuthToken.mock.callCount()).toEqual(1);
432
444
 
433
445
  const savedDisclosure = await mongoDb()
434
446
  .collection('disclosures')
@@ -449,8 +461,8 @@ describe('Test disclosure credentials controller', () => {
449
461
  feed: false,
450
462
  };
451
463
 
452
- vclSdk.getPresentationRequest.mockResolvedValueOnce(
453
- presentationRequestFeedMock
464
+ getPresentationRequest.mock.mockImplementationOnce(() =>
465
+ Promise.resolve(presentationRequestFeedMock)
454
466
  );
455
467
 
456
468
  const response = await fastify.injectJson({
@@ -1,3 +1,17 @@
1
+ const { after, afterEach, before, describe, it, mock } = require('node:test');
2
+ const { expect } = require('expect');
3
+
4
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
5
+ namedExports: {
6
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
7
+ VCLProvider: {
8
+ getInstance: mock.fn(() => ({
9
+ initialize: mock.fn(() => Promise.resolve(null)),
10
+ })),
11
+ },
12
+ },
13
+ });
14
+
1
15
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
16
  const { omit } = require('lodash/fp');
3
17
  const nock = require('nock');
@@ -12,24 +26,11 @@ const auth0Token =
12
26
  // eslint-disable-next-line max-len
13
27
  'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IktFWSJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0LyIsImF1ZCI6ImZvbyIsInNjb3BlIjoicmVhZDp1c2VycyJ9.VwIIUqx9T-AxqbfL_FyNRAeOxTwiC2JpcwtrqnEWN3DdF07ijUkF1WYy8Ahfr_p4R3KnoPbiefZnIbVANCt-lt0ej32rfil2yHhQEsvFxSOjcrx6ARmPp0YAfWlN-5Sotzkxy29jaOZMEDkmRFZg3jkdC7wosPW_S6M-olC4g3HHfylpZI8O3Jdd87Qr9wD_QtUzANwnPbl2Q-9NEyxVjAZIWg_HWK9JAAaf_2IY5VwHBvyp0oeQSEHKi4hogcM59EOc4FxdR5WH45B_PenVa6W4mHFBkH8sAXxt2Zs9s2efujkfWYfyXvgL_lN7vT-TEADlAPP2L6CpWpDISOMsQWUSgGHcN_KwRh_E7qJwahR6mv4QHY6ReEoyjkmSS3swrD1l74jNs7QLAdsMywvzCMDsHabs7DYcEMGQBdP14PJ_ucLFnkivZeBDAc6sS445ocbyrpyO40XMaMorD5khRd9ej89SxR7d_v0W6Ne2Nn4XgW3pAZzu5Rdc4JvqfzLFxkp95jxy1MTAddjWISPmNOYYyXHM9SSqSpqVECOFS0f4z2zycHRqXUcOytWrvED6VGo9x7-IVCgu8vFzj0zToIWQmsDs3UoH9RnV12z0PMwGXQzca1lT_zGwJxBF3e4zJjmcJ05OMF2JgZ2_G48O3M4Dtb0jlgWbKLd0kWlIFzQ';
14
28
 
15
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
16
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
17
-
18
- return {
19
- ...originalModule,
20
- VCLProvider: {
21
- getInstance: jest.fn().mockReturnValue({
22
- initialize: jest.fn().mockResolvedValue(null),
23
- }),
24
- },
25
- };
26
- });
27
-
28
29
  let persistDisclosures;
29
30
  describe('Test Disclosures controller, get disclosures list, delete disclosure', () => {
30
31
  let fastify;
31
32
 
32
- beforeAll(async () => {
33
+ before(async () => {
33
34
  fastify = buildFastify();
34
35
 
35
36
  nock('https://localhost/').get('/.well-known/jwks.json').reply(200, jwks);
@@ -45,7 +46,7 @@ describe('Test Disclosures controller, get disclosures list, delete disclosure',
45
46
  await mongoDb().collection('disclosures').deleteMany({});
46
47
  });
47
48
 
48
- afterAll(async () => {
49
+ after(async () => {
49
50
  nock.restore();
50
51
  await fastify.close();
51
52
  });
@@ -1,3 +1,17 @@
1
+ const { after, afterEach, before, describe, it, mock } = require('node:test');
2
+ const { expect } = require('expect');
3
+
4
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
5
+ namedExports: {
6
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
7
+ VCLProvider: {
8
+ getInstance: mock.fn(() => ({
9
+ initialize: mock.fn(() => Promise.resolve(null)),
10
+ })),
11
+ },
12
+ },
13
+ });
14
+
1
15
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
16
  const nock = require('nock');
3
17
  const buildFastify = require('./helpers/webwallet-build-fastify');
@@ -11,23 +25,11 @@ const auth0Token =
11
25
 
12
26
  const auth0userId = '1234567890';
13
27
  const usersDid = 'did:example:123';
14
-
15
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
16
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
17
- return {
18
- ...originalModule,
19
- VCLProvider: {
20
- getInstance: jest.fn().mockReturnValue({
21
- initialize: jest.fn().mockResolvedValue(null),
22
- }),
23
- },
24
- };
25
- });
26
28
  describe('feedback-controller', () => {
27
29
  let fastify;
28
30
  let persistAccounts;
29
31
 
30
- beforeAll(async () => {
32
+ before(async () => {
31
33
  fastify = buildFastify();
32
34
  nock('https://localhost/')
33
35
  .persist()
@@ -41,9 +43,10 @@ describe('feedback-controller', () => {
41
43
  await mongoDb().collection('accounts').deleteMany({});
42
44
  });
43
45
 
44
- afterAll(async () => {
46
+ after(async () => {
45
47
  nock.restore();
46
48
  await fastify.close();
49
+ mock.reset();
47
50
  });
48
51
  describe('POST feedback', () => {
49
52
  it('should return 204 and send a user feedback', async () => {
@@ -1,3 +1,17 @@
1
+ const { after, afterEach, before, describe, it, mock } = require('node:test');
2
+ const { expect } = require('expect');
3
+
4
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
5
+ namedExports: {
6
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
7
+ VCLProvider: {
8
+ getInstance: mock.fn(() => ({
9
+ initialize: mock.fn(() => Promise.resolve(null)),
10
+ })),
11
+ },
12
+ },
13
+ });
14
+
1
15
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
16
  const nock = require('nock');
3
17
  const buildFastify = require('./helpers/webwallet-build-fastify');
@@ -9,24 +23,12 @@ const auth0Token =
9
23
  'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IktFWSJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0LyIsImF1ZCI6ImZvbyIsInNjb3BlIjoicmVhZDp1c2VycyJ9.VwIIUqx9T-AxqbfL_FyNRAeOxTwiC2JpcwtrqnEWN3DdF07ijUkF1WYy8Ahfr_p4R3KnoPbiefZnIbVANCt-lt0ej32rfil2yHhQEsvFxSOjcrx6ARmPp0YAfWlN-5Sotzkxy29jaOZMEDkmRFZg3jkdC7wosPW_S6M-olC4g3HHfylpZI8O3Jdd87Qr9wD_QtUzANwnPbl2Q-9NEyxVjAZIWg_HWK9JAAaf_2IY5VwHBvyp0oeQSEHKi4hogcM59EOc4FxdR5WH45B_PenVa6W4mHFBkH8sAXxt2Zs9s2efujkfWYfyXvgL_lN7vT-TEADlAPP2L6CpWpDISOMsQWUSgGHcN_KwRh_E7qJwahR6mv4QHY6ReEoyjkmSS3swrD1l74jNs7QLAdsMywvzCMDsHabs7DYcEMGQBdP14PJ_ucLFnkivZeBDAc6sS445ocbyrpyO40XMaMorD5khRd9ej89SxR7d_v0W6Ne2Nn4XgW3pAZzu5Rdc4JvqfzLFxkp95jxy1MTAddjWISPmNOYYyXHM9SSqSpqVECOFS0f4z2zycHRqXUcOytWrvED6VGo9x7-IVCgu8vFzj0zToIWQmsDs3UoH9RnV12z0PMwGXQzca1lT_zGwJxBF3e4zJjmcJ05OMF2JgZ2_G48O3M4Dtb0jlgWbKLd0kWlIFzQ;';
10
24
 
11
25
  const auth0UserId = '1234567890';
12
-
13
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
14
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
15
- return {
16
- ...originalModule,
17
- VCLProvider: {
18
- getInstance: jest.fn().mockReturnValue({
19
- initialize: jest.fn().mockResolvedValue(null),
20
- }),
21
- },
22
- };
23
- });
24
26
  describe('Feeds Controller', () => {
25
27
  let fastify;
26
28
  let persistFeeds;
27
29
  let persistDisclosures;
28
30
 
29
- beforeAll(async () => {
31
+ before(async () => {
30
32
  fastify = buildFastify();
31
33
  nock('https://localhost/').get('/.well-known/jwks.json').reply(200, jwks);
32
34
  await fastify.ready();
@@ -42,9 +44,10 @@ describe('Feeds Controller', () => {
42
44
  await mongoDb().collection('disclosures').deleteMany({});
43
45
  });
44
46
 
45
- afterAll(async () => {
47
+ after(async () => {
46
48
  nock.restore();
47
49
  await fastify.close();
50
+ mock.reset();
48
51
  });
49
52
 
50
53
  describe('getFeeds', () => {
@@ -1,3 +1,7 @@
1
+ const { beforeEach, describe, it } = require('node:test');
2
+
3
+ const { expect } = require('expect');
4
+
1
5
  const buildFastify = require('fastify');
2
6
  const nock = require('nock');
3
7
  const got = require('got');
@@ -1,27 +1,28 @@
1
- const { mongoDb } = require('@spencejs/spence-mongo-repos');
2
- const webwalletBuildFastify = require('./helpers/webwallet-build-fastify');
3
- const { credentialsRepoPlugin } = require('../src/entities');
4
- const initCredentialsFactory = require('./factories/credentials');
5
-
6
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
7
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
1
+ const { after, afterEach, before, describe, it, mock } = require('node:test');
2
+ const { expect } = require('expect');
8
3
 
9
- return {
10
- ...originalModule,
4
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
5
+ namedExports: {
6
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
11
7
  VCLProvider: {
12
- getInstance: jest.fn().mockReturnValue({
13
- initialize: jest.fn().mockResolvedValue(null),
14
- }),
8
+ getInstance: mock.fn(() => ({
9
+ initialize: mock.fn(() => Promise.resolve(null)),
10
+ })),
15
11
  },
16
- };
12
+ },
17
13
  });
18
14
 
15
+ const { mongoDb } = require('@spencejs/spence-mongo-repos');
16
+ const webwalletBuildFastify = require('./helpers/webwallet-build-fastify');
17
+ const { credentialsRepoPlugin } = require('../src/entities');
18
+ const initCredentialsFactory = require('./factories/credentials');
19
+
19
20
  describe('Test filterDeletedCredentialsExtension', () => {
20
21
  let fastify;
21
22
  let credentialsRepo;
22
23
  let persistCredentials;
23
24
 
24
- beforeAll(async () => {
25
+ before(async () => {
25
26
  fastify = webwalletBuildFastify();
26
27
  await fastify.ready();
27
28
 
@@ -36,8 +37,9 @@ describe('Test filterDeletedCredentialsExtension', () => {
36
37
  await mongoDb().collection('credentials').deleteMany({});
37
38
  });
38
39
 
39
- afterAll(async () => {
40
+ after(async () => {
40
41
  await fastify.close();
42
+ mock.reset();
41
43
  });
42
44
 
43
45
  it('Credentials with deletedAt field shouldn`t be visible for find requests', async () => {
@@ -5,48 +5,56 @@
5
5
  * SPDX-License-Identifier: Apache-2.0
6
6
  */
7
7
 
8
+ const {
9
+ after,
10
+ afterEach,
11
+ before,
12
+ beforeEach,
13
+ describe,
14
+ it,
15
+ mock,
16
+ } = require('node:test');
17
+ const { expect } = require('expect');
18
+
8
19
  const nock = require('nock');
9
20
  const { mongoDb } = require('@spencejs/spence-mongo-repos');
21
+ const { VCLFinalizeOffersDescriptor } = require('@verii/vnf-nodejs-wallet-sdk');
22
+ const { vclMockCredentialManifest } = require('./mocks');
23
+ const { mockEmptyOffers } = require('./mocks/offers');
24
+ const { mockIssuers } = require('./mocks/issuers');
10
25
  const {
11
- VCLFinalizeOffersDescriptor,
12
- VCLProvider,
13
- } = require('@verii/vnf-nodejs-wallet-sdk');
14
- const { vclMockCredentialManifest } = require('./mocks/credential-manifest');
15
-
16
- jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
17
- const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
18
-
19
- const {
20
- mockAcceptedEmptyCredentials,
21
- } = require('./mocks/accepted-credentials');
22
- // eslint-disable-next-line no-shadow
23
- const { vclMockCredentialManifest } = require('./mocks');
24
- const { mockEmptyOffers } = require('./mocks/offers');
25
- const { mockIssuers } = require('./mocks/issuers');
26
-
27
- return {
28
- ...originalModule,
26
+ mockAcceptedEmptyCredentials,
27
+ } = require('./mocks/accepted-credentials');
28
+ const { mockCredentialTypes } = require('../mocks');
29
+
30
+ const initialize = mock.fn(() => Promise.resolve(null));
31
+ const getCredentialManifest = mock.fn(() =>
32
+ Promise.resolve(vclMockCredentialManifest)
33
+ );
34
+ const generateOffers = mock.fn(() => Promise.resolve(mockEmptyOffers));
35
+ const searchForOrganizations = mock.fn(() => Promise.resolve(mockIssuers));
36
+ const finalizeOffers = mock.fn(() =>
37
+ Promise.resolve(mockAcceptedEmptyCredentials)
38
+ );
39
+
40
+ mock.module('@verii/vnf-nodejs-wallet-sdk', {
41
+ namedExports: {
42
+ ...require('@verii/vnf-nodejs-wallet-sdk'),
29
43
  VCLProvider: {
30
- getInstance: jest.fn().mockReturnValue({
31
- initialize: jest.fn().mockResolvedValue(null),
32
- getCredentialManifest: jest
33
- .fn()
34
- .mockResolvedValue(vclMockCredentialManifest),
35
- generateOffers: jest.fn().mockResolvedValue(mockEmptyOffers),
36
- searchForOrganizations: jest.fn().mockResolvedValue(mockIssuers),
37
- finalizeOffers: jest
38
- .fn()
39
- .mockResolvedValue(mockAcceptedEmptyCredentials),
40
- }),
44
+ getInstance: mock.fn(() => ({
45
+ initialize,
46
+ getCredentialManifest,
47
+ generateOffers,
48
+ searchForOrganizations,
49
+ finalizeOffers,
50
+ credentialTypes: mockCredentialTypes,
51
+ })),
41
52
  },
42
- };
53
+ },
43
54
  });
44
55
 
45
- const vclSdk = VCLProvider.getInstance();
46
56
  const initAccountsFactory = require('../factories/accounts');
47
57
 
48
- const { mockEmptyOffers } = require('./mocks');
49
-
50
58
  const buildFastify = require('../helpers/webwallet-build-fastify');
51
59
  const { mockParsedEmptyResponse } = require('./mocks/accept-offers-response');
52
60
  const { Jwk } = require('../mocks/jwk');
@@ -59,7 +67,7 @@ describe('Test Deep Link issuing controller', () => {
59
67
  let fastify;
60
68
  let persistAccounts;
61
69
 
62
- beforeAll(async () => {
70
+ before(async () => {
63
71
  fastify = buildFastify();
64
72
 
65
73
  await fastify.ready();
@@ -78,15 +86,15 @@ describe('Test Deep Link issuing controller', () => {
78
86
 
79
87
  afterEach(async () => {
80
88
  nock.cleanAll();
81
- jest.clearAllMocks();
82
89
  await mongoDb().collection('credentials').deleteMany();
83
90
  await mongoDb().collection('accounts').deleteMany();
84
91
  });
85
92
 
86
- afterAll(async () => {
93
+ after(async () => {
87
94
  nock.restore();
88
95
  await mongoDb().collection('accounts').deleteMany();
89
96
  await fastify.close();
97
+ mock.reset();
90
98
  });
91
99
 
92
100
  describe('POST /issuing/deep-link/accept-offers - accept receive empty credentials by deep link', () => {
@@ -113,10 +121,10 @@ describe('Test Deep Link issuing controller', () => {
113
121
  expect(response.statusCode).toBe(200);
114
122
  expect(response.json).toEqual(mockParsedEmptyResponse);
115
123
 
116
- expect(vclSdk.getCredentialManifest).toBeCalledTimes(0); // important!
124
+ expect(getCredentialManifest.mock.callCount()).toEqual(0); // important!
117
125
 
118
- expect(vclSdk.finalizeOffers).toBeCalledTimes(1);
119
- expect(vclSdk.finalizeOffers).toBeCalledWith(
126
+ expect(finalizeOffers.mock.callCount()).toEqual(1);
127
+ expect(finalizeOffers.mock.calls[0].arguments).toEqual([
120
128
  expect.objectContaining(
121
129
  new VCLFinalizeOffersDescriptor(
122
130
  vclMockCredentialManifest,
@@ -127,8 +135,8 @@ describe('Test Deep Link issuing controller', () => {
127
135
  ),
128
136
  expect.objectContaining({
129
137
  value: mockEmptyOffers.sessionToken.value,
130
- })
131
- );
138
+ }),
139
+ ]);
132
140
 
133
141
  const savedCredential = await mongoDb()
134
142
  .collection('credentials')