-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.test.js
42 lines (31 loc) · 1.19 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* @flow */
import { type PathOr, pathOr } from '..'
('c': PathOr<{a: {b: 'c'}}, ['a', 'b'], null>)
;('y': PathOr<{ x: {y: 'y'} }, ['x', 'y'], null>)
;(null: PathOr<{a: {b: 'c'}}, ['a', 'b', 'c'], null>)
;({ b: 'c' }: PathOr<{a: {b: 'c'}}, ['a'], null>)
/**
* $ExpectError
*/
;('c2': PathOr<{a: {b: 'c'}}, ['a', 'b'], null>)
;('c': PathOr<{a: {b: 'c'}}, ['a', 'b'], null>)
;('c': PathOr<{a: {b: {c: 'c'}}}, ['a', 'b', 'c'], null>)
/**
* $ExpectError
*/
;('heh2': PathOr<{ hey: { hoh: { heh: 'heh' } } }, ['hey', 'hoh', 'heh'], null>)
;(pathOr({ hey: { hoh: 'hoh' } }, ['hey'], null): {hoh: 'hoh'})
;(pathOr({ hey: { hoh: 'hoh' } }, ['hey', 'hoh2'], null): null)
;(pathOr({ hey: { hoh: 'hoh' } }, ['hey', 'hoh'], null): 'hoh')
;(pathOr({ hey: { hoh: 'hoh' } }, ['hey'], null): {hoh: 'hoh'})
/**
* $ExpectError
*/
;(pathOr({ hey: { hoh: 'hoh' } }, ['hey', 'hoh'], null): 'hoh2')
;(pathOr({ hey: { hoh: 'hoh' } }, ['hey', 'hoh'], null): 'hoh')
;(pathOr({ hey: { hoh: { heh: 'heh' } } }, ['hey', 'hoh', 'hah'], null): null)
/**
* $ExpectError
*/
;(pathOr({ hey: { hoh: { heh: 'heh' } } }, ['hey', 'hoh', 'heh'], null): 'heh2')
;(pathOr({ hey: { hoh: { heh: 'heh' } } }, ['hey', 'hoh', 'heh'], null): 'heh')