forked from fanruan/fineui
windy
6 years ago
14 changed files with 198 additions and 9 deletions
@ -0,0 +1,6 @@
|
||||
!(function () { |
||||
// 先把准备环境准备好
|
||||
while(BI.prepares && BI.prepares.length > 0) { |
||||
BI.prepares.shift()(); |
||||
} |
||||
})(); |
@ -0,0 +1,110 @@
|
||||
/** |
||||
* Created by windy on 2018/01/24. |
||||
*/ |
||||
describe("baseFunctionTest", function () { |
||||
|
||||
before(function () { |
||||
|
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("formatEl和stripEL", function () { |
||||
var obj1 = { |
||||
type: "a", |
||||
pro: {}, |
||||
items: [] |
||||
}; |
||||
|
||||
var obj2 = { |
||||
el: { |
||||
type: "a", |
||||
pro: {}, |
||||
items: [] |
||||
} |
||||
}; |
||||
expect(BI.formatEL(obj1)).to.deep.equal(obj2); |
||||
expect(BI.formatEL(obj2)).to.deep.equal(obj2); |
||||
expect(BI.stripEL(obj1)).to.deep.equal(obj1); |
||||
expect(BI.stripEL(obj2)).to.deep.equal(obj1); |
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("encodeURIComponent和decodeURIComponent", function () { |
||||
var targetString = "tableName./\\"; |
||||
var encodeString = BI.encodeURIComponent(targetString); |
||||
expect(encodeString).to.equal("tableName120"); |
||||
expect(BI.decodeURIComponent(encodeString)).to.equal(targetString); |
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("count", function () { |
||||
var a = []; |
||||
expect(BI.count(1, 100)).to.equal(99); |
||||
BI.count(0, 100, function (v) { |
||||
a[v] = 0; |
||||
}); |
||||
expect(a.length).to.equal(100); |
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("concat", function () { |
||||
expect(BI.concat([1], [2])).to.deep.equal([1, 2]); |
||||
expect(BI.concat(1, 2)).to.equal("12"); |
||||
expect(BI.concat("1", "2")).to.equal("12"); |
||||
expect(BI.concat({a: 1}, {b: 1})).to.deep.equal({a: 1, b: 1}); |
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("remove", function () { |
||||
var a = [1, 2, 3, 4, 5, 6]; |
||||
BI.remove(a, function (i, v) { |
||||
return v === 4; |
||||
}); |
||||
expect(a).to.deep.equal([1, 2, 3, 5, 6]); |
||||
var b = { |
||||
a: 1, |
||||
b: 2 |
||||
}; |
||||
BI.remove(b, function (key) { |
||||
return key === "a"; |
||||
}); |
||||
expect(b).to.deep.equal({ |
||||
b: 2 |
||||
}); |
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("removeAt", function () { |
||||
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; |
||||
BI.removeAt(a, 2); |
||||
expect(a).to.deep.equal([1, 2, 4, 5, 6, 7, 8, 9]); |
||||
var b = { |
||||
a: 1, |
||||
b: 2 |
||||
}; |
||||
BI.removeAt(b, "a"); |
||||
expect(b).to.deep.equal({ |
||||
b: 2 |
||||
}); |
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("makeArray", function () { |
||||
var a = BI.makeArray(2, 1); |
||||
expect(a).to.deep.equal([1, 1, 1]); |
||||
}); |
||||
}); |
@ -0,0 +1,31 @@
|
||||
/** |
||||
* Created by windy on 2018/01/23. |
||||
*/ |
||||
describe("dateFunctionTest", function () { |
||||
|
||||
before(function () { |
||||
|
||||
}); |
||||
|
||||
/** |
||||
* test_author_windy |
||||
*/ |
||||
it("getWeekNumber", function () { |
||||
expect(BI.print(BI.getDate(2005, 0, 1), "%Y-%W")).to.equal("2004-53"); |
||||
expect(BI.print(BI.getDate(2005, 0, 2), "%Y-%W")).to.equal("2004-53"); |
||||
expect(BI.print(BI.getDate(2005, 11, 31), "%Y-%W")).to.equal("2005-52"); |
||||
expect(BI.print(BI.getDate(2007, 0, 1), "%Y-%W")).to.equal("2007-01"); |
||||
expect(BI.print(BI.getDate(2007, 11, 30), "%Y-%W")).to.equal("2007-52"); |
||||
expect(BI.print(BI.getDate(2007, 11, 31), "%Y-%W")).to.equal("2008-01"); |
||||
expect(BI.print(BI.getDate(2008, 0, 1), "%Y-%W")).to.equal("2008-01"); |
||||
expect(BI.print(BI.getDate(2008, 11, 28), "%Y-%W")).to.equal("2008-52"); |
||||
expect(BI.print(BI.getDate(2008, 11, 29), "%Y-%W")).to.equal("2009-01"); |
||||
expect(BI.print(BI.getDate(2008, 11, 30), "%Y-%W")).to.equal("2009-01"); |
||||
expect(BI.print(BI.getDate(2008, 11, 31), "%Y-%W")).to.equal("2009-01"); |
||||
expect(BI.print(BI.getDate(2009, 0, 1), "%Y-%W")).to.equal("2009-01"); |
||||
expect(BI.print(BI.getDate(2009, 11, 31), "%Y-%W")).to.equal("2009-53"); |
||||
expect(BI.print(BI.getDate(2010, 0, 1), "%Y-%W")).to.equal("2009-53"); |
||||
expect(BI.print(BI.getDate(2010, 0, 2), "%Y-%W")).to.equal("2009-53"); |
||||
expect(BI.print(BI.getDate(2010, 0, 3), "%Y-%W")).to.equal("2009-53"); |
||||
}); |
||||
}); |
Loading…
Reference in new issue