@@ -78,8 +78,10 @@ describe('Graph', () => {
7878 it ( 'should remove edges with falsy values' , ( ) => {
7979 const [ a , b ] = graph . addEdge ( 0 , false ) ;
8080 expect ( a . adjacents . map ( getValue ) ) . toEqual ( [ false ] ) ;
81+ expect ( b . adjacents . map ( getValue ) ) . toEqual ( [ ] ) ;
8182 graph . removeEdge ( 0 , false ) ;
8283 expect ( a . adjacents . map ( getValue ) ) . toEqual ( [ ] ) ;
84+ expect ( b . adjacents . map ( getValue ) ) . toEqual ( [ ] ) ;
8385 } ) ;
8486
8587 it ( 'should not create node when removing unexisting target' , ( ) => {
@@ -126,9 +128,9 @@ describe('Graph', () => {
126128 } ) ;
127129
128130 describe ( 'remove vertex and update adjacency list' , ( ) => {
129- let n1 ,
130- n2 ,
131- n4 ;
131+ let n1 ;
132+ let n2 ;
133+ let n4 ;
132134
133135 beforeEach ( ( ) => {
134136 // 0 -> 1 <- 2
@@ -142,8 +144,11 @@ describe('Graph', () => {
142144
143145 it ( 'should remove nodes from adjacent list' , ( ) => {
144146 expect ( n4 . getAdjacents ( ) . map ( getValue ) ) . toEqual ( [ 1 , 3 ] ) ;
147+ expect ( n2 . getAdjacents ( ) . map ( getValue ) ) . toEqual ( [ 1 ] ) ;
148+ expect ( graph . nodes . has ( n1 . value ) ) . toBe ( true ) ;
145149 graph . removeVertex ( 1 ) ;
146150 expect ( n4 . getAdjacents ( ) . map ( getValue ) ) . toEqual ( [ 3 ] ) ;
151+ expect ( graph . nodes . has ( n1 . value ) ) . toBe ( false ) ;
147152 } ) ;
148153 } ) ;
149154
@@ -230,14 +235,10 @@ describe('Graph', () => {
230235 } ) ;
231236
232237 describe ( 'with (people) edges on undigraph' , ( ) => {
233- let you ,
234- mary ,
235- barbara ;
236-
237238 beforeEach ( ( ) => {
238239 graph = new Graph ( Graph . UNDIRECTED ) ;
239- [ you ] = graph . addEdge ( 'You' , 'Mary' ) ;
240- [ mary , barbara ] = graph . addEdge ( 'Mary' , 'Barbara' ) ;
240+ graph . addEdge ( 'You' , 'Mary' ) ;
241+ graph . addEdge ( 'Mary' , 'Barbara' ) ;
241242 } ) ;
242243
243244 describe ( '#areConnected' , ( ) => {
0 commit comments