@@ -17,11 +17,11 @@ describe('arrays', () => {
17
17
} )
18
18
19
19
describe ( 'addElementToBeginningOfArray(array, element)' , ( ) => {
20
- it ( 'adds an ` element` to the beginning of an ` array` ' , ( ) => {
20
+ it ( 'adds an element to the beginning of an array' , ( ) => {
21
21
expect ( addElementToBeginningOfArray ( [ 1 ] , 'foo' ) ) . to . eql ( [ 'foo' , 1 ] )
22
22
} )
23
23
24
- it ( 'does not alter ` array` ' , ( ) => {
24
+ it ( 'does not alter the original array' , ( ) => {
25
25
const array = [ 1 ]
26
26
27
27
addElementToBeginningOfArray ( array , 'foo' )
@@ -31,11 +31,11 @@ describe('arrays', () => {
31
31
} )
32
32
33
33
describe ( 'destructivelyAddElementToBeginningOfArray(array, element)' , ( ) => {
34
- it ( 'adds an ` element` to the beginning of an ` array` ' , ( ) => {
34
+ it ( 'adds an element to the beginning of an array' , ( ) => {
35
35
expect ( destructivelyAddElementToBeginningOfArray ( [ 1 ] , 'foo' ) ) . to . eql ( [ 'foo' , 1 ] )
36
36
} )
37
37
38
- it ( 'alters ` array` ' , ( ) => {
38
+ it ( 'alters the original array' , ( ) => {
39
39
const array = [ 1 ]
40
40
41
41
destructivelyAddElementToBeginningOfArray ( array , 'foo' )
@@ -45,25 +45,25 @@ describe('arrays', () => {
45
45
} )
46
46
47
47
describe ( 'addElementToEndOfArray(array, element)' , ( ) => {
48
- it ( 'adds an ` element` to the end of an ` array` ' , ( ) => {
48
+ it ( 'adds an element to the end of an array' , ( ) => {
49
49
expect ( addElementToEndOfArray ( [ 1 ] , 'foo' ) ) . to . eql ( [ 1 , 'foo' ] )
50
50
} )
51
51
52
- it ( 'does not alter ` array` ' , ( ) => {
52
+ it ( 'does not alter the original array' , ( ) => {
53
53
const array = [ 1 ]
54
54
55
55
addElementToEndOfArray ( array , 'foo' )
56
56
57
- expect ( array ) . to . eql ( array )
57
+ expect ( array ) . to . eql ( [ 1 ] )
58
58
} )
59
59
} )
60
60
61
61
describe ( 'destructivelyAddElementToEndOfArray(array, element)' , ( ) => {
62
- it ( 'adds an ` element` to the end of an ` array` ' , ( ) => {
62
+ it ( 'adds an element to the end of an array' , ( ) => {
63
63
expect ( destructivelyAddElementToEndOfArray ( [ 1 ] , 'foo' ) ) . to . eql ( [ 1 , 'foo' ] )
64
64
} )
65
65
66
- it ( 'alters ` array` ' , ( ) => {
66
+ it ( 'alters the original array' , ( ) => {
67
67
const array = [ 1 ]
68
68
69
69
destructivelyAddElementToEndOfArray ( array , 'foo' )
@@ -73,44 +73,58 @@ describe('arrays', () => {
73
73
} )
74
74
75
75
describe ( 'accessElementInArray(array, index)' , ( ) => {
76
- it ( 'accesses the element in ` array` at the given ` index` ' , ( ) => {
76
+ it ( 'accesses the element in array at the given index' , ( ) => {
77
77
expect ( accessElementInArray ( [ 1 , 2 , 3 ] , 2 ) ) . to . equal ( 3 )
78
78
} )
79
79
} )
80
80
81
81
describe ( 'destructivelyRemoveElementFromBeginningOfArray(array)' , ( ) => {
82
- it ( 'returns the ` array` with the first element removed' , ( ) => {
82
+ it ( 'returns the array with the first element removed' , ( ) => {
83
83
expect ( destructivelyRemoveElementFromBeginningOfArray ( [ 1 , 2 , 3 ] ) ) . to . eql ( [ 2 , 3 ] )
84
84
} )
85
85
86
- it ( 'did not make a copy of the array when removing the first element ' , ( ) => {
86
+ it ( 'alters the original array ' , ( ) => {
87
87
const array = [ 1 , 2 , 3 ] ;
88
88
destructivelyRemoveElementFromBeginningOfArray ( array ) ;
89
89
expect ( array ) . to . eql ( [ 2 , 3 ] ) ;
90
90
} )
91
91
} )
92
92
93
93
describe ( 'removeElementFromBeginningOfArray(array)' , ( ) => {
94
- it ( 'removes the first element from the ` array` ' , ( ) => {
94
+ it ( 'removes the first element from the array' , ( ) => {
95
95
expect ( removeElementFromBeginningOfArray ( [ 1 , 2 , 3 ] ) ) . to . eql ( [ 2 , 3 ] )
96
96
} )
97
+
98
+ it ( 'does not alter the original array' , ( ) => {
99
+ const array = [ 1 , 2 , 3 ] ;
100
+
101
+ removeElementFromBeginningOfArray ( array ) ;
102
+
103
+ expect ( array ) . to . eql ( [ 1 , 2 , 3 ] ) ;
104
+ } )
97
105
} )
98
106
99
107
describe ( 'destructivelyRemoveElementFromEndOfArray(array)' , ( ) => {
100
- it ( 'returns the ` array` with the last element removed' , ( ) => {
108
+ it ( 'returns the array with the last element removed' , ( ) => {
101
109
expect ( destructivelyRemoveElementFromEndOfArray ( [ 1 , 2 , 3 ] ) ) . to . eql ( [ 1 , 2 ] )
102
110
} )
103
111
104
- it ( 'did not make a copy of the array when removing the last element ' , ( ) => {
112
+ it ( 'alters the original array ' , ( ) => {
105
113
const array = [ 1 , 2 , 3 ] ;
106
114
destructivelyRemoveElementFromEndOfArray ( array ) ;
107
115
expect ( array ) . to . eql ( [ 1 , 2 ] ) ;
108
116
} )
109
117
} )
110
118
111
119
describe ( 'removeElementFromEndOfArray(array)' , ( ) => {
112
- it ( 'removes the last element from the ` array` ' , ( ) => {
120
+ it ( 'removes the last element from the array' , ( ) => {
113
121
expect ( removeElementFromEndOfArray ( [ 1 , 2 , 3 ] ) ) . to . eql ( [ 1 , 2 ] )
114
122
} )
123
+
124
+ it ( 'does not alter the original array' , ( ) => {
125
+ const array = [ 1 , 2 , 3 ] ;
126
+ removeElementFromEndOfArray ( array ) ;
127
+ expect ( array ) . to . eql ( [ 1 , 2 , 3 ] ) ;
128
+ } )
115
129
} )
116
- } )
130
+ } )
0 commit comments