@@ -15,11 +15,9 @@ describe('NSVElement', () => {
15
15
16
16
it ( 'caches meta' , ( ) => {
17
17
// mock getViewMeta
18
- const getViewMeta = jest . fn (
19
- ( ) : NSVViewMeta => {
20
- return { viewFlags : NSVViewFlags . SKIP_ADD_TO_DOM }
21
- }
22
- )
18
+ const getViewMeta = jest . fn ( ( ) : NSVViewMeta => {
19
+ return { viewFlags : NSVViewFlags . SKIP_ADD_TO_DOM }
20
+ } )
23
21
const orig = require ( '../src/registry' ) . getViewMeta
24
22
require ( '../src/registry' ) . getViewMeta = getViewMeta
25
23
@@ -57,6 +55,46 @@ describe('NSVElement', () => {
57
55
expect ( elem . lastChild ) . toBe ( child2 )
58
56
} )
59
57
58
+ it ( 'returns prevSibling/nextSibling' , ( ) => {
59
+ const elem = new NSVElement ( 'StackLayout' )
60
+ const child1 = new NSVElement ( 'Label' )
61
+ const child2 = new NSVElement ( 'Label' )
62
+ const child3 = new NSVElement ( 'Label' )
63
+
64
+ expect ( child1 . prevSibling ) . toBe ( null )
65
+ expect ( child1 . nextSibling ) . toBe ( null )
66
+
67
+ expect ( child2 . prevSibling ) . toBe ( null )
68
+ expect ( child2 . nextSibling ) . toBe ( null )
69
+
70
+ expect ( child3 . prevSibling ) . toBe ( null )
71
+ expect ( child3 . nextSibling ) . toBe ( null )
72
+
73
+ elem . appendChild ( child1 )
74
+ elem . appendChild ( child2 )
75
+ elem . appendChild ( child3 )
76
+
77
+ expect ( child1 . prevSibling ) . toBe ( null )
78
+ expect ( child1 . nextSibling ) . toBe ( child2 )
79
+
80
+ expect ( child2 . prevSibling ) . toBe ( child1 )
81
+ expect ( child2 . nextSibling ) . toBe ( child3 )
82
+
83
+ expect ( child3 . prevSibling ) . toBe ( child2 )
84
+ expect ( child3 . nextSibling ) . toBe ( null )
85
+
86
+ elem . removeChild ( child2 )
87
+
88
+ expect ( child1 . prevSibling ) . toBe ( null )
89
+ expect ( child1 . nextSibling ) . toBe ( child3 )
90
+
91
+ expect ( child2 . prevSibling ) . toBe ( null )
92
+ expect ( child2 . nextSibling ) . toBe ( null )
93
+
94
+ expect ( child3 . prevSibling ) . toBe ( child1 )
95
+ expect ( child3 . nextSibling ) . toBe ( null )
96
+ } )
97
+
60
98
it ( 'insertBefore falls back to appendChild if anchor not found' , ( ) => {
61
99
const elem = new NSVElement ( 'StackLayout' )
62
100
const child = new NSVElement ( 'Label' )
0 commit comments