/
githubmirror
/
redux
Обзор
Документация
Войти
/
githubmirror
/
redux
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/utils/isAction.spec.ts
23 строки
744 B
Ben Durrant
use internal import
20 ноя 2023, 18:33
20 ноя 2023, 18:33
d44a074
Код
Авторство
О чём код?
import isAction from '@internal/utils/isAction' describe('isAction', () => { it('should only return true for plain objects with a string type property', () => { const actionCreator = () => ({ type: 'anAction' }) class Action { type = 'totally an action' } const testCases: [action: unknown, expected: boolean][] = [ [{ type: 'an action' }, true], [{ type: 'more props', extra: true }, true], [{ type: 0 }, false], [actionCreator(), true], [actionCreator, false], [Promise.resolve({ type: 'an action' }), false], [new Action(), false], ['a string', false] ] for (const [action, expected] of testCases) { expect(isAction(action)).toBe(expected) } }) })