Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 287b9ac

Browse files
author
DCPDEV
committed
Completed unit test for core
1 parent 1597737 commit 287b9ac

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

‎src/pcore.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ module.exports = {
55
curry,
66
compose: compipes('reduceRight'),
77
pipe: compipes('reduce'),
8-
id: a => a
9-
}
10-
8+
identity: a => a
9+
}

‎test/pcore.test.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function init () {
1212
}));
1313
}
1414

15-
const PicoLambda = Object.assign({}, require('../src/parray'), require('../src/pcore.js'));
15+
const PicoLambda = Object.assign({}, require('../src/parray'), require('../src/pcore'));
1616
const { describe, expect, it } = global;
1717
return { PicoLambda, describe, expect, it };
1818
}
@@ -143,4 +143,24 @@ describe('api: curry', () => {
143143
const curried = PL.curry(noParams)
144144
expect(curried).toEqual('Not one')
145145
})
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+
})
146166
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /