Use interfaces in action tests

This commit is contained in:
Josh Johnson 2019-12-23 17:22:09 +00:00
parent 893cbef14c
commit f896be9e10
7 changed files with 2951 additions and 2998 deletions

View file

@ -2,7 +2,7 @@ require:
- 'ts-node/register'
- './config/jsdom.js'
exit: true
spec: src/**/*.test.ts
spec: src/**/**/*.test.ts
extension:
- ts
- js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,15 +6,15 @@ describe('actions/choices', () => {
it('returns ADD_CHOICE action', () => {
const value = 'test';
const label = 'test';
const id = 'test';
const groupId = 'test';
const id = 1;
const groupId = 1;
const disabled = false;
const elementId = 'test';
const customProperties = 'test';
const placeholder = 'test';
const elementId = 1;
const customProperties = { test: true };
const placeholder = true;
const keyCode = 10;
const expectedAction = {
const expectedAction: actions.AddChoiceAction = {
type: 'ADD_CHOICE',
value,
label,
@ -46,7 +46,7 @@ describe('actions/choices', () => {
describe('filterChoices action', () => {
it('returns FILTER_CHOICES action', () => {
const results = Array(10);
const expectedAction = {
const expectedAction: actions.FilterChoicesAction = {
type: 'FILTER_CHOICES',
results,
};
@ -58,7 +58,7 @@ describe('actions/choices', () => {
describe('activateChoices action', () => {
describe('not passing active parameter', () => {
it('returns ACTIVATE_CHOICES action', () => {
const expectedAction = {
const expectedAction: actions.ActivateChoicesAction = {
type: 'ACTIVATE_CHOICES',
active: true,
};
@ -70,7 +70,7 @@ describe('actions/choices', () => {
describe('passing active parameter', () => {
it('returns ACTIVATE_CHOICES action', () => {
const active = true;
const expectedAction = {
const expectedAction: actions.ActivateChoicesAction = {
type: 'ACTIVATE_CHOICES',
active,
};
@ -82,7 +82,7 @@ describe('actions/choices', () => {
describe('clearChoices action', () => {
it('returns CLEAR_CHOICES action', () => {
const expectedAction = {
const expectedAction: actions.ClearChoicesAction = {
type: 'CLEAR_CHOICES',
};

View file

@ -8,7 +8,8 @@ describe('actions/groups', () => {
const id = 1;
const active = true;
const disabled = false;
const expectedAction = {
const expectedAction: actions.AddGroupAction = {
type: 'ADD_GROUP',
value,
id,

View file

@ -13,7 +13,7 @@ describe('actions/items', () => {
const placeholder = true;
const keyCode = 10;
const expectedAction = {
const expectedAction: actions.AddItemAction = {
type: 'ADD_ITEM',
value,
label,
@ -44,7 +44,8 @@ describe('actions/items', () => {
it('returns REMOVE_ITEM action', () => {
const id = 1;
const choiceId = 1;
const expectedAction = {
const expectedAction: actions.RemoveItemAction = {
type: 'REMOVE_ITEM',
id,
choiceId,
@ -59,7 +60,7 @@ describe('actions/items', () => {
const id = 1;
const highlighted = true;
const expectedAction = {
const expectedAction: actions.HighlightItemAction = {
type: 'HIGHLIGHT_ITEM',
id,
highlighted,

View file

@ -1,10 +1,11 @@
import { expect } from 'chai';
import * as actions from './misc';
import { State } from '../interfaces';
describe('actions/misc', () => {
describe('clearAll action', () => {
it('returns CLEAR_ALL action', () => {
const expectedAction = {
const expectedAction: actions.ClearAllAction = {
type: 'CLEAR_ALL',
};
@ -14,15 +15,13 @@ describe('actions/misc', () => {
describe('resetTo action', () => {
it('returns RESET_TO action', () => {
const state = {
const state: State = {
choices: [],
items: [],
groups: [],
general: {
loading: false,
},
loading: false,
};
const expectedAction = {
const expectedAction: actions.ResetToAction = {
type: 'RESET_TO',
state,
};
@ -34,7 +33,7 @@ describe('actions/misc', () => {
describe('setIsLoading action', () => {
describe('setting loading state to true', () => {
it('returns expected action', () => {
const expectedAction = {
const expectedAction: actions.SetIsLoadingAction = {
type: 'SET_IS_LOADING',
isLoading: true,
};
@ -45,7 +44,7 @@ describe('actions/misc', () => {
describe('setting loading state to false', () => {
it('returns expected action', () => {
const expectedAction = {
const expectedAction: actions.SetIsLoadingAction = {
type: 'SET_IS_LOADING',
isLoading: false,
};