All files / test test.js

100% Statements 18/18
100% Branches 0/0
100% Functions 4/4
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x 1x   1x 1x 1x   1x     1x 1x 1x 1x     1x 1x 1x 1x     1x 1x   1x   1x        
var expect = require("expect.js");
var clone = require("../src/index.js").clone;
 
describe("function clone", function () {
    describe("param data", function () {
        it("正确用例", function () {
            // 基本数据类型
            expect(clone("abc")).to.equal("abc");
 
            // 数组
            var arr = [1, [2]];
            var cloneArr = clone(arr);
            expect(cloneArr).not.to.equal(arr);
            expect(cloneArr).to.eql(arr);
 
            // 对象
            var obj = { a: { b: 1 } };
            var cloneObj = clone(obj);
            expect(cloneObj).not.to.equal(obj);
            expect(cloneObj).to.eql(obj);
        });
 
        it("边界值用例", function () {
            expect(clone()).to.equal(undefined);
 
            expect(clone(undefined)).to.equal(undefined);
 
            expect(clone(null)).to.equal(null);
        });
    });
});