From 5f3597d6ed398b65f0d156ee3f6a364677e9acf7 Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Wed, 24 Aug 2022 12:00:55 +0700 Subject: [PATCH 1/2] feat(jest): update describe on tests --- .../BlockchainClient/BlockchainClient.test.ts | 2 +- libraries/Crypto/Crypto.test.ts | 2 +- .../UsersProgram/UsersProgram.types.test.ts | 2 +- store/meta/mutations.test.ts | 2 +- utilities/EXIF.test.ts | 4 +-- utilities/Messaging.test.ts | 30 +++++++++---------- utilities/Thumbnail.test.ts | 2 +- .../__snapshots__/Messaging.test.ts.snap | 16 +++++----- .../__snapshots__/Thumbnail.test.ts.snap | 2 +- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/libraries/BlockchainClient/BlockchainClient.test.ts b/libraries/BlockchainClient/BlockchainClient.test.ts index 16b603414a..4628c05b5c 100644 --- a/libraries/BlockchainClient/BlockchainClient.test.ts +++ b/libraries/BlockchainClient/BlockchainClient.test.ts @@ -1,6 +1,6 @@ import BlockchainClient from './BlockchainClient' -describe('', () => { +describe('Test BlockchainClient', () => { test('get account but it is uninitialized', () => { const $BlockchainClient: BlockchainClient = BlockchainClient.getInstance() try { diff --git a/libraries/Crypto/Crypto.test.ts b/libraries/Crypto/Crypto.test.ts index 4e39c17647..0d75b487d9 100644 --- a/libraries/Crypto/Crypto.test.ts +++ b/libraries/Crypto/Crypto.test.ts @@ -1,7 +1,7 @@ import { Keypair } from '@solana/web3.js' import Crypto from './Crypto' -describe('', () => { +describe('Test crypto', () => { test('Initialize Crypto', () => { const exampleKeypair = Keypair.generate() const konstruktor = new Crypto() diff --git a/libraries/Solana/UsersProgram/UsersProgram.types.test.ts b/libraries/Solana/UsersProgram/UsersProgram.types.test.ts index 710088ca35..14123b6483 100644 --- a/libraries/Solana/UsersProgram/UsersProgram.types.test.ts +++ b/libraries/Solana/UsersProgram/UsersProgram.types.test.ts @@ -1,6 +1,6 @@ import { IDL } from '~/libraries/Solana/UsersProgram/UsersProgram.types' -describe('', () => { +describe('Test UsersProgram types', () => { test('check IDL export type', () => { expect(IDL).toEqual({ version: '0.1.0', diff --git a/store/meta/mutations.test.ts b/store/meta/mutations.test.ts index 3dd8e759d9..29ea7c901a 100644 --- a/store/meta/mutations.test.ts +++ b/store/meta/mutations.test.ts @@ -1,7 +1,7 @@ import { MetaState } from './types' import * as meta from '~/store/meta/mutations' -describe('', () => { +describe('Test meta mutations', () => { let inst: any const state: MetaState = { title: 'empty title', diff --git a/utilities/EXIF.test.ts b/utilities/EXIF.test.ts index 3aa338ebae..434ea35ce1 100644 --- a/utilities/EXIF.test.ts +++ b/utilities/EXIF.test.ts @@ -1,7 +1,7 @@ import * as exif from './EXIF' -describe('', () => { - test('file is jpeg', async () => { +describe('Tests exif', () => { + test('given file is jpeg', async () => { const jpegBlob = new Blob(['testing'], { type: 'image/jpeg' }) // const file2 = new Fil({ ...mockFileData, name: 'testPng2.png' }) diff --git a/utilities/Messaging.test.ts b/utilities/Messaging.test.ts index 53e053e83a..cb01930b4f 100644 --- a/utilities/Messaging.test.ts +++ b/utilities/Messaging.test.ts @@ -142,8 +142,8 @@ const initialRootState: any = { }, } -describe('', () => { - test('getFullUserInfoFromState with identical textile public key', () => { +describe('Test Messaging', () => { + it('calls getFullUserInfoFromState with identical textile public key', () => { const rootStateForTest = { ...initialRootState } const publicKeyForTest = 'publickey1' rootStateForTest.accounts.details.textilePubkey = publicKeyForTest @@ -156,7 +156,7 @@ describe('', () => { expect(result).toBe(rootStateForTest.accounts.details) }) - test('getFullUserInfoFromState with non-identical textile public key', () => { + it('calls getFullUserInfoFromState with non-identical textile public key', () => { const rootStateForTest = { ...initialRootState } const publicKeyForTest = 'https://accounts.google.com/o/oauth2/revoke?token=%s' @@ -194,7 +194,7 @@ describe('', () => { }) }) - test('getUsernameFromState with unknown textile public key', () => { + it('calls getUsernameFromState with unknown textile public key', () => { const rootStateForTest = { ...initialRootState } const publicKeyForTest = 'publickey1' rootStateForTest.accounts.details.textilePubkey = publicKeyForTest @@ -207,7 +207,7 @@ describe('', () => { expect(result).toBe(PropCommonEnum.UNKNOWN) }) - test('getAddressFromState with unknown textile public key', () => { + it('calls getAddressFromState with unknown textile public key', () => { const rootStateForTest = { ...initialRootState } const publicKeyForTest = 'publickey1' rootStateForTest.accounts.details.textilePubkey = publicKeyForTest @@ -220,7 +220,7 @@ describe('', () => { expect(result).toBe(PropCommonEnum.UNKNOWN) }) - test('refreshTimeStampInterval', () => { + it('calls refreshTimeStampInterval', () => { jest.useFakeTimers() const action = jest.fn() const result1 = Messaging.refreshTimestampInterval(123, action, 3000) @@ -229,7 +229,7 @@ describe('', () => { expect(result2).toBe(1000000000001) }) - test('replyMessageToUIReply', () => { + it('calls replyMessageToUIReply', () => { const result: UIReply = Messaging.exportedForTesting.replyMessageToUIReply( [ { @@ -256,7 +256,7 @@ describe('', () => { expect(result).toMatchSnapshot() }) - test('messageRepliesToUIReplies', () => { + it('calls messageRepliesToUIReplies', () => { const result = Messaging.exportedForTesting.messageRepliesToUIReplies( [ { @@ -292,7 +292,7 @@ describe('', () => { expect(result).toMatchSnapshot() }) - test('groupMessages', () => { + it('calls groupMessages', () => { const message1 = `message1` const message2 = `message2` const reaction1 = `reaction1` @@ -336,7 +336,7 @@ describe('', () => { }) describe('update message tracker', () => { - test('updateMessageTracker glyph', () => { + it('calls updateMessageTracker glyph', () => { const newMessages = [ { replyMessage: 'text0', @@ -360,7 +360,7 @@ describe('update message tracker', () => { expect(result).toMatchSnapshot() }) - test('updateMessageTracker text', () => { + it('calls updateMessageTracker text', () => { const newMessages = [ { replyMessage: 'text0', @@ -384,7 +384,7 @@ describe('update message tracker', () => { expect(result).toMatchSnapshot() }) - test('updateMessageTracker file', () => { + it('calls updateMessageTracker file', () => { const newMessages = [ { replyMessage: 'text0', @@ -408,7 +408,7 @@ describe('update message tracker', () => { expect(result).toMatchSnapshot() }) - test('updateMessageTracker reaction', () => { + it('calls updateMessageTracker reaction', () => { const newMessages = [ { replyMessage: 'text0', @@ -432,7 +432,7 @@ describe('update message tracker', () => { expect(result).toMatchSnapshot() }) - test('updateMessageTracker reply', () => { + it('calls updateMessageTracker reply', () => { const newMessages = [ { replyMessage: 'text0', @@ -456,7 +456,7 @@ describe('update message tracker', () => { expect(result).toMatchSnapshot() }) - test('convertTimestampToDate', () => { + it('calls convertTimestampToDate', () => { const localTimestamp = dateNow const result = Messaging.convertTimestampToDate( { diff --git a/utilities/Thumbnail.test.ts b/utilities/Thumbnail.test.ts index 39846733fb..1865604664 100644 --- a/utilities/Thumbnail.test.ts +++ b/utilities/Thumbnail.test.ts @@ -3,7 +3,7 @@ import * as Thumbnail from './Thumbnail' const ThumbnailDefault = Thumbnail.default -describe('', () => { +describe('Test thumbnail', () => { test('txt thumbnail', async () => { const testFile = new File(['hello'], 'test_fil.txt', { type: 'text/plain', diff --git a/utilities/__snapshots__/Messaging.test.ts.snap b/utilities/__snapshots__/Messaging.test.ts.snap index 98682d745b..53e9d1e8ee 100644 --- a/utilities/__snapshots__/Messaging.test.ts.snap +++ b/utilities/__snapshots__/Messaging.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` messageRepliesToUIReplies 1`] = ` +exports[`Test Messaging calls messageRepliesToUIReplies 1`] = ` Array [ Object { "fileMessage": "", @@ -25,7 +25,7 @@ Array [ ] `; -exports[` replyMessageToUIReply 1`] = ` +exports[`Test Messaging calls replyMessageToUIReply 1`] = ` Object { "0": Object { "fileMessage": "", @@ -55,9 +55,9 @@ Object { } `; -exports[`update message tracker convertTimestampToDate 1`] = `"L"`; +exports[`update message tracker calls convertTimestampToDate 1`] = `"L"`; -exports[`update message tracker updateMessageTracker file 1`] = ` +exports[`update message tracker calls updateMessageTracker file 1`] = ` Object { "messages": Object { "undefined": Object { @@ -75,7 +75,7 @@ Object { } `; -exports[`update message tracker updateMessageTracker glyph 1`] = ` +exports[`update message tracker calls updateMessageTracker glyph 1`] = ` Object { "messages": Object { "undefined": Object { @@ -93,7 +93,7 @@ Object { } `; -exports[`update message tracker updateMessageTracker reaction 1`] = ` +exports[`update message tracker calls updateMessageTracker reaction 1`] = ` Object { "messages": Object {}, "reactions": Object { @@ -113,7 +113,7 @@ Object { } `; -exports[`update message tracker updateMessageTracker reply 1`] = ` +exports[`update message tracker calls updateMessageTracker reply 1`] = ` Object { "messages": Object {}, "reactions": Object {}, @@ -133,7 +133,7 @@ Object { } `; -exports[`update message tracker updateMessageTracker text 1`] = ` +exports[`update message tracker calls updateMessageTracker text 1`] = ` Object { "messages": Object { "undefined": Object { diff --git a/utilities/__snapshots__/Thumbnail.test.ts.snap b/utilities/__snapshots__/Thumbnail.test.ts.snap index 41bc200dc0..7c447971be 100644 --- a/utilities/__snapshots__/Thumbnail.test.ts.snap +++ b/utilities/__snapshots__/Thumbnail.test.ts.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` txt thumbnail 1`] = `undefined`; +exports[`Test thumbnail txt thumbnail 1`] = `undefined`; From 09ef35a48a4c76675aa8330f30406be8fc643e4e Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Wed, 24 Aug 2022 22:53:34 +0700 Subject: [PATCH 2/2] feat(jest): write better description of test suite --- libraries/Iridium/IdentityManager.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Iridium/IdentityManager.test.ts b/libraries/Iridium/IdentityManager.test.ts index 6d592e64f7..6614a2a1ab 100644 --- a/libraries/Iridium/IdentityManager.test.ts +++ b/libraries/Iridium/IdentityManager.test.ts @@ -51,7 +51,7 @@ describe('Test seedFromWallet', () => { }) describe('Test seedFromPrivateKey', () => { - it('should return an error: Incorrect signature hash size', async () => { + it('throws on invalid private key length', async () => { const localParam = { passphrase: 'string', privateKey: new Uint8Array(