From 5bcadf8611bdc0a442b10679d764fb976167bf69 Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Mon, 19 Sep 2022 12:34:00 +0700 Subject: [PATCH] feat(jest): increase coverage on store/accounts & util --- store/accounts/mutations.test.ts | 18 +++++++++++++++++- utilities/animation.test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 utilities/animation.test.ts diff --git a/store/accounts/mutations.test.ts b/store/accounts/mutations.test.ts index 92d48b027d..2129b7c9d2 100644 --- a/store/accounts/mutations.test.ts +++ b/store/accounts/mutations.test.ts @@ -3,7 +3,7 @@ import InitialAccountsState from './state' import mutations from './mutations' import { User } from 'libraries/Iridium/users/types' -describe('init', () => { +describe('Test accounts/mutations', () => { let instance: any let localStateForUnitTest: AccountsState @@ -249,4 +249,20 @@ describe('init', () => { photoHash: newPhotoHash, }) }) + + it('should setNewAccount to true', () => { + const argument = true + + instance.setNewAccount(localStateForUnitTest, argument) + + expect(localStateForUnitTest.isNewAccount).toBeTruthy() + }) + + it('should setNewAccount to false', () => { + const argument = false + + instance.setNewAccount(localStateForUnitTest, argument) + + expect(localStateForUnitTest.isNewAccount).toBeFalsy() + }) }) diff --git a/utilities/animation.test.ts b/utilities/animation.test.ts new file mode 100644 index 0000000000..657ab8e6ae --- /dev/null +++ b/utilities/animation.test.ts @@ -0,0 +1,26 @@ +import { easeOutBack, lerp } from '~/utilities/animation' + +describe('Test utilities/animation', () => { + it('should return expected value for easeOutBack', () => { + const argument = 42 + const result = easeOutBack(argument) + + const expectedValue = + 1 + + (1.2 + 1) * Math.pow(argument - 1, 5) + + 1.2 * Math.pow(argument - 1, 4) + + expect(result).toEqual(expectedValue) + }) + + it('should return expected value for lerp', () => { + const argumentX = 22 + const argumentY = 32 + const argumentA = 42 + const result = lerp(argumentX, argumentY, argumentA) + + const expectedValue = argumentX * (1 - argumentA) + argumentY * argumentA + + expect(result).toEqual(expectedValue) + }) +})