Skip to content

Commit 02a7a38

Browse files
committed
Better tests
1 parent c776187 commit 02a7a38

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

test/api.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@ test('isRemoteFunction', async t => {
3535
t.false(isRemoteFunction(() => {}))
3636
t.false(isRemoteFunction('other'))
3737
})
38+
39+
test('Types must be same instance when creating new dop', function(t) {
40+
const dopcopy = dop.factory()
41+
t.is(dop.TYPE.Inner, dopcopy.TYPE.Inner)
42+
t.is(dop.TYPE.Replace, dopcopy.TYPE.Replace)
43+
t.is(dop.TYPE.Splice, dopcopy.TYPE.Splice)
44+
})

test/merge.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import test from 'ava'
2-
import { merge } from '../'
2+
import dop from '../'
33
import _ from 'lodash' // https://github.com/lodash/lodash/blob/master/test/merge.test.js
44
import R from 'ramda'
55

66
// https://jsperf.com/merge-challenge
77

8-
run(merge, 'dop')
8+
run(dop.merge, 'dop')
99
run(_.merge, 'lodash')
1010

1111
function run(merge, name) {
@@ -32,6 +32,16 @@ function run(merge, name) {
3232
t.deepEqual(merge(names, ages, heights), expected)
3333
})
3434

35+
test(name + ': must be a completly new references', function(t) {
36+
var object = { obj: { a: 1 }, arr: [2] }
37+
var actual = merge({}, object)
38+
39+
t.deepEqual(actual, object)
40+
t.not(object, actual)
41+
t.not(object.obj, actual.obj)
42+
t.not(object.arr, actual.arr)
43+
})
44+
3545
test(name + ': should work with four arguments', function(t) {
3646
var expected = { a: 4 },
3747
actual = merge({ a: 1 }, { a: 2 }, { a: 3 }, expected)

0 commit comments

Comments
 (0)