Browse Source

Pull request #1545: 无JIRA任务 解决单测报错

Merge in VISUAL/fineui from ~WINDY/fui:master to master

* commit '19adce1fdba4ba29a4261e5893a10a5cb820fdad':
  无JIRA任务 解决单测报错
es6
windy 4 years ago
parent
commit
5866488ad9
  1. 6
      karma.conf.js
  2. 17
      src/case/combo/searchtextvaluecombo/__test__/combo.searchtextvaluecombo.test.js
  3. 2
      src/core/__test__/alias.test.js
  4. 117
      src/widget/multiselect/__test__/multiselect.loader.nobar.test.js
  5. 7
      src/widget/multiselectlist/__test__/multiselectlist.insert.test.js
  6. 3
      src/widget/multiselectlist/multiselectlist.insert.js

6
karma.conf.js

@ -19,11 +19,7 @@ module.exports = function (config) {
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
"src/css/core/**/*.css", "dist/fineui.min.css",
"src/css/theme/**/*.css",
"src/css/base/**/*.css",
"src/css/widget/**/*.css",
"public/css/app.css",
"src/core/foundation.js", "src/core/foundation.js",
"src/core/lodash.js", "src/core/lodash.js",
"src/core/base.js", "src/core/base.js",

17
src/case/combo/searchtextvaluecombo/__test__/combo.searchtextvaluecombo.test.js

@ -6,12 +6,15 @@
describe("search_text_value_combo", function () { describe("search_text_value_combo", function () {
var items = BI.map(BI.makeArray(100, null), function(idx, v) { var items;
return { before(function () {
text: idx, items = BI.map(BI.makeArray(100, null), function(idx, v) {
value: idx, return {
title: idx text: idx,
}; value: idx,
title: idx
};
});
}); });
/** /**
@ -77,7 +80,7 @@ describe("search_text_value_combo", function () {
BI.nextTick(function () { BI.nextTick(function () {
BI.Test.triggerKeyDown(widget.element.find(".bi-search-text-value-trigger .bi-input"), "2", 50, function () { BI.Test.triggerKeyDown(widget.element.find(".bi-search-text-value-trigger .bi-input"), "2", 50, function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.find(".bi-search-text-value-popup .bi-single-select-item").click(); widget.element.find(".bi-search-text-value-popup .bi-single-select-item")[0].click();
expect(widget.getValue()[0]).to.deep.equal(2); expect(widget.getValue()[0]).to.deep.equal(2);
widget.destroy(); widget.destroy();
done(); done();

2
src/core/__test__/alias.test.js

@ -18,7 +18,7 @@ describe("aliasFunctionTest", function () {
var targetString = "<a>1 2&</a>"; var targetString = "<a>1 2&</a>";
var encodeString = BI.htmlEncode(targetString); var encodeString = BI.htmlEncode(targetString);
expect(encodeString).to.equal("&lt;a&gt;1 2&amp;&lt;/a&gt;"); expect(encodeString).to.equal("&lt;a&gt;1&nbsp;2&amp;&lt;/a&gt;");
expect(BI.htmlDecode(encodeString)).to.equal(targetString); expect(BI.htmlDecode(encodeString)).to.equal(targetString);
}); });

117
src/widget/multiselect/__test__/multiselect.loader.nobar.test.js

@ -6,67 +6,71 @@
describe("multi_select_no_bar_series", function () { describe("multi_select_no_bar_series", function () {
var _getItemsByTimes = function (items, times) { var _getItemsByTimes, _itemsCreator, itemSelectorGetter, searchItemSelectorGetter, _hasNextByTimes, items;
var res = []; before(function () {
for (var i = (times - 1) * 100; items[i] && i < times * 100; i++) { _getItemsByTimes = function (items, times) {
res.push(items[i]); var res = [];
} for (var i = (times - 1) * 100; items[i] && i < times * 100; i++) {
return res; res.push(items[i]);
}; }
return res;
};
var _hasNextByTimes = function (items, times) { _hasNextByTimes = function (items, times) {
return times * 100 < items.length; return times * 100 < items.length;
}; };
var _itemsCreator = function (options, callback) { _itemsCreator = function (options, callback) {
var items = BI.map(BI.makeArray(100, null), function(idx, v) { var items = BI.map(BI.makeArray(100, null), function(idx, v) {
return { return {
text: idx, text: idx,
value: idx, value: idx,
title: idx title: idx
}; };
}); });
var keywords = (options.keywords || []).slice(); var keywords = (options.keywords || []).slice();
if (options.keyword) { if (options.keyword) {
keywords.push(options.keyword); keywords.push(options.keyword);
} }
BI.each(keywords, function (i, kw) { BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw); var search = BI.Func.getSearchResult(items, kw);
items = search.match.concat(search.find); items = search.match.concat(search.find);
});
if (options.selectedValues) {// 过滤
var filter = BI.makeObject(options.selectedValues, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
}); });
} if (options.selectedValues) {// 过滤
if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) { var filter = BI.makeObject(options.selectedValues, true);
items = BI.filter(items, function (i, ob) {
return !filter[ob.value];
});
}
if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
callback({
items: items
});
return;
}
if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({ callback({
items: items items: _getItemsByTimes(items, options.times),
hasNext: _hasNextByTimes(items, options.times)
}); });
return; };
}
if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) {
callback({count: items.length});
return;
}
callback({
items: _getItemsByTimes(items, options.times),
hasNext: _hasNextByTimes(items, options.times)
});
};
var itemSelectorGetter = function (array) { itemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) { return BI.map(array, function (idx, num) {
return ".bi-multi-select-popup-view .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")"; return ".bi-multi-select-popup-view .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
}); });
}; };
var searchItemSelectorGetter = function (array) { searchItemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) { return BI.map(array, function (idx, num) {
return ".bi-multi-select-search-pane .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")"; return ".bi-multi-select-search-pane .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
}); });
}; };
})
/** /**
* test_author_windy * test_author_windy
@ -159,7 +163,10 @@ describe("multi_select_no_bar_series", function () {
type: "bi.multi_select_no_bar_combo", type: "bi.multi_select_no_bar_combo",
width: 220, width: 220,
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
callback(items); callback({
items: items,
hasNext: false
});
}, },
value: [1, 2] value: [1, 2]
}); });

7
src/widget/multiselectlist/__test__/multiselectlist.insert.test.js

@ -144,6 +144,13 @@ describe("multi_list_insert_pane", function () {
type: "bi.multi_select_insert_list", type: "bi.multi_select_insert_list",
width: 220, width: 220,
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
if (op.keywords) {
callback({
items: [],
hasNext: false
})
return;
}
callback({ callback({
items: items, items: items,
hasNext: false hasNext: false

3
src/widget/multiselectlist/multiselectlist.insert.js

@ -15,7 +15,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
BI.MultiSelectInsertList.superclass._init.apply(this, arguments); BI.MultiSelectInsertList.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = o.value || {}; this.storeValue = this._assertValue(o.value || {});
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue)); BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
@ -213,6 +213,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
val || (val = {}); val || (val = {});
val.type || (val.type = BI.Selection.Multi); val.type || (val.type = BI.Selection.Multi);
val.value || (val.value = []); val.value || (val.value = []);
return val;
}, },
_makeMap: function (values) { _makeMap: function (values) {

Loading…
Cancel
Save