Sha256: 671a766ca797e46804c550bff1960859f0f5cbc4c813951acce6ea484f3149cf
Contents?: true
Size: 1.5 KB
Versions: 5
Compression:
Stored size: 1.5 KB
Contents
"use strict"; var patch = require("../patch") exports["test patch delete"] = function(assert) { var hash = { a: 1, b: 2 } assert.deepEqual(patch(hash, { a: null }), { b: 2 }, "null removes property") } exports["test patch delete with void"] = function(assert) { var hash = { a: 1, b: 2 } assert.deepEqual(patch(hash, { a: void(0) }), { b: 2 }, "void(0) removes property") } exports["test patch addition"] = function(assert) { var hash = { a: 1, b: 2 } assert.deepEqual(patch(hash, { c: 3 }), { a: 1, b: 2, c: 3 }, "new properties are added") } exports["test patch addition"] = function(assert) { var hash = { a: 1, b: 2 } assert.deepEqual(patch(hash, { c: 3 }), { a: 1, b: 2, c: 3 }, "new properties are added") } exports["test hash on itself"] = function(assert) { var hash = { a: 1, b: 2 } assert.deepEqual(patch(hash, hash), hash, "applying hash to itself returns hash itself") } exports["test patch with empty delta"] = function(assert) { var hash = { a: 1, b: 2 } assert.deepEqual(patch(hash, {}), hash, "applying empty delta results in no changes") } exports["test patch nested data"] = function(assert) { assert.deepEqual(patch({ a: { b: 1 }, c: { d: 2 } }, { a: { b: null, e: 3 }, c: { d: 4 } }), { a: { e: 3 }, c: { d: 4 } }, "nested structures can also be patched") } if (require.main === module) require("test").run(exports)
Version data entries
5 entries across 2 versions & 1 rubygems