From 70baeaf3f09d3ab2939d82c53213a60dfcafe0da Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Mon, 25 Apr 2022 14:33:53 +0700 Subject: [PATCH 1/2] feat(jest): 100% coverage for store/ui/mutations --- store/ui/__snapshots__/mutations.test.ts.snap | 91 +++++++++++++++++++ store/ui/mutations.test.ts | 48 +++++----- 2 files changed, 115 insertions(+), 24 deletions(-) diff --git a/store/ui/__snapshots__/mutations.test.ts.snap b/store/ui/__snapshots__/mutations.test.ts.snap index 4e68f5a874..45d7180f15 100644 --- a/store/ui/__snapshots__/mutations.test.ts.snap +++ b/store/ui/__snapshots__/mutations.test.ts.snap @@ -28,6 +28,97 @@ Object { } `; +exports[`mutations updateMostUsedGlyph with existing emoji 1`] = ` +Array [ + Object { + "count": 1, + "pack": Object { + "artist": "Dina Brodsky", + "description": "Short description can go here. Lorem ipsum.", + "id": "0903", + "name": "Birds", + "stickerURLs": Array [ + "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/hawk.webp", + "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/ducklings.webp", + "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/owl.webp", + "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/penguins.webp", + "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/robin.webp", + "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/stork.webp", + "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/yellow_bird.webp", + ], + }, + "url": "https://satellite.mypinata.cloud/ipfs/QmXrmiCxkyfpsAY18qzVBPv9TpCbTUToowQEsYy1Pm5C9b/$1/ducklings.webp", + }, + Object { + "count": 1, + "pack": Object { + "artist": "John Treanor", + "description": "Short description can go here. Lorem ipsum.", + "id": "0123", + "name": "Astrobunny", + "stickerURLs": Array [ + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/AHH.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/AHHcloseup.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Coy_02.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Cry.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Cry2.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Laugh.webp", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Luv.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Luv_02.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Sad3.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/ThumbsDownNew.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/ThumbsUP.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/ThumbsUPNew.gif", + ], + }, + "url": "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Coy_02.gif", + }, + Object { + "count": 1, + "pack": Object { + "artist": "John Treanor", + "description": "Short description can go here. Lorem ipsum.", + "id": "0123", + "name": "Astrobunny", + "stickerURLs": Array [ + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/AHH.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/AHHcloseup.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Coy_02.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Cry.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Cry2.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Laugh.webp", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Luv.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Luv_02.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/Sad3.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/ThumbsDownNew.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/ThumbsUP.gif", + "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/ThumbsUPNew.gif", + ], + }, + "url": "https://satellite.mypinata.cloud/ipfs/QmaBFFeJksvrfEhwbKYkzbgm7bKFWzHhRECqGxgB52LeHg/$1/ThumbsUP.gif", + }, + Object { + "count": 1, + "pack": Object { + "artist": "Dina Brodsky", + "description": "Short description can go here. Lorem ipsum.", + "id": "0903", + "name": "Birds", + "stickerURLs": Array [ + "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/hawk.webp", + "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/ducklings.webp", + "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/owl.webp", + "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/penguins.webp", + "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/robin.webp", + "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/stork.webp", + "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/yellow_bird.webp", + ], + }, + "url": "https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/ducklings.webp", + }, +] +`; + exports[`mutations.default.addReaction 0 1`] = `undefined`; exports[`mutations.default.addReaction 1 1`] = `undefined`; diff --git a/store/ui/mutations.test.ts b/store/ui/mutations.test.ts index d623621233..42006b9db4 100644 --- a/store/ui/mutations.test.ts +++ b/store/ui/mutations.test.ts @@ -3895,30 +3895,30 @@ describe('mutations', () => { count: 1, // This emoji has been not been used in the past, by sending this message (via this unit): we've incremented this to 1 from 0. }) }) - // test('updateMostUsedGlyph with existing emoji', () => { - // const localizedState = { ...initialState } - // const object = { - // pack: { - // name: 'Birds', - // description: 'Short description can go here. Lorem ipsum.', - // artist: 'Dina Brodsky', - // id: '0903', - // stickerURLs: [ - // 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/hawk.webp', - // 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/ducklings.webp', - // 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/owl.webp', - // 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/penguins.webp', - // 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/robin.webp', - // 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/stork.webp', - // 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/yellow_bird.webp', - // ], - // }, - // url: 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/ducklings.webp', - // count: 2, // Since this glyph has been used before, it will be incremented from 1 to 2. - // } - // mutations.default.updateRecentGlyphs(localizedState, object) - // expect(localizedState.recentGlyphs).toContainEqual(object) - // }) + test('updateMostUsedGlyph with existing emoji', () => { + const localizedState = { ...initialState } + const object = { + pack: { + name: 'Birds', + description: 'Short description can go here. Lorem ipsum.', + artist: 'Dina Brodsky', + id: '0903', + stickerURLs: [ + 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/hawk.webp', + 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/ducklings.webp', + 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/owl.webp', + 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/penguins.webp', + 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/robin.webp', + 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/stork.webp', + 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/yellow_bird.webp', + ], + }, + url: 'https://satellite.mypinata.cloud/ipfs/QmS1NEujgAT8iogdK3jsQzDf751U6LCSpCNojg1JJhs3zz/$1/ducklings.webp', + count: 2, // Since this glyph has been used before, it will be incremented from 1 to 2. + } + mutations.default.updateRecentGlyphs(localizedState, object) + expect(localizedState.recentGlyphs).toMatchSnapshot() + }) test('updateMostUsedGlyph with new emoji', () => { const localizedState = { ...initialState } const object = { From 16f257474b660b321df8e06200f2706bc39f56cb Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Mon, 25 Apr 2022 14:42:40 +0700 Subject: [PATCH 2/2] feat(jest): 78% coverage for store/ui/mutations --- store/ui/mutations.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/store/ui/mutations.test.ts b/store/ui/mutations.test.ts index 42006b9db4..99d8e8dd14 100644 --- a/store/ui/mutations.test.ts +++ b/store/ui/mutations.test.ts @@ -4072,4 +4072,9 @@ describe('mutations', () => { mutations.default.setFileSort(localizedState, argument) expect(localizedState.fileSort).toBe(argument) }) + test('setFilesUploadStatus', () => { + const localizedState = { ...initialState } + mutations.default.setFilesUploadStatus(localizedState, 'process') + expect(localizedState.filesUploadStatus).toBe('process') + }) })