"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/xtend/test.js" (7 Feb 2017, 1760 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 var test = require("tape")
    2 var extend = require("./")
    3 var mutableExtend = require("./mutable")
    4 
    5 test("merge", function(assert) {
    6     var a = { a: "foo" }
    7     var b = { b: "bar" }
    8 
    9     assert.deepEqual(extend(a, b), { a: "foo", b: "bar" })
   10     assert.end()
   11 })
   12 
   13 test("replace", function(assert) {
   14     var a = { a: "foo" }
   15     var b = { a: "bar" }
   16 
   17     assert.deepEqual(extend(a, b), { a: "bar" })
   18     assert.end()
   19 })
   20 
   21 test("undefined", function(assert) {
   22     var a = { a: undefined }
   23     var b = { b: "foo" }
   24 
   25     assert.deepEqual(extend(a, b), { a: undefined, b: "foo" })
   26     assert.deepEqual(extend(b, a), { a: undefined, b: "foo" })
   27     assert.end()
   28 })
   29 
   30 test("handle 0", function(assert) {
   31     var a = { a: "default" }
   32     var b = { a: 0 }
   33 
   34     assert.deepEqual(extend(a, b), { a: 0 })
   35     assert.deepEqual(extend(b, a), { a: "default" })
   36     assert.end()
   37 })
   38 
   39 test("is immutable", function (assert) {
   40     var record = {}
   41 
   42     extend(record, { foo: "bar" })
   43     assert.equal(record.foo, undefined)
   44     assert.end()
   45 })
   46 
   47 test("null as argument", function (assert) {
   48     var a = { foo: "bar" }
   49     var b = null
   50     var c = void 0
   51 
   52     assert.deepEqual(extend(b, a, c), { foo: "bar" })
   53     assert.end()
   54 })
   55 
   56 test("mutable", function (assert) {
   57     var a = { foo: "bar" }
   58 
   59     mutableExtend(a, { bar: "baz" })
   60 
   61     assert.equal(a.bar, "baz")
   62     assert.end()
   63 })
   64 
   65 test("null prototype", function(assert) {
   66     var a = { a: "foo" }
   67     var b = Object.create(null)
   68     b.b = "bar";
   69 
   70     assert.deepEqual(extend(a, b), { a: "foo", b: "bar" })
   71     assert.end()
   72 })
   73 
   74 test("null prototype mutable", function (assert) {
   75     var a = { foo: "bar" }
   76     var b = Object.create(null)
   77     b.bar = "baz";
   78 
   79     mutableExtend(a, b)
   80 
   81     assert.equal(a.bar, "baz")
   82     assert.end()
   83 })