Sha256: 4b80e65e1f4ef7d61f6d8e014d8579aa40b69aed95b273aa1a2476be30a957d6

Contents?: true

Size: 1.32 KB

Versions: 74

Compression:

Stored size: 1.32 KB

Contents

var test = require("tape")
var extend = require("./")
var mutableExtend = require("./mutable")

test("merge", function(assert) {
    var a = { a: "foo" }
    var b = { b: "bar" }

    assert.deepEqual(extend(a, b), { a: "foo", b: "bar" })
    assert.end()
})

test("replace", function(assert) {
    var a = { a: "foo" }
    var b = { a: "bar" }

    assert.deepEqual(extend(a, b), { a: "bar" })
    assert.end()
})

test("undefined", function(assert) {
    var a = { a: undefined }
    var b = { b: "foo" }

    assert.deepEqual(extend(a, b), { a: undefined, b: "foo" })
    assert.deepEqual(extend(b, a), { a: undefined, b: "foo" })
    assert.end()
})

test("handle 0", function(assert) {
    var a = { a: "default" }
    var b = { a: 0 }

    assert.deepEqual(extend(a, b), { a: 0 })
    assert.deepEqual(extend(b, a), { a: "default" })
    assert.end()
})

test("is immutable", function (assert) {
    var record = {}

    extend(record, { foo: "bar" })
    assert.equal(record.foo, undefined)
    assert.end()
})

test("null as argument", function (assert) {
    var a = { foo: "bar" }
    var b = null
    var c = void 0

    assert.deepEqual(extend(b, a, c), { foo: "bar" })
    assert.end()
})

test("mutable", function (assert) {
    var a = { foo: "bar" }

    mutableExtend(a, { bar: "baz" })

    assert.equal(a.bar, "baz")
    assert.end()
})

Version data entries

74 entries across 35 versions & 7 rubygems

Version Path
gulp_assets-1.0.0.pre.4 template/node_modules/gulp-rev-replace/node_modules/gulp-util/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/output-file-sync/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.4 template/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-rev-replace/node_modules/gulp-util/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/output-file-sync/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-rev-replace/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-rev/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-sass/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-sourcemaps/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-util/node_modules/through2/node_modules/xtend/test.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/xtend/test.js
node_task-0.2.0 lib/node_task/node_modules/ndjson/node_modules/through2/node_modules/xtend/test.js
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/tar-fs/node_modules/tar-stream/node_modules/xtend/test.js
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/tar-fs/node_modules/tar-stream/node_modules/xtend/test.js
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/tar-fs/node_modules/tar-stream/node_modules/xtend/test.js
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/tar-fs/node_modules/tar-stream/node_modules/xtend/test.js
entangled-0.0.12 spec/dummy/public/node_modules/bower/node_modules/tar-fs/node_modules/tar-stream/node_modules/xtend/test.js
entangled-0.0.11 spec/dummy/public/node_modules/bower/node_modules/tar-fs/node_modules/tar-stream/node_modules/xtend/test.js
entangled-0.0.10 spec/dummy/public/node_modules/bower/node_modules/tar-fs/node_modules/tar-stream/node_modules/xtend/test.js