Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jest): increase coverage on store/accounts & utilities #4918

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion store/accounts/mutations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
})
})
26 changes: 26 additions & 0 deletions utilities/animation.test.ts
Original file line number Diff line number Diff line change
@@ -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)
})
})