From 2b35bbd4385ee105666454741eb313bd202e8b4a Mon Sep 17 00:00:00 2001 From: Nando <24811313+fzavalia@users.noreply.github.com> Date: Thu, 21 Sep 2023 10:52:06 -0300 Subject: [PATCH] fix: Test actions --- src/modules/ens/actions.spec.ts | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/modules/ens/actions.spec.ts diff --git a/src/modules/ens/actions.spec.ts b/src/modules/ens/actions.spec.ts new file mode 100644 index 000000000..360520461 --- /dev/null +++ b/src/modules/ens/actions.spec.ts @@ -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 } }) + }) +})