Skip to content

Commit 8623a30

Browse files
committed
feat (easyComp): replace local state with local store
1 parent 33e78e8 commit 8623a30

File tree

10 files changed

+195
-171
lines changed

10 files changed

+195
-171
lines changed

__tests__/errors.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ describe('errors', () => {
1414
expect(() => easyComp(FuncComp)).not.toThrow()
1515
})
1616

17+
test('easyComp should throw when the store is not an object or undefined', () => {
18+
const UndefinedComp = easyComp(class extends Component {})
19+
const ObjectComp = easyComp(class extends Component {
20+
store = {}
21+
})
22+
const NullComp = easyComp(class extends Component {
23+
store = null
24+
})
25+
const StringComp = easyComp(class extends Component {
26+
store = 'Hello World!'
27+
})
28+
29+
expect(() => new UndefinedComp()).not.toThrow()
30+
expect(() => new ObjectComp()).not.toThrow()
31+
expect(() => new NullComp()).toThrow()
32+
expect(() => new StringComp()).toThrow()
33+
})
34+
1735
test('easyComp should throw when shouldComponentUpdate is defined', () => {
1836
class DefinedComp extends Component {
1937
shouldComponentUpdate () {}

0 commit comments

Comments
 (0)