Select Git revision

Volker Schukai authored
extend.js 2.08 KiB
"use strict";
import {extend} from "../../../source/data/extend.js";
import {expect} from "chai"
describe('extend', function () {
[
[
'{"a":{"b":["1","2","3"]}}',
{
a: {
b: [
"1",
"2",
"3"
]
}
},
{
a: {
b: []
}
},
], [
'{"a":{"b":1,"d":1}}',
{
a: {
b: 1
}
},
{
a: {
d: 1
}
},
],
[
'{"a":{"b":1,"d":{"x":["car"],"f":true,"g":[]}}}',
{},
{
a: {
b: 1,
d: {x: ["car"]}
}
},
{
a: {
d: {
f: true,
g: []
}
}
},
]
].forEach(function (data) {
let d = data.shift()
let a = data
it('.extend(' + JSON.stringify(a) + ') should result in ' + d, function () {
let x = extend.apply(this, a);
expect(JSON.stringify(x)).is.equal(d);
});
});
[
[
{},
{
a: {
b: 1,
d: ["car"]
}
},
{
a: {
d: {
f: true,
g: []
}
}
},
],
[
{
a: {}
},
{
a: []
}
]
].forEach(function (data) {
let a = data
it('.extend(' + JSON.stringify(a) + ') should throw Error ', function () {
expect(() => extend.apply(this, a)).to.throw(Error);
});
});
})