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() })
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/xtend/test.js | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |