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' - 'ts-node/register'
- './config/jsdom.js' - './config/jsdom.js'
exit: true exit: true
spec: src/**/*.test.ts spec: src/**/**/*.test.ts
extension: extension:
- ts - ts
- js - 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', () => { it('returns ADD_CHOICE action', () => {
const value = 'test'; const value = 'test';
const label = 'test'; const label = 'test';
const id = 'test'; const id = 1;
const groupId = 'test'; const groupId = 1;
const disabled = false; const disabled = false;
const elementId = 'test'; const elementId = 1;
const customProperties = 'test'; const customProperties = { test: true };
const placeholder = 'test'; const placeholder = true;
const keyCode = 10; const keyCode = 10;
const expectedAction = { const expectedAction: actions.AddChoiceAction = {
type: 'ADD_CHOICE', type: 'ADD_CHOICE',
value, value,
label, label,
@ -46,7 +46,7 @@ describe('actions/choices', () => {
describe('filterChoices action', () => { describe('filterChoices action', () => {
it('returns FILTER_CHOICES action', () => { it('returns FILTER_CHOICES action', () => {
const results = Array(10); const results = Array(10);
const expectedAction = { const expectedAction: actions.FilterChoicesAction = {
type: 'FILTER_CHOICES', type: 'FILTER_CHOICES',
results, results,
}; };
@ -58,7 +58,7 @@ describe('actions/choices', () => {
describe('activateChoices action', () => { describe('activateChoices action', () => {
describe('not passing active parameter', () => { describe('not passing active parameter', () => {
it('returns ACTIVATE_CHOICES action', () => { it('returns ACTIVATE_CHOICES action', () => {
const expectedAction = { const expectedAction: actions.ActivateChoicesAction = {
type: 'ACTIVATE_CHOICES', type: 'ACTIVATE_CHOICES',
active: true, active: true,
}; };
@ -70,7 +70,7 @@ describe('actions/choices', () => {
describe('passing active parameter', () => { describe('passing active parameter', () => {
it('returns ACTIVATE_CHOICES action', () => { it('returns ACTIVATE_CHOICES action', () => {
const active = true; const active = true;
const expectedAction = { const expectedAction: actions.ActivateChoicesAction = {
type: 'ACTIVATE_CHOICES', type: 'ACTIVATE_CHOICES',
active, active,
}; };
@ -82,7 +82,7 @@ describe('actions/choices', () => {
describe('clearChoices action', () => { describe('clearChoices action', () => {
it('returns CLEAR_CHOICES action', () => { it('returns CLEAR_CHOICES action', () => {
const expectedAction = { const expectedAction: actions.ClearChoicesAction = {
type: 'CLEAR_CHOICES', type: 'CLEAR_CHOICES',
}; };

View file

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

View file

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

View file

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