Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EskiMojo14 committed Nov 20, 2023
1 parent 8472642 commit 7859c01
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/utils/isAction.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { isAction } from 'redux'

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)
}
})
})

0 comments on commit 7859c01

Please sign in to comment.