@@ -12,7 +12,7 @@ function init () {
12
12
} ) ) ;
13
13
}
14
14
15
- const PicoLambda = Object . assign ( { } , require ( '../src/parray' ) , require ( '../src/pcore.js ' ) ) ;
15
+ const PicoLambda = Object . assign ( { } , require ( '../src/parray' ) , require ( '../src/pcore' ) ) ;
16
16
const { describe, expect, it } = global ;
17
17
return { PicoLambda, describe, expect, it } ;
18
18
}
@@ -143,4 +143,24 @@ describe('api: curry', () => {
143
143
const curried = PL . curry ( noParams )
144
144
expect ( curried ) . toEqual ( 'Not one' )
145
145
} )
146
+ } )
147
+
148
+ describe ( 'api: identity' , ( ) => {
149
+ it ( 'should return same value as passed in' , ( ) => {
150
+ expect ( PL . identity ( 1 ) ) . toEqual ( 1 )
151
+ expect ( PL . identity ( "one" ) ) . toEqual ( "one" )
152
+ expect ( PL . identity ( [ 1 ] ) ) . toEqual ( [ 1 ] )
153
+
154
+ const testObj = { a :1 }
155
+ expect ( PL . identity ( testObj ) ) . toEqual ( testObj )
156
+ } )
157
+
158
+ it ( 'should not change the object' , ( ) => {
159
+ const testObj = { a :1 }
160
+ //Make sure we don't have the same object so that the next comparison is meaningful
161
+ expect ( PL . identity ( Object . assign ( { } , testObj ) ) === testObj ) . toEqual ( false )
162
+
163
+ //Given that we have a new object, make sure it still looks the same as the prototype
164
+ expect ( PL . identity ( Object . assign ( { } , testObj ) ) ) . toEqual ( testObj )
165
+ } )
146
166
} )
0 commit comments