Skip to content

Commit 448ff7d

Browse files
committed
Add multiple suspense tests
1 parent 6776467 commit 448ff7d

File tree

9 files changed

+491
-14
lines changed

9 files changed

+491
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ yarn-error.log*
44
package-lock.json
55
dist
66
.DS_Store
7+
coverage

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
]
3333
},
3434
"lint-staged": {
35-
"*.{js}": [
35+
"**/*.{js}": [
3636
"flow focus-check",
3737
"prettier --write",
3838
"git add"
3939
],
40-
"*.{json,md}": [
40+
"**/*.{json,md}": [
4141
"prettier --write",
4242
"git add"
4343
]

src/__tests__/element.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import * as is from 'react-is'
2+
import { typeOf } from '../element'
3+
4+
import {
5+
REACT_ELEMENT_TYPE,
6+
REACT_PORTAL_TYPE,
7+
REACT_FRAGMENT_TYPE,
8+
REACT_STRICT_MODE_TYPE,
9+
REACT_PROFILER_TYPE,
10+
REACT_PROVIDER_TYPE,
11+
REACT_CONTEXT_TYPE,
12+
REACT_CONCURRENT_MODE_TYPE,
13+
REACT_FORWARD_REF_TYPE,
14+
REACT_SUSPENSE_TYPE,
15+
REACT_MEMO_TYPE,
16+
REACT_LAZY_TYPE
17+
} from '../symbols'
18+
19+
describe('typeOf', () => {
20+
it('correctly identifies all elements', () => {
21+
expect(typeOf({})).toBe(undefined)
22+
23+
expect(typeOf({
24+
$$typeof: is.Portal
25+
})).toBe(REACT_PORTAL_TYPE)
26+
27+
expect(typeOf({
28+
$$typeof: is.Element,
29+
type: is.ConcurrentMode
30+
})).toBe(REACT_CONCURRENT_MODE_TYPE)
31+
32+
expect(typeOf({
33+
$$typeof: is.Element,
34+
type: is.Fragment
35+
})).toBe(REACT_FRAGMENT_TYPE)
36+
37+
expect(typeOf({
38+
$$typeof: is.Element,
39+
type: is.Profiler
40+
})).toBe(REACT_PROFILER_TYPE)
41+
42+
expect(typeOf({
43+
$$typeof: is.Element,
44+
type: is.StrictMode
45+
})).toBe(REACT_STRICT_MODE_TYPE)
46+
47+
expect(typeOf({
48+
$$typeof: is.Element,
49+
type: is.Suspense
50+
})).toBe(REACT_SUSPENSE_TYPE)
51+
})
52+
})

src/__tests__/element.test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as is from 'react-is'
2+
import { typeOf } from '../element'
3+
4+
import {
5+
REACT_ELEMENT_TYPE,
6+
REACT_PORTAL_TYPE,
7+
REACT_FRAGMENT_TYPE,
8+
REACT_STRICT_MODE_TYPE,
9+
REACT_PROFILER_TYPE,
10+
REACT_PROVIDER_TYPE,
11+
REACT_CONTEXT_TYPE,
12+
REACT_CONCURRENT_MODE_TYPE,
13+
REACT_FORWARD_REF_TYPE,
14+
REACT_SUSPENSE_TYPE,
15+
REACT_MEMO_TYPE,
16+
REACT_LAZY_TYPE
17+
} from '../symbols'
18+
19+
describe('typeOf', () => {
20+
it('correctly identifies all elements', () => {
21+
expect(typeOf({})).toBe(undefined)
22+
23+
expect(typeOf({
24+
$$typeof: is.Portal
25+
})).toBe(REACT_PORTAL_TYPE)
26+
27+
expect(typeOf({
28+
$$typeof: is.Element,
29+
type: is.ConcurrentMode
30+
})).toBe(REACT_CONCURRENT_MODE_TYPE)
31+
32+
expect(typeOf({
33+
$$typeof: is.Element,
34+
type: is.Fragment
35+
})).toBe(REACT_FRAGMENT_TYPE)
36+
37+
expect(typeOf({
38+
$$typeof: is.Element,
39+
type: is.Profiler
40+
})).toBe(REACT_PROFILER_TYPE)
41+
42+
expect(typeOf({
43+
$$typeof: is.Element,
44+
type: is.StrictMode
45+
})).toBe(REACT_STRICT_MODE_TYPE)
46+
})
47+
})

0 commit comments

Comments
 (0)