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('
{1}
', cls, text)).to.equal('
Some text
'); + }); }); diff --git a/src/core/base.js b/src/core/base.js index f2b9483a10..5b30e1c3f4 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -976,7 +976,7 @@ if (!_global.BI) { * 对字符串做替换的函数 * * var cls = 'my-class', text = 'Some text'; - * var res = BI.format('
{1}
', cls, text); * //res的值为:'
Some text
'; * * @static