@@ -10,8 +10,14 @@ import {
10
10
} from '../..' ;
11
11
import { VirgilCardVerificationError } from '../../Cards/errors' ;
12
12
import { ICard } from '../../Cards/ICard' ;
13
-
13
+ import * as chaiAsPromised from "chai-as-promised" ;
14
14
import { compatData } from './data' ;
15
+ import { use } from "chai" ;
16
+ // @ts -ignore
17
+ import {
18
+ assert ,
19
+ sinon
20
+ } from '../declarations' ;
15
21
16
22
const WELL_KNOWN_IDENTITY = `js_sdk_well_known_identity${ Date . now ( ) } @virgil.com` ;
17
23
let WELL_KNOWN_CARD_ID :string ;
@@ -21,20 +27,20 @@ const init = (identity: string = WELL_KNOWN_IDENTITY) => {
21
27
const accessTokenSigner = new VirgilAccessTokenSigner ( crypto ) ;
22
28
const cardCrypto = new VirgilCardCrypto ( crypto ) ;
23
29
24
- const apiPrivateKey = crypto . importPrivateKey ( process . env . API_KEY_PRIVATE_KEY ! ) ;
30
+ const apiPrivateKey = crypto . importPrivateKey ( process . env . APP_KEY ! ) ;
25
31
26
32
const jwtGenerator = new JwtGenerator ( {
27
33
appId : process . env . APP_ID ! ,
28
34
apiKey : apiPrivateKey ,
29
- apiKeyId : process . env . API_KEY_ID ! ,
35
+ apiKeyId : process . env . APP_KEY_ID ! ,
30
36
accessTokenSigner,
31
37
millisecondsToLive : 20 * 60 * 1000
32
38
} ) ;
33
39
34
40
const expiredTokenGenerator = new JwtGenerator ( {
35
41
appId : process . env . APP_ID ! ,
36
42
apiKey : apiPrivateKey ,
37
- apiKeyId : process . env . API_KEY_ID ! ,
43
+ apiKeyId : process . env . APP_KEY_ID ! ,
38
44
accessTokenSigner,
39
45
millisecondsToLive : 1000
40
46
} ) ;
@@ -59,15 +65,13 @@ const init = (identity: string = WELL_KNOWN_IDENTITY) => {
59
65
} ;
60
66
} ;
61
67
62
- describe ( 'CardManager' , function ( ) {
68
+ describe ( 'CardManager' , async function ( ) {
63
69
64
- this . timeout ( 10000 ) ;
70
+ //this.timeout(10000);
71
+ await initCrypto ( ) ;
65
72
66
- before ( async ( ) => {
67
- await initCrypto ( ) ;
68
- } ) ;
69
-
70
- before ( ( ) => {
73
+ before ( ( ) => {
74
+ use ( chaiAsPromised )
71
75
const { cardManager, crypto, cardVerifier } = init ( ) ;
72
76
const keypair = crypto . generateKeys ( ) ;
73
77
cardVerifier . verifySelfSignature = false ;
@@ -195,10 +199,10 @@ describe('CardManager', function () {
195
199
) ;
196
200
} ) ;
197
201
198
- it ( 'verifies cards after publishing' , ( ) => {
202
+ it ( 'verifies cards after publishing' , async ( ) => {
199
203
const keypair = crypto . generateKeys ( ) ;
200
204
201
- return assert . isRejected (
205
+ return await assert . isRejected (
202
206
cardManager . publishCard ( {
203
207
privateKey : keypair . privateKey ,
204
208
publicKey : keypair . publicKey ,
@@ -208,7 +212,7 @@ describe('CardManager', function () {
208
212
) ;
209
213
} ) ;
210
214
211
- it ( 'verifies cards after publishing as raw model' , ( ) => {
215
+ it ( 'verifies cards after publishing as raw model' , async ( ) => {
212
216
const keypair = crypto . generateKeys ( ) ;
213
217
const rawCard = cardManager . generateRawCard ( {
214
218
privateKey : keypair . privateKey ,
@@ -222,14 +226,14 @@ describe('CardManager', function () {
222
226
) ;
223
227
} ) ;
224
228
225
- it ( 'verifies cards on get' , ( ) => {
229
+ it ( 'verifies cards on get' , async ( ) => {
226
230
return assert . isRejected (
227
231
cardManager . getCard ( WELL_KNOWN_CARD_ID ) ,
228
232
VirgilCardVerificationError
229
233
) ;
230
234
} ) ;
231
235
232
- it ( 'verifies cards on search' , ( ) => {
236
+ it ( 'verifies cards on search' , async ( ) => {
233
237
return assert . isRejected (
234
238
cardManager . searchCards ( WELL_KNOWN_IDENTITY ) ,
235
239
VirgilCardVerificationError
@@ -476,19 +480,19 @@ describe('CardManager', function () {
476
480
. callsFake ( getTokenFn as any ) ;
477
481
} ) ;
478
482
479
- it ( 'retries get card' , ( ) => {
483
+ it ( 'retries get card' , async ( ) => {
480
484
return assert . isFulfilled (
481
485
cardManager . getCard ( WELL_KNOWN_CARD_ID )
482
486
) ;
483
487
} ) ;
484
488
485
- it ( 'retries search cards' , ( ) => {
489
+ it ( 'retries search cards' , async ( ) => {
486
490
return assert . isFulfilled (
487
491
cardManager . searchCards ( WELL_KNOWN_IDENTITY )
488
492
) ;
489
493
} ) ;
490
494
491
- it ( 'retries publish card' , ( ) => {
495
+ it ( 'retries publish card' , async ( ) => {
492
496
const { privateKey, publicKey } = crypto . generateKeys ( ) ;
493
497
return assert . isFulfilled (
494
498
cardManager . publishCard ( {
0 commit comments