From 9e593bb5b66e07957a6517efd4df412424f3e2eb Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 10 Apr 2020 15:45:18 +0800 Subject: [PATCH] =?UTF-8?q?BI-61182=20test:=20=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- karma.conf.js | 5 ++++ src/core/__test__/base.test.js | 49 +++++++++++++++++++++++++++++++++- src/core/base.js | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index ac795ceac1..51b6bf4bea 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -57,6 +57,11 @@ module.exports = function (config) { "test/**/*.js" ], + exclude: [ + "src/base/tree/ztree/jquery.ztree.core-3.5.js", + "src/base/tree/ztree/jquery.ztree.excheck-3.5.js" + ], + // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor diff --git a/src/core/__test__/base.test.js b/src/core/__test__/base.test.js index 950a32e9bb..df933bae7c 100644 --- a/src/core/__test__/base.test.js +++ b/src/core/__test__/base.test.js @@ -254,10 +254,57 @@ describe("baseFunctionTest", function () { /** * test_author_windy */ - it("abc", function () { + it("others", function () { expect(BI.abc2Int("B")).to.equal(2); expect(BI.int2Abc(2)).to.equal("B"); + expect(BI.has({a: "1", b: "2"}, "a")).to.equal(true); + expect(Object.isFrozen(BI.freeze({a: "1", b: "2"}))).to.equal(true); + expect(BI.isCapitalEqual("A", "a")).to.equal(true); + expect(BI.isEmptyString("a")).to.equal(false); + expect(BI.isNotEmptyString("a")).to.equal(true); + expect(BI.isWindow("a")).to.equal(false); }); + /** + * test_author_windy + */ + it("deepFunc", function () { + expect(BI.isDeepMatch({b: {c: {e: 3}}, d:2}, {b: {c: {e: 3}}, d:2})).to.equal(true); + expect(BI.deepIndexOf([{a: 1}, {b: 2}, {c: 3}], {c: 3})).to.equal(2); + var remove = [{a: 1}, {b: 2}, {c: 3}]; + BI.deepRemove(remove, {c: 3}); + expect(remove).to.deep.equal([{a: 1}, {b: 2}]); + expect(BI.deepWithout([{a: 1}, {b: 2}, {c: 3}], {c: 3})).to.deep.equal([{a: 1}, {b: 2}]); + expect(BI.deepUnique([{c: 3}, {a: 1}, {b: 2}, {c: 3}, {c: 3}])).to.deep.equal([{c: 3}, {a: 1}, {b: 2}]); + expect(BI.deepDiff({a: 1, b: 2}, {a: 1, c: 2})).to.deep.equal(["b", "c"]); + }); + /** + * test_author_windy + */ + it("number", function () { + expect(BI.parseSafeInt(9007199254740992)).to.equal(9007199254740991); + expect(BI.isNegativeInteger(-3)).to.equal(true); + expect(BI.isFloat(1.2)).to.equal(false); + expect(BI.isOdd(1)).to.equal(true); + expect(BI.isOdd("a")).to.equal(false); + expect(BI.isEven("a")).to.equal(false); + expect(BI.isEven(2)).to.equal(true); + expect(BI.sum([1, 2, 3, 4, 5, 6, 7])).to.equal(28); + expect(BI.average([1, 2, 3, 4, 5, 6, 7])).to.equal(4); + }); + + /** + * test_author_windy + */ + it("string", function () { + expect(BI.toLowerCase("AAAAA")).to.equal("aaaaa"); + expect(BI.isLiteral("AAAAA")).to.equal(false); + expect(BI.stripQuotes("AAAAA")).to.equal("AAAAA"); + expect(BI.camelize("background-color")).to.equal("backgroundColor"); + expect(BI.escape("'\\")).to.equal("\\'\\\\"); + expect(BI.leftPad("123", 5, "0")).to.equal("00123"); + var cls = 'my-class', text = 'Some text'; + expect(BI.format('