@@ -103,6 +103,7 @@ describe('LinkedList', function () {
103103 it ( 'should have a reference to previous node on the last element' , ( ) => {
104104 // expect(linkedList.last.value).toBe('d');
105105 expect ( linkedList . last . previous . value ) . toBe ( 'c' ) ;
106+ expect ( linkedList . size ) . toBe ( 4 ) ;
106107 } ) ;
107108
108109 it ( 'should have a reference to previous node on the first element' , ( ) => {
@@ -130,10 +131,12 @@ describe('LinkedList', function () {
130131 expect ( linkedList . first . next . previous . value ) . toBe ( 'b' ) ;
131132 // expect(linkedList.first.value).toBe('b');
132133 expect ( linkedList . first . previous ) . toBe ( null ) ;
134+ expect ( linkedList . size ) . toBe ( 3 ) ;
133135 } ) ;
134136
135137 it ( 'should keep previous updated when deleting everything' , ( ) => {
136138 linkedList . removeFirst ( ) ;
139+ expect ( linkedList . size ) . toBe ( 2 ) ;
137140 // c -> d
138141 // expect(linkedList.first.value).toBe('c');
139142 expect ( linkedList . first . previous ) . toBe ( null ) ;
@@ -149,6 +152,7 @@ describe('LinkedList', function () {
149152 expect ( linkedList . first ) . toBe ( null ) ;
150153
151154 linkedList . removeFirst ( ) ;
155+ expect ( linkedList . size ) . toBe ( 0 ) ;
152156 } ) ;
153157 } ) ;
154158
@@ -162,6 +166,7 @@ describe('LinkedList', function () {
162166 expect ( linkedList . last . value ) . toBe ( 'b' ) ;
163167 expect ( linkedList . last . previous . value ) . toBe ( 'a' ) ;
164168 expect ( linkedList . first . previous ) . toBe ( null ) ;
169+ expect ( linkedList . size ) . toBe ( 2 ) ;
165170 } ) ;
166171 } ) ;
167172
@@ -174,10 +179,13 @@ describe('LinkedList', function () {
174179 } ) ;
175180
176181 it ( 'should do nothing with previous' , ( ) => {
182+ expect ( linkedList . size ) . toBe ( 3 ) ;
177183 expect ( linkedList . removeLast ( ) ) . toBe ( 'c' ) ;
178184 expect ( linkedList . pop ( ) ) . toBe ( 'b' ) ;
179185 expect ( linkedList . remove ( ) ) . toBe ( 'a' ) ;
180186 expect ( linkedList . shift ( ) ) . toBe ( undefined ) ;
187+ linkedList . removeLast ( ) ;
188+ expect ( linkedList . size ) . toBe ( 0 ) ;
181189 } ) ;
182190 } ) ;
183191 } ) ;
0 commit comments