Sha256: c3d96d55bb0e1a0e97c9f7d09c6245339edaf940c323582226b6a4562687ae67

Contents?: true

Size: 1.72 KB

Versions: 138

Compression:

Stored size: 1.72 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()
})

test("null prototype", function(assert) {
    var a = { a: "foo" }
    var b = Object.create(null)
    b.b = "bar";

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

test("null prototype mutable", function (assert) {
    var a = { foo: "bar" }
    var b = Object.create(null)
    b.bar = "baz";

    mutableExtend(a, b)

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

Version data entries

138 entries across 127 versions & 14 rubygems

Version Path
govuk_publishing_components-17.12.0 node_modules/xtend/test.js
govuk_publishing_components-17.11.0 node_modules/xtend/test.js
govuk_publishing_components-17.10.0 node_modules/xtend/test.js
govuk_publishing_components-17.9.0 node_modules/xtend/test.js
govuk_publishing_components-17.8.0 node_modules/xtend/test.js
govuk_publishing_components-17.7.0 node_modules/xtend/test.js
govuk_publishing_components-17.6.1 node_modules/xtend/test.js
govuk_publishing_components-17.6.0 node_modules/xtend/test.js
govuk_publishing_components-17.5.0 node_modules/xtend/test.js
govuk_publishing_components-17.4.0 node_modules/xtend/test.js
govuk_publishing_components-17.3.0 node_modules/xtend/test.js
govuk_publishing_components-17.2.0 node_modules/xtend/test.js
govuk_publishing_components-17.1.1 node_modules/xtend/test.js
govuk_publishing_components-17.1.0 node_modules/xtend/test.js
govuk_publishing_components-17.0.0 node_modules/xtend/test.js
govuk_publishing_components-16.29.0 node_modules/xtend/test.js
govuk_publishing_components-16.28.0 node_modules/xtend/test.js
govuk_publishing_components-16.27.1 node_modules/xtend/test.js
govuk_publishing_components-16.27.0 node_modules/xtend/test.js
govuk_publishing_components-16.26.0 node_modules/xtend/test.js