Skip to content

Commit

Permalink
fix: Test actions
Browse files Browse the repository at this point in the history
  • Loading branch information
fzavalia committed Sep 21, 2023
1 parent 07f87fd commit 2b35bbd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/modules/ens/actions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
fetchExternalENSNamesRequest,
FETCH_EXTERNAL_ENS_NAMES_REQUEST,
FETCH_EXTERNAL_ENS_NAMES_SUCCESS,
fetchExternalENSNamesSuccess,
fetchExternalENSNamesFailure,
FETCH_EXTERNAL_ENS_NAMES_FAILURE
} from './actions'
import { ENSError } from './types'

let owner: string
let names: string[]
let error: ENSError

beforeEach(() => {
owner = '0x123'
names = ['name1.eth', 'name2.eth']
error = { message: 'Some Error' }
})

describe('when creating the action that signals the start of an external ens fetch request', () => {
it('should return an action signaling the start of an external ens fetch request', () => {
expect(fetchExternalENSNamesRequest(owner)).toEqual({ type: FETCH_EXTERNAL_ENS_NAMES_REQUEST, payload: { owner } })
})
})

describe('when creating the action that signals the successful fetch of external ens names', () => {
it('should return an action signaling the successful fetch of external ens names', () => {
expect(fetchExternalENSNamesSuccess(owner, names)).toEqual({ type: FETCH_EXTERNAL_ENS_NAMES_SUCCESS, payload: { owner, names } })
})
})

describe('when creating the action that signals the unsuccessful fetch of external ens names', () => {
it('should return an action signaling the unsuccessful fetch of external ens names', () => {
expect(fetchExternalENSNamesFailure(owner, error)).toEqual({ type: FETCH_EXTERNAL_ENS_NAMES_FAILURE, payload: { owner, error } })
})
})

0 comments on commit 2b35bbd

Please sign in to comment.