Browse Source

无JIRA任务 解决单测报错

es6
windy 4 years ago
parent
commit
19adce1fdb
  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
files: [
"src/css/core/**/*.css",
"src/css/theme/**/*.css",
"src/css/base/**/*.css",
"src/css/widget/**/*.css",
"public/css/app.css",
"dist/fineui.min.css",
"src/core/foundation.js",
"src/core/lodash.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 () {
var items = BI.map(BI.makeArray(100, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
var items;
before(function () {
items = BI.map(BI.makeArray(100, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
});
});
/**
@ -77,7 +80,7 @@ describe("search_text_value_combo", function () {
BI.nextTick(function () {
BI.Test.triggerKeyDown(widget.element.find(".bi-search-text-value-trigger .bi-input"), "2", 50, 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);
widget.destroy();
done();

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

@ -18,7 +18,7 @@ describe("aliasFunctionTest", function () {
var targetString = "<a>1 2&</a>";
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);
});

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

@ -6,67 +6,71 @@
describe("multi_select_no_bar_series", function () {
var _getItemsByTimes = function (items, times) {
var res = [];
for (var i = (times - 1) * 100; items[i] && i < times * 100; i++) {
res.push(items[i]);
}
return res;
};
var _getItemsByTimes, _itemsCreator, itemSelectorGetter, searchItemSelectorGetter, _hasNextByTimes, items;
before(function () {
_getItemsByTimes = function (items, times) {
var res = [];
for (var i = (times - 1) * 100; items[i] && i < times * 100; i++) {
res.push(items[i]);
}
return res;
};
var _hasNextByTimes = function (items, times) {
return times * 100 < items.length;
};
_hasNextByTimes = function (items, times) {
return times * 100 < items.length;
};
var _itemsCreator = function (options, callback) {
var items = BI.map(BI.makeArray(100, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
});
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
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];
_itemsCreator = function (options, callback) {
var items = BI.map(BI.makeArray(100, null), function(idx, v) {
return {
text: idx,
value: idx,
title: idx
};
});
var keywords = (options.keywords || []).slice();
if (options.keyword) {
keywords.push(options.keyword);
}
BI.each(keywords, function (i, kw) {
var search = BI.Func.getSearchResult(items, kw);
items = search.match.concat(search.find);
});
}
if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) {
if (options.selectedValues) {// 过滤
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({
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) {
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 + ")";
});
};
itemSelectorGetter = function (array) {
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 + ")";
});
};
var searchItemSelectorGetter = function (array) {
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 + ")";
});
};
searchItemSelectorGetter = function (array) {
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 + ")";
});
};
})
/**
* test_author_windy
@ -159,7 +163,10 @@ describe("multi_select_no_bar_series", function () {
type: "bi.multi_select_no_bar_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
callback({
items: items,
hasNext: false
});
},
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",
width: 220,
itemsCreator: function (op, callback) {
if (op.keywords) {
callback({
items: [],
hasNext: false
})
return;
}
callback({
items: items,
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);
var self = this, o = this.options;
this.storeValue = o.value || {};
this.storeValue = this._assertValue(o.value || {});
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));
@ -213,6 +213,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
val || (val = {});
val.type || (val.type = BI.Selection.Multi);
val.value || (val.value = []);
return val;
},
_makeMap: function (values) {

Loading…
Cancel
Save