diff --git a/packages/@magic-sdk/provider/test/mocks.ts b/packages/@magic-sdk/provider/test/mocks.ts index 66ef3ee8..499e986f 100644 --- a/packages/@magic-sdk/provider/test/mocks.ts +++ b/packages/@magic-sdk/provider/test/mocks.ts @@ -25,8 +25,16 @@ export function restoreSDKEnvironmentConstants() { jest.unmock('../src/core/sdk-environment'); } -export function mockLocalForage(FAKE_STORE: Record = {}) { - jest.spyOn(storage, 'getItem').mockImplementation((key: string) => FAKE_STORE[key]); +export function mockLocalForage(FAKE_STORE: Record = {}) { + jest.spyOn(storage, 'getItem').mockImplementation((key: string, callback?: (err: unknown, value: unknown) => void) => { + const value = FAKE_STORE[key]; + + if (callback) { + callback(null, value); + } + + return Promise.resolve(value); + }); jest.spyOn(storage, 'setItem').mockImplementation(async (key: string, value: any) => { FAKE_STORE[key] = value; }); diff --git a/packages/@magic-sdk/provider/test/spec/core/sdk-exceptions/magic-rpc-error/constructor.spec.ts b/packages/@magic-sdk/provider/test/spec/core/sdk-exceptions/magic-rpc-error/constructor.spec.ts index 8c5970ea..f36f2e0e 100644 --- a/packages/@magic-sdk/provider/test/spec/core/sdk-exceptions/magic-rpc-error/constructor.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/core/sdk-exceptions/magic-rpc-error/constructor.spec.ts @@ -43,8 +43,7 @@ test('Initialize MagicRPCError with `undefined` argument', () => { test('Initialize MagicRPCError with unknown error code argument', () => { const err = new MagicRPCError({ - // @ts-ignore - code: 1, + code: -32603, message: 'hello world', data: exampleData, }); diff --git a/packages/@magic-sdk/provider/test/spec/core/view-controller/post.spec.ts b/packages/@magic-sdk/provider/test/spec/core/view-controller/post.spec.ts index 9f0e4fcd..51244a23 100644 --- a/packages/@magic-sdk/provider/test/spec/core/view-controller/post.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/core/view-controller/post.spec.ts @@ -68,7 +68,7 @@ const FAKE_JWT_TOKEN = 'hot tokens'; const FAKE_DEVICE_SHARE = 'fake device share'; const FAKE_RT = 'will freshen'; const FAKE_INJECTED_JWT = 'fake injected jwt'; -let FAKE_STORE: Record = {}; +let FAKE_STORE: Record = {}; let viewController: TestViewController; @@ -78,9 +78,17 @@ beforeEach(() => { createJwtStub = jest.spyOn(webCryptoUtils, 'createJwt'); getDecryptedDeviceShareStub = jest.spyOn(deviceShareWebCryptoUtils, 'getDecryptedDeviceShare'); clearDeviceSharesStub = jest.spyOn(deviceShareWebCryptoUtils, 'clearDeviceShares'); - jest.spyOn(global.console, 'info').mockImplementation(() => {}); + jest.spyOn(global.console, 'info').mockImplementation(() => { }); jest.spyOn(global, 'addEventListener').mockImplementation(jest.fn()); - jest.spyOn(storage, 'getItem').mockImplementation((key: string) => FAKE_STORE[key]); + jest.spyOn(storage, 'getItem').mockImplementation((key: string, callback?: (err: unknown, value: unknown) => void) => { + const value = FAKE_STORE[key]; + + if (callback) { + callback(null, value); + } + + return Promise.resolve(value); + }); jest.spyOn(storage, 'setItem').mockImplementation(async (key: string, value: any) => { FAKE_STORE[key] = value; }); @@ -205,7 +213,7 @@ test('Sends payload without rt if no jwt can be made', async () => { }); test('Sends payload when web crypto jwt fails', async () => { - const consoleErrorStub = jest.spyOn(global.console, 'error').mockImplementationOnce(() => {}); + const consoleErrorStub = jest.spyOn(global.console, 'error').mockImplementationOnce(() => { }); createJwtStub.mockRejectedValueOnce('danger'); FAKE_STORE.rt = FAKE_RT; diff --git a/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithCredential.spec.ts b/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithCredential.spec.ts index 8131c6c6..608c68e4 100644 --- a/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithCredential.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithCredential.spec.ts @@ -24,7 +24,7 @@ test('If no parameters are given & platform target is "web", URL search string a const magic = createMagicSDK({ platform: 'web' }); magic.auth.request = jest.fn(); - jest.spyOn(window.history, 'replaceState').mockImplementation(() => { }); + jest.spyOn(window.history, 'replaceState').mockImplementation(() => { /* noop */ }); jest.spyOn(window, 'location', 'get').mockReturnValue({ search: '?magic_credential=asdf', diff --git a/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithEmailOTPWhitelabel.spec.ts b/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithEmailOTPWhitelabel.spec.ts index 5f169558..59de4a27 100644 --- a/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithEmailOTPWhitelabel.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithEmailOTPWhitelabel.spec.ts @@ -9,7 +9,7 @@ const expectedEmail = 'john.doe@mail.com'; test('Generates JSON RPC pending for otp-input-sent', async () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -29,7 +29,7 @@ test('Generates JSON RPC pending for otp-input-sent', async () => { test('Generates JSON RPC pending for verify-mfa-code', () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -49,7 +49,7 @@ test('Generates JSON RPC pending for verify-mfa-code', () => { test('Generates JSON RPC pending for lost-device', () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -67,7 +67,7 @@ test('Generates JSON RPC pending for lost-device', () => { test('Generates JSON RPC pending for verify-recovery-code', () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); diff --git a/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithSmsWhitelabel.spec.ts b/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithSmsWhitelabel.spec.ts index fb228337..718f3a74 100644 --- a/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithSmsWhitelabel.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/modules/auth/loginWithSmsWhitelabel.spec.ts @@ -13,7 +13,7 @@ const expectedPhoneNumber = 'hey hey I am a number but jk'; test('Generates JSON RPC request payload with `phone` parameter', async () => { const magic = createMagicSDK(); magic.auth.request = jest.fn(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); await magic.auth.loginWithSMS({ phoneNumber: expectedPhoneNumber, showUI: false }); @@ -25,7 +25,7 @@ test('Generates JSON RPC request payload with `phone` parameter', async () => { test('If `testMode` is enabled, testing-specific RPC method is used', async () => { const magic = createMagicSDKTestMode(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); magic.auth.request = jest.fn(); await magic.auth.loginWithSMS({ phoneNumber: expectedPhoneNumber, showUI: false }); @@ -39,7 +39,7 @@ test('If `testMode` is enabled, testing-specific RPC method is used', async () = test('Generates JSON RPC pending for otp-input-sent', () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -59,7 +59,7 @@ test('Generates JSON RPC pending for otp-input-sent', () => { test('method should return a PromiEvent', () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); expect(isPromiEvent(magic.auth.loginWithSMS({ email: 'blag' }))).toBeTruthy(); }); diff --git a/packages/@magic-sdk/provider/test/spec/modules/auth/updateEmailWithUI.whitelabel.spec.ts b/packages/@magic-sdk/provider/test/spec/modules/auth/updateEmailWithUI.whitelabel.spec.ts index e8e7af21..1b86dd0c 100644 --- a/packages/@magic-sdk/provider/test/spec/modules/auth/updateEmailWithUI.whitelabel.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/modules/auth/updateEmailWithUI.whitelabel.spec.ts @@ -7,7 +7,7 @@ beforeEach(() => { test('Generate JSON RPC request payload with method `magic_auth_update_email` whitelabel and start recency check', async () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -27,7 +27,7 @@ test('Generate JSON RPC request payload with method `magic_auth_update_email` wh test('Whitelabel `magic_auth_update_email`, recency check Retry event', async () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -41,7 +41,7 @@ test('Whitelabel `magic_auth_update_email`, recency check Retry event', async () test('Whitelabel `magic_auth_update_email`, Update Email, fire retry with Email event', async () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -58,7 +58,7 @@ test('Whitelabel `magic_auth_update_email`, Update Email, fire retry with Email test('Generate JSON RPC request payload with method `magic_auth_update_email` whitelabel and start verify Email otp ', async () => { const magic = createMagicSDK(); - magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.auth.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.auth.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); diff --git a/packages/@magic-sdk/provider/test/spec/modules/base-module/request.spec.ts b/packages/@magic-sdk/provider/test/spec/modules/base-module/request.spec.ts index e13207b1..1c02d7e4 100644 --- a/packages/@magic-sdk/provider/test/spec/modules/base-module/request.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/modules/base-module/request.spec.ts @@ -30,7 +30,7 @@ const requestPayload: JsonRpcRequestPayload = { beforeEach(() => { jest.restoreAllMocks(); // Silence the "duplicate iframes" warning. - jest.spyOn(console, 'warn').mockImplementation(() => {}); + jest.spyOn(console, 'warn').mockImplementation(() => { /* noop */ }); }); test('Resolves with a successful response', async () => { @@ -113,7 +113,7 @@ test('Receive no further events after the response from `ViewController` resolve const request = baseModule .request(requestPayload) - .on('hello_b', (result:string) => { + .on('hello_b', (result: string) => { expect(result).toBe('world'); }) .on('hello_b2', () => { @@ -159,7 +159,7 @@ test('Falls back to empty array if `params` is missing from event', done => { ), ); - baseModule.request(requestPayload).on('hello_c', (...args:[]) => { + baseModule.request(requestPayload).on('hello_c', (...args: []) => { expect(args).toEqual([]); done(); }); diff --git a/packages/@magic-sdk/provider/test/spec/modules/user/recoverAccount.spec.ts b/packages/@magic-sdk/provider/test/spec/modules/user/recoverAccount.spec.ts index 82ac7d0a..899cebc2 100644 --- a/packages/@magic-sdk/provider/test/spec/modules/user/recoverAccount.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/modules/user/recoverAccount.spec.ts @@ -36,7 +36,7 @@ test('method should return a PromiEvent', () => { test('method should create intermediary event on cancel', () => { const magic = createMagicSDK(); - magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.user.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -50,7 +50,7 @@ test('method should create intermediary event on cancel', () => { test('method should create intermediary event on ResendSms', () => { const magic = createMagicSDK(); - magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.user.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -64,7 +64,7 @@ test('method should create intermediary event on ResendSms', () => { test('method should create intermediary event on VerifyOtp', () => { const magic = createMagicSDK(); - magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.user.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -78,7 +78,7 @@ test('method should create intermediary event on VerifyOtp', () => { test('method should create intermediary event on UpdateEmail', () => { const magic = createMagicSDK(); - magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.user.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -92,7 +92,7 @@ test('method should create intermediary event on UpdateEmail', () => { test('method should create intermediary event on UpdateEmailEventEmit.Cancel', () => { const magic = createMagicSDK(); - magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.user.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -106,7 +106,7 @@ test('method should create intermediary event on UpdateEmailEventEmit.Cancel', ( test('method should create intermediary event on RetryWithNewEmail', () => { const magic = createMagicSDK(); - magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.user.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); @@ -120,7 +120,7 @@ test('method should create intermediary event on RetryWithNewEmail', () => { test('method should create intermediary event on VerifyEmailOtp', () => { const magic = createMagicSDK(); - magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => {})); + magic.user.overlay.post = jest.fn().mockImplementation(() => new Promise(() => { /* noop */ })); const createIntermediaryEventFn = jest.fn(); magic.user.createIntermediaryEvent = jest.fn().mockImplementation(() => createIntermediaryEventFn); diff --git a/packages/@magic-sdk/provider/test/spec/util/device-share-web-crypto.spec.ts b/packages/@magic-sdk/provider/test/spec/util/device-share-web-crypto.spec.ts index 2d24b120..7cf08d6b 100644 --- a/packages/@magic-sdk/provider/test/spec/util/device-share-web-crypto.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/util/device-share-web-crypto.spec.ts @@ -10,7 +10,7 @@ import { getDecryptedDeviceShare, } from '../../../src/util/device-share-web-crypto'; -let FAKE_STORE: Record = {}; +let FAKE_STORE: Record = {}; const FAKE_NETWORK_HASH = 'network_hash'; const FAKE_PLAINTEXT_SHARE = `AQICAHg1y7j1UY7sfTib6h9cN2Kh7v0WhCRwQxEPhGAQ2m5OgQGrJvUP6MKiuj9yD96y6B4eAAABPzCCATsGCSqGSIb3DQEHBqCCASwwggEoAgEAMIIBIQYJKoZIhvcNAQcBMB4GCWCGSAFlAwQBLjARBAy6tbGg/6//2IJs9xUCARCAgfOY3knm1i2kGjLXQFoqEjOeLr/UGwHQ+AW1y20UoCX3ght68egu06Hg54JF/mCGgSDt7R7dFSOuGvapE9OEyFYz4f1+tpWb5PPaLReBRTTTfw/8Xgsfzl6iXACsLKqyXEeWci+/vOWDLqu73E0uy5StyN5InZLwHCJe4l+KMEr5C7JZvobQh4NVBT5SqgQXmLGXGGH/2ydkq8zkgVGDT9jQlqqpUH83UMFQwHSwbJRRyYLxBwQKTO0AODfqk5OnWRA+BoDC8HMFyQUb4nS+BgDlgTgL7Kg/H/Echr+SlQKJdWJnvf3BjSBwO8z5kVpxRo5xwG4=`; diff --git a/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromiEvent.spec.ts b/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromiEvent.spec.ts index 804d2048..440a6db6 100644 --- a/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromiEvent.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromiEvent.spec.ts @@ -1,4 +1,4 @@ -import { createPromiEvent } from '../../../../src/util/promise-tools'; +import { createPromiEvent, PromiEvent } from '../../../../src/util/promise-tools'; import { TypedEmitter } from '../../../../src/util/events'; type DefaultEvents = { @@ -19,50 +19,50 @@ beforeEach(() => { }); test('Creates a native `Promise`', () => { - const p = createPromiEvent(resolve => resolve(true)); + const promiEvent = createPromiEvent(resolve => resolve(true)); - expect(p instanceof Promise).toBe(true); + expect(promiEvent instanceof Promise).toBe(true); }); test('Attaches `TypedEmitter` methods to the initial value', () => { - const p = createPromiEvent(resolve => resolve(true)); + const promiEvent = createPromiEvent(resolve => resolve(true)); typedEmitterMethods.forEach(method => { - expect(typeof p[method as keyof typeof p] === 'function').toBe(true); + expect(typeof promiEvent[method as keyof typeof promiEvent] === 'function').toBe(true); }); }); test('Attaches `TypedEmitter` methods to `Promise.then` result', () => { - const p = createPromiEvent(resolve => resolve(true)).then(); + const promiEvent = createPromiEvent(resolve => resolve(true)).then(); typedEmitterMethods.forEach(method => { - expect(typeof p[method as keyof typeof p] === 'function').toBe(true); + expect(typeof promiEvent[method as keyof typeof promiEvent] === 'function').toBe(true); }); }); test('Attaches `TypedEmitter` methods to `Promise.catch` result', () => { - const p = createPromiEvent(resolve => resolve(true)).catch(); + const promiEvent = createPromiEvent(resolve => resolve(true)).catch(); typedEmitterMethods.forEach(method => { - expect(typeof p[method as keyof typeof p] === 'function').toBe(true); + expect(typeof promiEvent[method as keyof typeof promiEvent] === 'function').toBe(true); }); }); test('Attaches `TypedEmitter` methods to `Promise.finally` result', () => { - const p = createPromiEvent(resolve => resolve(true)).catch(); + const promiEvent = createPromiEvent(resolve => resolve(true)).catch(); typedEmitterMethods.forEach(method => { - expect(typeof p[method as keyof typeof p] === 'function').toBe(true); + expect(typeof promiEvent[method as keyof typeof promiEvent] === 'function').toBe(true); }); }); test('Attaches `Promise` methods to `TypedEmitter` results', () => { chainingEmitterMethods.forEach(emitterMethod => { const emitterStub = jest.spyOn(TypedEmitter.prototype, emitterMethod as any).mockImplementation(); - const p = createPromiEvent(resolve => resolve(true))[emitterMethod]('done', () => {}); + const promiEvent = createPromiEvent(resolve => resolve(true))[emitterMethod]('done', () => { /* noop */ }); promiseMethods.forEach(promiseMethod => { - expect(typeof (p as Record)[promiseMethod] === 'function').toBe(true); + expect(typeof promiEvent[promiseMethod as keyof typeof promiEvent] === 'function').toBe(true); }); emitterStub.mockReset(); @@ -89,7 +89,9 @@ test('Emits "error" event upon Promise reject', done => { expect(err).toBe('goodbye' as any); done(); }) - .catch(() => { }); + .catch(() => { + /* noop */ + }); }); test('Emits "settled" event upon Promise reject', done => { @@ -97,5 +99,7 @@ test('Emits "settled" event upon Promise reject', done => { .on('settled', () => { done(); }) - .catch(() => { }); + .catch(() => { + /* noop */ + }); }); diff --git a/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromise.spec.ts b/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromise.spec.ts index b443447f..64f22405 100644 --- a/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromise.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/util/promise-tools/createPromise.spec.ts @@ -5,9 +5,9 @@ beforeEach(() => { }); test('Creates a native `Promise`', () => { - const p = createPromise(resolve => resolve(true)); + const promiEvent = createPromise(resolve => resolve(true)); - expect(p instanceof Promise).toBe(true); + expect(promiEvent instanceof Promise).toBe(true); }); test('Resolves the `Promise`', done => { diff --git a/packages/@magic-sdk/provider/test/spec/util/promise-tools/isPromiEvent.spec.ts b/packages/@magic-sdk/provider/test/spec/util/promise-tools/isPromiEvent.spec.ts index 68736ed4..d90d08d7 100644 --- a/packages/@magic-sdk/provider/test/spec/util/promise-tools/isPromiEvent.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/util/promise-tools/isPromiEvent.spec.ts @@ -5,13 +5,13 @@ beforeEach(() => { }); test('Returns `true` for valid `PromiEvent` object', () => { - const p = createPromiEvent(resolve => resolve(true)); + const promiEvent = createPromiEvent(resolve => resolve(true)); - expect(isPromiEvent(p)).toBe(true); + expect(isPromiEvent(promiEvent)).toBe(true); }); test('Returns `false` for invalid `PromiEvent` object', () => { - const p = {}; + const promiEvent = {}; - expect(isPromiEvent(p)).toBe(false); + expect(isPromiEvent(promiEvent)).toBe(false); }); diff --git a/packages/@magic-sdk/provider/test/spec/util/web-crypto.spec.ts b/packages/@magic-sdk/provider/test/spec/util/web-crypto.spec.ts index 4ee8ff20..171870c4 100644 --- a/packages/@magic-sdk/provider/test/spec/util/web-crypto.spec.ts +++ b/packages/@magic-sdk/provider/test/spec/util/web-crypto.spec.ts @@ -3,7 +3,7 @@ import * as storage from '../../../src/util/storage'; import { clearKeys, createJwt, STORE_KEY_PRIVATE_KEY, STORE_KEY_PUBLIC_JWK } from '../../../src/util/web-crypto'; import { TextEncoder } from 'util'; -let FAKE_STORE: Record = {}; +let FAKE_STORE: Record = {}; beforeAll(() => { jest.spyOn(storage, 'getItem').mockImplementation(async (key: string) => FAKE_STORE[key]); @@ -62,7 +62,7 @@ test('should store public and private keys after creating JWT', async () => { test('private key should be non exportable', async () => { await createJwt(); - const privateKey = FAKE_STORE[STORE_KEY_PRIVATE_KEY]; + const privateKey = FAKE_STORE[STORE_KEY_PRIVATE_KEY] as CryptoKey; expect(() => crypto.subtle.exportKey('jwk', privateKey)).rejects.toThrow(); });