Compare commits

..

4 Commits

Author SHA1 Message Date
Zoupers.Zou-邹清原 4fc41d599e Pull request #3747: 重新打通单测流程 && 将mocha单测用例转为jest单测 8 months ago
Zoupers cfe8ce1d6c 修复单测问题 && 优化tsconfig.json配置 9 months ago
Zoupers d8448dcd38 jest流程打通,mocha用例转为jest用例,但是karma配置暂时还保留 9 months ago
Zoupers feca9ef16b karma单测配置 9 months ago
  1. 2
      .npmrc
  2. 2
      packages/demo/i18n/i18n.cn.js
  3. 1
      packages/demo/src/demo/widget/yearmonthinterval/demo.year_month_interval.js
  4. 2
      packages/fineui/.gitignore
  5. 18
      packages/fineui/bi.lessconfig.json
  6. BIN
      packages/fineui/dist/font/iconfont.eot
  7. 480
      packages/fineui/dist/font/iconfont.svg
  8. BIN
      packages/fineui/dist/font/iconfont.ttf
  9. BIN
      packages/fineui/dist/font/iconfont.woff
  10. BIN
      packages/fineui/dist/font/iconfont.woff2
  11. 51
      packages/fineui/jest.config.ts
  12. 167
      packages/fineui/karma.conf.js
  13. 40
      packages/fineui/package.json
  14. 5
      packages/fineui/src/base/collection/__test__/collection.test.js
  15. 9
      packages/fineui/src/base/combination/tab.js
  16. 18
      packages/fineui/src/base/foundation/__test__/message.test.js
  17. 4
      packages/fineui/src/base/grid/__test__/grid.test.js
  18. 6
      packages/fineui/src/base/layer/__test__/layer.popover.test.js
  19. 6
      packages/fineui/src/base/list/__test__/listview.test.js
  20. 60
      packages/fineui/src/base/single/__test__/text.test.js
  21. 10
      packages/fineui/src/base/single/a/__test__/a.test.js
  22. 22
      packages/fineui/src/base/single/button/buttons/__test__/button.test.js
  23. 32
      packages/fineui/src/base/single/button/node/__test__/icontexticonnode.test.js
  24. 32
      packages/fineui/src/base/single/button/node/__test__/icontextnode.test.js
  25. 32
      packages/fineui/src/base/single/button/node/__test__/texticonnode.test.js
  26. 32
      packages/fineui/src/base/single/button/node/__test__/textnode.test.js
  27. 10
      packages/fineui/src/base/single/html/__test__/html.test.js
  28. 4
      packages/fineui/src/base/single/iframe/__test__/iframe.test.js
  29. 8
      packages/fineui/src/base/single/img/__test__/img.test.js
  30. 9
      packages/fineui/src/base/single/input/radio/radio.js
  31. 6
      packages/fineui/src/base/single/link/__test__/link.test.js
  32. 5
      packages/fineui/src/base/tree/customtree.js
  33. 24
      packages/fineui/src/case/button/node/__test__/node.arrow.test.js
  34. 20
      packages/fineui/src/case/button/node/__test__/node.first.plus.test.js
  35. 20
      packages/fineui/src/case/button/node/__test__/node.icon.arrow.test.js
  36. 20
      packages/fineui/src/case/button/node/__test__/node.last.plus.test.js
  37. 20
      packages/fineui/src/case/button/node/__test__/node.mid.plus.test.js
  38. 24
      packages/fineui/src/case/button/node/__test__/node.multilayer.icon.arrow.test.js
  39. 20
      packages/fineui/src/case/button/node/__test__/node.plus.test.js
  40. 98
      packages/fineui/src/case/button/treeitem/__test__/item.treeleaf.test.js
  41. 14
      packages/fineui/src/case/colorchooser/__test__/colorchooser.test.js
  42. 6
      packages/fineui/src/case/colorchooser/farbtastic/__test__/farbtastic.test.js
  43. 18
      packages/fineui/src/case/combo/bubblecombo/__test__/combo.bubble.test.js
  44. 8
      packages/fineui/src/case/combo/editoriconcheckcombo/__test__/combo.editiconcheck.test.js
  45. 28
      packages/fineui/src/case/combo/iconcombo/combo.icon.js
  46. 10
      packages/fineui/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js
  47. 20
      packages/fineui/src/case/combo/searchtextvaluecombo/__test__/combo.searchtextvaluecombo.test.js
  48. 14
      packages/fineui/src/case/combo/textvaluecheckcombo/__test__/combo.textvaluecheck.test.js
  49. 18
      packages/fineui/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js
  50. 26
      packages/fineui/src/case/editor/__test__/editor.clear.test.js
  51. 18
      packages/fineui/src/case/editor/__test__/editor.sign.test.js
  52. 18
      packages/fineui/src/case/editor/__test__/editor.state.simple.test.js
  53. 18
      packages/fineui/src/case/editor/__test__/editor.state.test.js
  54. 16
      packages/fineui/src/case/loader/__test__/loader.lazy.test.js
  55. 16
      packages/fineui/src/case/loader/__test__/loader.list.test.js
  56. 40
      packages/fineui/src/case/pager/__test__/pager.test.js
  57. 8
      packages/fineui/src/case/segment/__test__/segment.test.js
  58. 1
      packages/fineui/src/case/toolbar/toolbar.multiselect.js
  59. 4
      packages/fineui/src/case/ztree/asynctree.js
  60. 10
      packages/fineui/src/component/allvaluechooser/__test__/combo.allvaluechooser.test.js
  61. 6
      packages/fineui/src/component/allvaluemultitextvaluecombo/__test__/allvalue.multitextvalue.combo.test.js
  62. 30
      packages/fineui/src/component/valuechooser/__test__/combo.valuechooser.insert.test.js
  63. 22
      packages/fineui/src/component/valuechooser/__test__/combo.valuechooser.test.js
  64. 14
      packages/fineui/src/component/valuechooser/__test__/pane.valuechooser.test.js
  65. 49
      packages/fineui/src/core/1.lodash.js
  66. 2
      packages/fineui/src/core/2.base.js
  67. 4
      packages/fineui/src/core/5.inject.js
  68. 110
      packages/fineui/src/core/__test__/alias.test.js
  69. 280
      packages/fineui/src/core/__test__/base.test.js
  70. 24
      packages/fineui/src/core/__test__/context.test.js
  71. 8
      packages/fineui/src/core/__test__/widget.test.js
  72. 11
      packages/fineui/src/core/constant/writable.var.js
  73. 6
      packages/fineui/src/core/controller/controller.broadcast.js
  74. 2
      packages/fineui/src/core/controller/controller.layer.js
  75. 38
      packages/fineui/src/core/func/__test__/date.test.js
  76. 14
      packages/fineui/src/core/func/__test__/function.test.js
  77. 10
      packages/fineui/src/core/func/__test__/string.test.js
  78. 7
      packages/fineui/src/core/func/alias.js
  79. 36
      packages/fineui/src/core/platform/web/jquery/__test__/fn.test.js
  80. 10
      packages/fineui/src/core/utils/__test__/aes.test.js
  81. 38
      packages/fineui/src/core/utils/dom.js
  82. 8
      packages/fineui/src/less/base/colorchooser/colorpicker/button.colorshow.less
  83. 16
      packages/fineui/src/less/base/single/button/button.less
  84. 2
      packages/fineui/src/less/base/single/button/switch.less
  85. 7
      packages/fineui/src/less/base/tree/ztree.less
  86. 6
      packages/fineui/src/less/core/utils/common.less
  87. 6
      packages/fineui/src/less/core/utils/list-item.less
  88. 3
      packages/fineui/src/less/lib/colors.less
  89. 4
      packages/fineui/src/less/lib/theme.less
  90. 32
      packages/fineui/src/widget/datepane/__test__/datepane.test.js
  91. 16
      packages/fineui/src/widget/datetime/__test__/datetime.test.js
  92. 32
      packages/fineui/src/widget/datetimepane/__test__/datetimepane.test.js
  93. 14
      packages/fineui/src/widget/downlist/__test__/downlist.test.js
  94. 7
      packages/fineui/src/widget/downlist/combo.downlist.js
  95. 46
      packages/fineui/src/widget/dynamicdate/__test__/dynamicdate.test.js
  96. 2
      packages/fineui/src/widget/dynamicdate/dynamicdate.card.js
  97. 28
      packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js
  98. 2
      packages/fineui/src/widget/dynamicdate/dynamicdate.param.item.js
  99. 2
      packages/fineui/src/widget/dynamicdate/dynamicdate.popup.js
  100. 46
      packages/fineui/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js
  101. Some files were not shown because too many files have changed in this diff Show More

2
.npmrc

@ -1,2 +1,2 @@
puppeteer_download_host=https://npm.taobao.org/mirrors PUPPETEER_DOWNLOAD_BASE_URL=https://cdn.npmmirror.com/binaries/chrome-for-testing
@fui:registry=https://npm.fineres.com/ @fui:registry=https://npm.fineres.com/

2
packages/demo/i18n/i18n.cn.js

@ -1,4 +1,4 @@
window.BI = {}; window.BI = window.BI || {};
window.BI.i18n = { window.BI.i18n = {
'BI-Multi_Date_Quarter_End': '季度末', 'BI-Multi_Date_Quarter_End': '季度末',
'BI-Multi_Date_Month_Begin': '月初', 'BI-Multi_Date_Month_Begin': '月初',

1
packages/demo/src/demo/widget/yearmonthinterval/demo.year_month_interval.js

@ -20,7 +20,6 @@ export class YearMonthIntervalDemo extends Widget {
ref(_ref) { ref(_ref) {
self.interval = _ref; self.interval = _ref;
}, },
format: "%Y/%X",
value: { value: {
start: { start: {
type: 2, type: 2,

2
packages/fineui/.gitignore vendored

@ -0,0 +1,2 @@
logs/*
coverage/*

18
packages/fineui/bi.lessconfig.json

@ -23,8 +23,8 @@
"@color-bi-border-disabled-radio": "rgba(9, 30, 64, 0.19)", "@color-bi-border-disabled-radio": "rgba(9, 30, 64, 0.19)",
"@color-bi-background-active-radio-content": "#2C60DB", "@color-bi-background-active-radio-content": "#2C60DB",
"@color-bi-border-checkbox-theme-dark": "rgba(255, 255, 255, 0.37)", "@color-bi-border-checkbox-theme-dark": "rgba(255, 255, 255, 0.37)",
"@color-bi-border-hover-active-radio-theme-dark": "#497FFD", "@color-bi-border-hover-active-radio-theme-dark": "#3869DC",
"@color-bi-background-active-radio-content-theme-dark": "#497FFD", "@color-bi-background-active-radio-content-theme-dark": "#3869DC",
"@color-bi-background-disabled-active-radio-content": "#FFFFFF", "@color-bi-background-disabled-active-radio-content": "#FFFFFF",
"@color-bi-background-disabled-active-radio-content-theme-dark": "#606479", "@color-bi-background-disabled-active-radio-content-theme-dark": "#606479",
"@color-bi-background-disabled-active-checkbox-content": "#FFFFFF", "@color-bi-background-disabled-active-checkbox-content": "#FFFFFF",
@ -48,17 +48,5 @@
"@font-solid-bottom": "e905", "@font-solid-bottom": "e905",
"@font-solid-right": "e906", "@font-solid-right": "e906",
"@font-dot": "e762", "@font-dot": "e762",
"@font-down-triangle": "e70b", "@font-down-triangle": "e70b"
"@color-bi-background-theme-dark": "#1B1F31",
"@border-color-light-line-theme-dark": "#30364B",
"@color-bi-background-header-background": "#F8F9FC",
"@color-bi-background-header-background-theme-dark": "#1B1F31",
"@color-bi-background-common-light-button": "#E5EFFF",
"@color-bi-background-common-light-button-theme-dark": "#0F2A62",
"@color-bi-text-highlight-theme-dark": "#497FFD",
"@color-bi-border-active-chooser-show-button-theme-dark": "#497FFD",
"@color-bi-background-button-theme-dark": "#497FFD",
"@color-bi-background-active-switch-theme-dark": "#497FFD",
"@color-bi-text-common-light-button-theme-dark": "#497FFD",
"@color-bi-text-common-light-button": "#2c60db"
} }

BIN
packages/fineui/dist/font/iconfont.eot vendored

Binary file not shown.

480
packages/fineui/dist/font/iconfont.svg vendored

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
packages/fineui/dist/font/iconfont.ttf vendored

Binary file not shown.

BIN
packages/fineui/dist/font/iconfont.woff vendored

Binary file not shown.

BIN
packages/fineui/dist/font/iconfont.woff2 vendored

Binary file not shown.

51
packages/fineui/jest.config.ts

@ -0,0 +1,51 @@
import type { Config } from "jest";
// import webpackConfig from "./webpack/webpack.dev";
export default {
// testEnvironment: "<rootDir>/test/testEnvironmentJsdom.ts",
testEnvironment: "jsdom",
testEnvironmentOptions: {
// html: fs.readFileSync(path.join(__dirname, "test/index.html")),
},
testMatch: ["<rootDir>/src/**/*.test.js"],
collectCoverage: false,
collectCoverageFrom: ["src/**/*.js", "!src/**/*.test.js"],
coverageDirectory: "coverage",
coverageReporters: ["html", "json-summary", "cobertura"],
reporters: [
"default",
[
"jest-html-reporters",
{
publicPath: "./html-report",
openReport: true,
},
],
],
transform: {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "babel-jest",
},
preset: "jest-puppeteer",
verbose: true,
watchman: true,
injectGlobals: true,
globals: {
"ts-jest": {
tsconfig: "tsconfig.json",
},
},
setupFilesAfterEnv: [
"<rootDir>/src/bundle.js",
"<rootDir>/src/core/platform/web/config.js",
"<rootDir>/../demo/i18n/i18n.cn.js",
"<rootDir>/test/utils.js",
"<rootDir>/test/prepare.js",
],
moduleNameMapper: {
"@/(.*)$": "<rootDir>/src/$1",
},
} as Config;

167
packages/fineui/karma.conf.js

@ -0,0 +1,167 @@
// Karma configuration
// Generated on Mon Nov 27 2017 11:16:26 GMT+0800 (中国标准时间)
const os = require("os");
const webpackConfig = require("./webpack/webpack.dev")
process.env.CHROME_BIN = require("puppeteer").executablePath();
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "",
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["webpack", "mocha", "chai"],
// list of files / patterns to load in the browser
files: [].concat(
webpackConfig.entry.fineui,
["test/**/*.js", "src/**/*.test.js"]
),
exclude: [
"src/base/tree/ztree/jquery.ztree.core-3.5.js",
"src/base/tree/ztree/jquery.ztree.excheck-3.5.js",
"src/base/single/input/file.js",
"src/case/loading/loading_pane.js",
"src/base/tree/ztree/**/*.js",
"src/case/tree/ztree/*.js",
"src/widget/multitree/**/*.js",
"src/widget/multiselecttree/**/*.js",
"src/component/treevaluechooser/*.js"
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"src/less/**/*.less": ["webpack"],
"ui/**/*.less": ["webpack"],
"src/*.js": ["webpack"],
"src/**/!(*.test).js": ["webpack"],
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["progress", "coverage", "html"],
browserDisconnectTolerance: 3,
browserDisconnectTimeout : 300000,
browserNoActivityTimeout : 300000,
coverageReporter: {
// specify a common output directory
dir: "coverage/",
reporters: [
// reporters not supporting the `file` property
{ type: "html", subdir: "report-html" },
{ type: "json-summary", subdir: "report-json-summary" },
{ type: "cobertura", subdir: "report-cobertura"}
]
},
htmlReporter: {
outputFile: "logs/test-report.html"
},
// web server port
port: 9878,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
loggers: [
{
type: "console"
},
{
type: "file",
filename: "logs/karma.log"
}
],
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// you can define custom flags
customLaunchers: {
HeadlessChrome: {
base: "ChromeHeadless",
flags: [
"--no-sandbox",
"--remote-debugging-port=9222",
"--enable-logging",
"--user-data-dir=./karma-chrome",
"--v=1",
"--disable-background-timer-throttling",
"--disable-renderer-backgrounding",
"--proxy-bypass-list=*",
"--disable-web-security",
"--disable-gpu",
],
},
ChromeDebug: {
base: "Chrome",
flags: [
"--no-sandbox",
"--remote-debugging-port=9222",
"--enable-logging",
"--user-data-dir=./karma-chrome",
"--v=1",
"--disable-background-timer-throttling",
"--disable-renderer-backgrounding",
"--proxy-bypass-list=*",
"--disable-web-security",
"--disable-gpu",
],
},
},
// // start these browsers
// // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [os.platform() === "win32"
&& parseFloat(os.release()
.split(".")
.slice(0, 2)
.join(".")) <= 6.1
? "HeadlessChrome" : "ChromeHeadless"],
retryLimit: 30,
captureTimeout: 30000,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
webpack: webpackConfig,
plugins: [
"karma-webpack",
"karma-mocha",
"karma-chai",
"karma-chrome-launcher",
"karma-coverage",
"karma-htmlfile-reporter",
]
});
};

40
packages/fineui/package.json

@ -30,7 +30,9 @@
"tsc": "tsc", "tsc": "tsc",
"link": "pnpm link --global", "link": "pnpm link --global",
"build:biCss": "cross-env LESS_CONFIG_PATH=bi.lessconfig.json LESS_FILE_NAME=bi npm run webpack:css", "build:biCss": "cross-env LESS_CONFIG_PATH=bi.lessconfig.json LESS_FILE_NAME=bi npm run webpack:css",
"build:jsyCss": "cross-env LESS_CONFIG_PATH=jsy.lessconfig.json LESS_FILE_NAME=jsy npm run webpack:css" "build:jsyCss": "cross-env LESS_CONFIG_PATH=jsy.lessconfig.json LESS_FILE_NAME=jsy npm run webpack:css",
"test:jest": "jest --coverage --noStackTrace --silent",
"test:karma": "karma start"
}, },
"files": [ "files": [
"dist", "dist",
@ -57,7 +59,37 @@
"jquery": "3.6.3" "jquery": "3.6.3"
}, },
"devDependencies": { "devDependencies": {
"core-js": "^3.37.1", "@babel/plugin-proposal-class-properties": "^7.18.6",
"cross-env": "^7.0.3" "@babel/plugin-proposal-decorators": "^7.24.1",
"@babel/plugin-transform-classes": "^7.24.5",
"@babel/plugin-transform-modules-commonjs": "7.6.0",
"@babel/plugin-transform-proto-to-assign": "^7.24.1",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/plugin-transform-runtime": "^7.24.3",
"@babel/preset-env": "^7.24.5",
"@babel/preset-react": "^7.24.1",
"@babel/preset-typescript": "^7.24.1",
"@babel/runtime": "7.20.1",
"@jest/environment": "^29.7.0",
"babel-jest": "^29.7.0",
"chai": "4.2.0",
"core-js": "^3.30.2",
"cross-env": "^7.0.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-environment-puppeteer": "^10.0.1",
"jest-html-reporters": "^3.1.7",
"jest-puppeteer": "^10.0.1",
"karma": "3.1.4",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.2",
"karma-htmlfile-reporter": "^0.3.8",
"karma-mocha": "1.3.0",
"karma-typescript": "^5.5.4",
"karma-webpack": "^5.0.1",
"mocha": "5.2.0",
"puppeteer": "^22.8.2",
"ts-jest": "^29.1.2"
} }
} }

5
packages/fineui/src/base/collection/__test__/collection.test.js

@ -3,12 +3,13 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/3/17 * Created by windy on 2020/3/17
*/ */
require("../../../bundle")
describe("CollectionTest", function () { describe("CollectionTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("collection", function () { it("collection", () => {
var items = []; var items = [];
var cellCount = 100; var cellCount = 100;
for (var i = 0; i < cellCount; i++) { for (var i = 0; i < cellCount; i++) {

9
packages/fineui/src/base/combination/tab.js

@ -13,8 +13,7 @@ import {
contains, contains,
any, any,
isEqual, isEqual,
LogicFactory, LogicFactory
Events,
} from "@/core"; } from "@/core";
/** /**
@ -107,11 +106,7 @@ export class Tab extends Widget {
Widget.execWithContext(this, () => { Widget.execWithContext(this, () => {
this.cardMap[v] = cardCreator(v); this.cardMap[v] = cardCreator(v);
}); });
const card = this.layout.addCardByName(v, this.cardMap[v]); this.layout.addCardByName(v, this.cardMap[v]);
card.on(Events.DESTROY, () => {
this.layout.deleteCardByName(v);
delete this.cardMap[v];
});
} }
} }

18
packages/fineui/src/base/foundation/__test__/message.test.js

@ -3,17 +3,17 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/3/9 * Created by windy on 2020/3/9
*/ */
describe("MessageTest", function () { describe("MessageTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("alert", function (done) { it("alert", done => {
BI.Msg.alert("message", "ASASASASA"); BI.Msg.alert("message", "ASASASASA");
var body = BI.Widget._renderEngine.createElement("body"); var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-message-depend").length).to.equal(1); expect(body.find(".bi-message-depend").length).toBe(1);
BI.nextTick(function () { BI.nextTick(function () {
body.find(".bi-message-depend .bi-button").click(); body.find(".bi-message-depend .bi-button").click();
expect(body.find(".bi-message-depend").length).to.equal(0); expect(body.find(".bi-message-depend").length).toBe(0);
done(); done();
}); });
}); });
@ -21,15 +21,15 @@ describe("MessageTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("toast_hand_close", function (done) { it("toast_hand_close", done => {
BI.Msg.toast("message", { BI.Msg.toast("message", {
autoClose: false, autoClose: false,
}); });
var body = BI.Widget._renderEngine.createElement("body"); var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-toast").length).to.equal(1); expect(body.find(".bi-toast").length).toBe(1);
BI.nextTick(function () { BI.nextTick(function () {
body.find(".bi-toast .bi-icon-button").click(); body.find(".bi-toast .bi-icon-button").click();
expect(body.find(".bi-toast").length).to.equal(0); expect(body.find(".bi-toast").length).toBe(0);
done(); done();
}); });
}); });
@ -37,9 +37,9 @@ describe("MessageTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("toast_auto_close", function () { it("toast_auto_close", () => {
BI.Msg.toast("message"); BI.Msg.toast("message");
var body = BI.Widget._renderEngine.createElement("body"); var body = BI.Widget._renderEngine.createElement("body");
expect(body.find(".bi-toast").length).to.equal(1); expect(body.find(".bi-toast").length).toBe(1);
}); });
}); });

4
packages/fineui/src/base/grid/__test__/grid.test.js

@ -3,11 +3,11 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/3/20 * Created by windy on 2020/3/20
*/ */
describe("GridTest", function () { describe("GridTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("grid", function () { it("grid", () => {
var items = []; var items = [];
var rowCount = 1000, columnCount = 100; var rowCount = 1000, columnCount = 100;
for (var i = 0; i < rowCount; i++) { for (var i = 0; i < rowCount; i++) {

6
packages/fineui/src/base/layer/__test__/layer.popover.test.js

@ -4,11 +4,11 @@
* Created by windy on 2020/3/17 * Created by windy on 2020/3/17
*/ */
describe("PopoverTest", function () { describe("PopoverTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("BarPopover", function (done) { it("BarPopover", done => {
var id = BI.UUID(); var id = BI.UUID();
BI.Popovers.remove(id); BI.Popovers.remove(id);
BI.Popovers.create(id, { BI.Popovers.create(id, {
@ -24,7 +24,7 @@ describe("PopoverTest", function () {
}, },
}).open(id); }).open(id);
BI.delay(function () { BI.delay(function () {
expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).to.equal(1); expect(BI.Widget._renderEngine.createElement("body").find(".bi-popup-view .bi-z-index-mask").length).toBe(1);
BI.Popovers.remove(id); BI.Popovers.remove(id);
done(); done();
}, 100); }, 100);

6
packages/fineui/src/base/list/__test__/listview.test.js

@ -5,11 +5,11 @@
*/ */
// TODO 展示类控件测什么没想好标记一下 // TODO 展示类控件测什么没想好标记一下
describe("ListView && VirtualList", function () { describe("ListView && VirtualList", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("ListView初始化测试", function () { it("ListView初始化测试", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.list_view", type: "bi.list_view",
el: { el: {
@ -31,7 +31,7 @@ describe("ListView && VirtualList", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("VirtualList初始化测试", function () { it("VirtualList初始化测试", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.virtual_list", type: "bi.virtual_list",
items: BI.map(BI.range(0, 100), function (i, item) { items: BI.map(BI.range(0, 100), function (i, item) {

60
packages/fineui/src/base/single/__test__/text.test.js

@ -1,54 +1,54 @@
/** /**
* Created by windy on 2018/01/23. * Created by windy on 2018/01/23.
*/ */
describe("TextTest", function () { describe("TextTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("setText", function () { it("setText", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
}); });
text.setText("AAA"); text.setText("AAA");
expect(text.element.text()).to.equal("AAA"); expect(text.element.text()).toBe("AAA");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("setStyle", function () { it("setStyle", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
}); });
text.setStyle({ "color": "red" }); text.setStyle({ "color": "red" });
expect(text.element.getStyle("color")).to.equal("rgb(255, 0, 0)"); expect(text.element.getStyle("color")).toBe("rgb(255, 0, 0)");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("高亮doHighlight", function () { it("高亮doHighlight", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "AAA", text: "AAA",
highLight: true, highLight: true,
}); });
expect(text.element.getStyle("color")).to.equal("rgb(54, 133, 242)"); expect(text.element.getStyle("color")).toBe("rgb(54, 133, 242)");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("标红doRedMark", function () { it("标红doRedMark", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "我是要标红的A", text: "我是要标红的A",
keyword: "A", keyword: "A",
}); });
expect(text.element.children(".bi-keyword-red-mark").length).to.not.equal(0); expect(text.element.children(".bi-keyword-red-mark").length).not.toBe(0);
text.destroy(); text.destroy();
}); });
@ -56,89 +56,89 @@ describe("TextTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("取消高亮undoHighlight", function () { it("取消高亮undoHighlight", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "AAA", text: "AAA",
highLight: true, highLight: true,
}); });
text.unHighLight(); text.unHighLight();
expect(text.element.getStyle("color")).to.not.equal("rgb(54, 133, 242)"); expect(text.element.getStyle("color")).not.toBe("rgb(54, 133, 242)");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("取消标红undoRedMark", function () { it("取消标红undoRedMark", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "我是要标红的A", text: "我是要标红的A",
keyword: "A", keyword: "A",
}); });
text.unRedMark(); text.unRedMark();
expect(text.element.children(".bi-keyword-red-mark").length).to.equal(0); expect(text.element.children(".bi-keyword-red-mark").length).toBe(0);
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("setValue", function () { it("setValue", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
value: "AAA", value: "AAA",
}); });
text.setValue("value"); text.setValue("value");
expect(text.element.text()).to.equal("value"); expect(text.element.text()).toBe("value");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("gap测试", function () { it("gap测试", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "我是要标红的A", text: "我是要标红的A",
vgap: 10, vgap: 10,
hgap: 10, hgap: 10,
}); });
expect(text.element.css("padding")).to.equal("10px"); expect(text.element.css("padding")).toBe("10px");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("空格测试", function () { it("空格测试", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "我是要标红的 A", text: "我是要标红的 A",
}); });
expect(text.element.text()).to.equal("我是要标红的 A"); expect(text.element.text()).toBe("我是要标红的 A");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("lineHeight和height", function () { it("lineHeight和height", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "我是A", text: "我是A",
lineHeight: 12, lineHeight: 12,
height: 24, height: 24,
}); });
expect(text.element.css("height")).to.equal("24px"); expect(text.element.css("height")).toBe("24px");
expect(text.element.css("line-height")).to.equal("12px"); expect(text.element.css("line-height")).toBe("12px");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("handler", function (done) { it("handler", done => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "我是A", text: "我是A",
@ -148,7 +148,7 @@ describe("TextTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
text.text.element.click(); text.text.element.click();
expect(text.text.element.text()).to.equal("handler"); expect(text.text.element.text()).toBe("handler");
text.destroy(); text.destroy();
done(); done();
}); });
@ -157,38 +157,38 @@ describe("TextTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("text的value属性", function () { it("text的value属性", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: "", text: "",
value: "aaaa", value: "aaaa",
}); });
expect(text.element.text()).to.equal(""); expect(text.element.text()).toBe("");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("text的value属性1", function () { it("text的value属性1", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
value: "aaaa", value: "aaaa",
}); });
expect(text.element.text()).to.equal("aaaa"); expect(text.element.text()).toBe("aaaa");
text.destroy(); text.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("text的value属性2", function () { it("text的value属性2", () => {
var text = BI.Test.createWidget({ var text = BI.Test.createWidget({
type: "bi.text", type: "bi.text",
text: null, text: null,
value: "aaaa", value: "aaaa",
}); });
expect(text.element.text()).to.equal(""); expect(text.element.text()).toBe("");
text.destroy(); text.destroy();
}); });
}); });

10
packages/fineui/src/base/single/a/__test__/a.test.js

@ -1,23 +1,23 @@
/** /**
* Created by windy on 2018/01/23. * Created by windy on 2018/01/23.
*/ */
describe("ALinkTest", function () { describe("ALinkTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("A初始化测试", function () { it("A初始化测试", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.a", type: "bi.a",
text: "CCC", text: "CCC",
}); });
expect(a.element.is("a")).to.equal(true); expect(a.element.is("a")).toBe(true);
a.destroy(); a.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("A的el测试", function () { it("A的el测试", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.a", type: "bi.a",
text: "DDD", text: "DDD",
@ -25,7 +25,7 @@ describe("ALinkTest", function () {
type: "bi.label", type: "bi.label",
}, },
}); });
expect(a.element.is("a") && a.element.hasClass("bi-label")).to.equal(true); expect(a.element.is("a") && a.element.hasClass("bi-label")).toBe(true);
a.destroy(); a.destroy();
}); });
}); });

22
packages/fineui/src/base/single/button/buttons/__test__/button.test.js

@ -1,11 +1,11 @@
/** /**
* Created by windy on 2018/01/23. * Created by windy on 2018/01/23.
*/ */
describe("ButtonTest", function () { describe("ButtonTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("Click点击触发事件", function (done) { it("Click点击触发事件", done => {
var button = BI.Test.createWidget({ var button = BI.Test.createWidget({
type: "bi.button", type: "bi.button",
text: "CCC", text: "CCC",
@ -15,7 +15,7 @@ describe("ButtonTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
button.element.click(); button.element.click();
expect(button.element.children(".bi-text").text()).to.equal("click"); expect(button.element.children(".bi-text").text()).toBe("click");
button.destroy(); button.destroy();
done(); done();
}); });
@ -25,7 +25,7 @@ describe("ButtonTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("MouseDown触发事件", function (done) { it("MouseDown触发事件", done => {
var button = BI.Test.createWidget({ var button = BI.Test.createWidget({
type: "bi.button", type: "bi.button",
text: "CCC", text: "CCC",
@ -36,7 +36,7 @@ describe("ButtonTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
button.element.mousedown(); button.element.mousedown();
expect(button.element.children(".bi-text").text()).to.equal("click"); expect(button.element.children(".bi-text").text()).toBe("click");
button.destroy(); button.destroy();
done(); done();
}); });
@ -45,7 +45,7 @@ describe("ButtonTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("MouseUp触发事件", function (done) { it("MouseUp触发事件", done => {
var button = BI.Test.createWidget({ var button = BI.Test.createWidget({
type: "bi.button", type: "bi.button",
text: "CCC", text: "CCC",
@ -57,7 +57,7 @@ describe("ButtonTest", function () {
BI.nextTick(function () { BI.nextTick(function () {
button.element.mousedown(); button.element.mousedown();
button.element.mouseup(); button.element.mouseup();
expect(button.element.children(".bi-text").text()).to.equal("click"); expect(button.element.children(".bi-text").text()).toBe("click");
button.destroy(); button.destroy();
done(); done();
}); });
@ -66,7 +66,7 @@ describe("ButtonTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("doubleClick触发事件", function (done) { it("doubleClick触发事件", done => {
var button = BI.Test.createWidget({ var button = BI.Test.createWidget({
type: "bi.button", type: "bi.button",
text: "CCC", text: "CCC",
@ -77,7 +77,7 @@ describe("ButtonTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
button.element.dblclick(); button.element.dblclick();
expect(button.element.children(".bi-text").text()).to.equal("click"); expect(button.element.children(".bi-text").text()).toBe("click");
button.destroy(); button.destroy();
done(); done();
}); });
@ -86,7 +86,7 @@ describe("ButtonTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("LongClick触发事件", function (done) { it("LongClick触发事件", done => {
var clickNum = 0; var clickNum = 0;
var button = BI.Test.createWidget({ var button = BI.Test.createWidget({
type: "bi.button", type: "bi.button",
@ -102,7 +102,7 @@ describe("ButtonTest", function () {
BI.nextTick(function () { BI.nextTick(function () {
button.element.mousedown(); button.element.mousedown();
BI.delay(function () { BI.delay(function () {
expect(clickNum).to.equal(2); expect(clickNum).toBe(2);
button.destroy(); button.destroy();
done(); done();
}, 360); }, 360);

32
packages/fineui/src/base/single/button/node/__test__/icontexticonnode.test.js

@ -3,88 +3,88 @@
* @date 2020/4/21 * @date 2020/4/21
*/ */
describe("IconTextIconNodeTest", function () { describe("IconTextIconNodeTest", () => {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", () => {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
}); });
iconTextIconNode.setText("AAA"); iconTextIconNode.setText("AAA");
expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).toBe("AAA");
iconTextIconNode.destroy(); iconTextIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getText", function () { it("getText", () => {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
text: "AAA", text: "AAA",
}); });
expect(iconTextIconNode.getText()).to.equal("AAA"); expect(iconTextIconNode.getText()).toBe("AAA");
iconTextIconNode.destroy(); iconTextIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setValue", function () { it("setValue", () => {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
}); });
iconTextIconNode.setValue("AAA"); iconTextIconNode.setValue("AAA");
expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).toBe("AAA");
iconTextIconNode.destroy(); iconTextIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("readonly下的setValue", function () { it("readonly下的setValue", () => {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
value: "AAA", value: "AAA",
readonly: true, readonly: true,
}); });
iconTextIconNode.setValue("BBB"); iconTextIconNode.setValue("BBB");
expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextIconNode.element.find(".bi-text").text()).toBe("AAA");
iconTextIconNode.destroy(); iconTextIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getValue", function () { it("getValue", () => {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
value: "AAA", value: "AAA",
}); });
expect(iconTextIconNode.getValue()).to.equal("AAA"); expect(iconTextIconNode.getValue()).toBe("AAA");
iconTextIconNode.destroy(); iconTextIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("doRedMark和unRedMark", function () { it("doRedMark和unRedMark", () => {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
iconTextIconNode.doRedMark("AAA"); iconTextIconNode.doRedMark("AAA");
expect(iconTextIconNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(iconTextIconNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
iconTextIconNode.unRedMark(); iconTextIconNode.unRedMark();
expect(iconTextIconNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(iconTextIconNode.element.find(".bi-keyword-red-mark").length).toBe(0);
iconTextIconNode.destroy(); iconTextIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("Click点击触发事件", function (done) { it("Click点击触发事件", done => {
var iconTextIconNode = BI.Test.createWidget({ var iconTextIconNode = BI.Test.createWidget({
type: "bi.icon_text_icon_node", type: "bi.icon_text_icon_node",
text: "AAA", text: "AAA",
@ -94,7 +94,7 @@ describe("IconTextIconNodeTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
iconTextIconNode.element.click(); iconTextIconNode.element.click();
expect(iconTextIconNode.element.find(".bi-text").text()).to.equal("click"); expect(iconTextIconNode.element.find(".bi-text").text()).toBe("click");
iconTextIconNode.destroy(); iconTextIconNode.destroy();
done(); done();
}); });

32
packages/fineui/src/base/single/button/node/__test__/icontextnode.test.js

@ -3,88 +3,88 @@
* @date 2020/4/21 * @date 2020/4/21
*/ */
describe("IconTextNodeTest", function () { describe("IconTextNodeTest", () => {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", () => {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
}); });
iconTextNode.setText("AAA"); iconTextNode.setText("AAA");
expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextNode.element.find(".bi-text").text()).toBe("AAA");
iconTextNode.destroy(); iconTextNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getText", function () { it("getText", () => {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
text: "AAA", text: "AAA",
}); });
expect(iconTextNode.getText()).to.equal("AAA"); expect(iconTextNode.getText()).toBe("AAA");
iconTextNode.destroy(); iconTextNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setValue", function () { it("setValue", () => {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
}); });
iconTextNode.setValue("AAA"); iconTextNode.setValue("AAA");
expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextNode.element.find(".bi-text").text()).toBe("AAA");
iconTextNode.destroy(); iconTextNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("readonly下的setValue", function () { it("readonly下的setValue", () => {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
value: "AAA", value: "AAA",
readonly: true, readonly: true,
}); });
iconTextNode.setValue("BBB"); iconTextNode.setValue("BBB");
expect(iconTextNode.element.find(".bi-text").text()).to.equal("AAA"); expect(iconTextNode.element.find(".bi-text").text()).toBe("AAA");
iconTextNode.destroy(); iconTextNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getValue", function () { it("getValue", () => {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
value: "AAA", value: "AAA",
}); });
expect(iconTextNode.getValue()).to.equal("AAA"); expect(iconTextNode.getValue()).toBe("AAA");
iconTextNode.destroy(); iconTextNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("doRedMark和unRedMark", function () { it("doRedMark和unRedMark", () => {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
iconTextNode.doRedMark("AAA"); iconTextNode.doRedMark("AAA");
expect(iconTextNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(iconTextNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
iconTextNode.unRedMark(); iconTextNode.unRedMark();
expect(iconTextNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(iconTextNode.element.find(".bi-keyword-red-mark").length).toBe(0);
iconTextNode.destroy(); iconTextNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("Click点击触发事件", function (done) { it("Click点击触发事件", done => {
var iconTextNode = BI.Test.createWidget({ var iconTextNode = BI.Test.createWidget({
type: "bi.icon_text_node", type: "bi.icon_text_node",
text: "AAA", text: "AAA",
@ -94,7 +94,7 @@ describe("IconTextNodeTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
iconTextNode.element.click(); iconTextNode.element.click();
expect(iconTextNode.element.find(".bi-text").text()).to.equal("click"); expect(iconTextNode.element.find(".bi-text").text()).toBe("click");
iconTextNode.destroy(); iconTextNode.destroy();
done(); done();
}); });

32
packages/fineui/src/base/single/button/node/__test__/texticonnode.test.js

@ -3,88 +3,88 @@
* @date 2020/4/21 * @date 2020/4/21
*/ */
describe("TextIconNodeTest", function () { describe("TextIconNodeTest", () => {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", () => {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
}); });
textIconNode.setText("AAA"); textIconNode.setText("AAA");
expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(textIconNode.element.find(".bi-text").text()).toBe("AAA");
textIconNode.destroy(); textIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getText", function () { it("getText", () => {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
text: "AAA", text: "AAA",
}); });
expect(textIconNode.getText()).to.equal("AAA"); expect(textIconNode.getText()).toBe("AAA");
textIconNode.destroy(); textIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setValue", function () { it("setValue", () => {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
}); });
textIconNode.setValue("AAA"); textIconNode.setValue("AAA");
expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(textIconNode.element.find(".bi-text").text()).toBe("AAA");
textIconNode.destroy(); textIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("readonly下的setValue", function () { it("readonly下的setValue", () => {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
value: "AAA", value: "AAA",
readonly: true, readonly: true,
}); });
textIconNode.setValue("BBB"); textIconNode.setValue("BBB");
expect(textIconNode.element.find(".bi-text").text()).to.equal("AAA"); expect(textIconNode.element.find(".bi-text").text()).toBe("AAA");
textIconNode.destroy(); textIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getValue", function () { it("getValue", () => {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
value: "AAA", value: "AAA",
}); });
expect(textIconNode.getValue()).to.equal("AAA"); expect(textIconNode.getValue()).toBe("AAA");
textIconNode.destroy(); textIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("doRedMark和unRedMark", function () { it("doRedMark和unRedMark", () => {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
textIconNode.doRedMark("AAA"); textIconNode.doRedMark("AAA");
expect(textIconNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textIconNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textIconNode.unRedMark(); textIconNode.unRedMark();
expect(textIconNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textIconNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textIconNode.destroy(); textIconNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("Click点击触发事件", function (done) { it("Click点击触发事件", done => {
var textIconNode = BI.Test.createWidget({ var textIconNode = BI.Test.createWidget({
type: "bi.text_icon_node", type: "bi.text_icon_node",
text: "AAA", text: "AAA",
@ -94,7 +94,7 @@ describe("TextIconNodeTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
textIconNode.element.click(); textIconNode.element.click();
expect(textIconNode.element.find(".bi-text").text()).to.equal("click"); expect(textIconNode.element.find(".bi-text").text()).toBe("click");
textIconNode.destroy(); textIconNode.destroy();
done(); done();
}); });

32
packages/fineui/src/base/single/button/node/__test__/textnode.test.js

@ -3,89 +3,89 @@
* @date 2020/4/21 * @date 2020/4/21
*/ */
describe("TextNodeTest", function () { describe("TextNodeTest", () => {
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setText", function () { it("setText", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
}); });
textNode.setText("AAA"); textNode.setText("AAA");
expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); expect(textNode.element.children(".bi-text").text()).toBe("AAA");
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getText", function () { it("getText", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
text: "AAA", text: "AAA",
whiteSpace: "normal", whiteSpace: "normal",
}); });
expect(textNode.getText()).to.equal("AAA"); expect(textNode.getText()).toBe("AAA");
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("setValue", function () { it("setValue", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
}); });
textNode.setValue("AAA"); textNode.setValue("AAA");
expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); expect(textNode.element.children(".bi-text").text()).toBe("AAA");
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("readonly下的setValue", function () { it("readonly下的setValue", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
value: "AAA", value: "AAA",
readonly: true, readonly: true,
}); });
textNode.setValue("BBB"); textNode.setValue("BBB");
expect(textNode.element.children(".bi-text").text()).to.equal("AAA"); expect(textNode.element.children(".bi-text").text()).toBe("AAA");
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("getValue", function () { it("getValue", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
value: "AAA", value: "AAA",
}); });
expect(textNode.getValue()).to.equal("AAA"); expect(textNode.getValue()).toBe("AAA");
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("doRedMark和unRedMark", function () { it("doRedMark和unRedMark", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
textNode.doRedMark("AAA"); textNode.doRedMark("AAA");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textNode.unRedMark(); textNode.unRedMark();
expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
*/ */
it("Click点击触发事件", function (done) { it("Click点击触发事件", done => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.text_node", type: "bi.text_node",
text: "AAA", text: "AAA",
@ -95,7 +95,7 @@ describe("TextNodeTest", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
textNode.element.click(); textNode.element.click();
expect(textNode.element.children(".bi-text").text()).to.equal("click"); expect(textNode.element.children(".bi-text").text()).toBe("click");
textNode.destroy(); textNode.destroy();
done(); done();
}); });

10
packages/fineui/src/base/single/html/__test__/html.test.js

@ -4,16 +4,16 @@
* Created by windy on 2020/3/10 * Created by windy on 2020/3/10
*/ */
describe("HtmlTest", function () { describe("HtmlTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("html_h1", function () { it("html_h1", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.html", type: "bi.html",
text: "<h1>在bi.html标签中使用html原生标签</h1>", text: "<h1>在bi.html标签中使用html原生标签</h1>",
}); });
expect(a.element.find("h1").length).to.equal(1); expect(a.element.find("h1").length).toBe(1);
a.destroy(); a.destroy();
}); });
@ -21,7 +21,7 @@ describe("HtmlTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("html测试属性方法", function () { it("html测试属性方法", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.html", type: "bi.html",
text: "<h1>在bi.html标签中使用html原生标签</h1>", text: "<h1>在bi.html标签中使用html原生标签</h1>",
@ -35,7 +35,7 @@ describe("HtmlTest", function () {
}); });
a.setValue("DDDDD"); a.setValue("DDDDD");
a.setStyle({ "background-color": "red" }); a.setStyle({ "background-color": "red" });
expect(a.text.element.css("background-color")).to.equal("rgb(255, 0, 0)"); expect(a.text.element.css("background-color")).toBe("rgb(255, 0, 0)");
a.destroy(); a.destroy();
}); });
}); });

4
packages/fineui/src/base/single/iframe/__test__/iframe.test.js

@ -4,11 +4,11 @@
* Created by windy on 2020/3/17 * Created by windy on 2020/3/17
*/ */
describe("IframeTest", function () { describe("IframeTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("directionPager", function () { it("directionPager", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.iframe", type: "bi.iframe",
}); });

8
packages/fineui/src/base/single/img/__test__/img.test.js

@ -4,19 +4,19 @@
* Created by windy on 2020/3/17 * Created by windy on 2020/3/17
*/ */
describe("ImgTest", function () { describe("ImgTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("img", function () { it("img", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.img", type: "bi.img",
iconWidth: 36, iconWidth: 36,
iconHeight: 36, iconHeight: 36,
}); });
a.setSrc("test.png"); a.setSrc("test.png");
expect(a.element.attr("src")).to.equal("test.png"); expect(a.element.attr("src")).toBe("test.png");
expect(a.getSrc()).to.equal("test.png"); expect(a.getSrc()).toBe("test.png");
a.destroy(); a.destroy();
}); });
}); });

9
packages/fineui/src/base/single/input/radio/radio.js

@ -56,4 +56,13 @@ export class Radio extends BasicButton {
this.fireEvent(Radio.EVENT_CHANGE); this.fireEvent(Radio.EVENT_CHANGE);
} }
} }
setSelected(b) {
super.setSelected(b);
if (b) {
this.radio.element.addClass("bi-high-light-background");
} else {
this.radio.element.removeClass("bi-high-light-background");
}
}
} }

6
packages/fineui/src/base/single/link/__test__/link.test.js

@ -4,15 +4,15 @@
* Created by windy on 2020/3/17 * Created by windy on 2020/3/17
*/ */
describe("LinkTest", function () { describe("LinkTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("link", function () { it("link", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.link", type: "bi.link",
}); });
expect(a.element.is("a")).to.equal(true); expect(a.element.is("a")).toBe(true);
a.destroy(); a.destroy();
}); });
}); });

5
packages/fineui/src/base/tree/customtree.js

@ -16,8 +16,7 @@ import {
isNull, isNull,
createWidget, createWidget,
Controller, Controller,
Events, Events
omit,
} from "@/core"; } from "@/core";
/** /**
@ -105,7 +104,7 @@ export class CustomTree extends Widget {
return itemsCreator.apply(this, args); return itemsCreator.apply(this, args);
}; };
isNull(item.popup.el) && (item.popup.el = deepClone(omit(this.options.el, "node"))); isNull(item.popup.el) && (item.popup.el = deepClone(this.options.el));
item.popup.el.node = item.el; item.popup.el.node = item.el;
items.push(item); items.push(item);
} else { } else {

24
packages/fineui/src/case/button/node/__test__/node.arrow.test.js

@ -3,38 +3,38 @@
* @date 2020/5/12 * @date 2020/5/12
*/ */
describe("test node.arrow", function () { describe("test node.arrow", () => {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doRedMark 和 unRedMark", function () { it("doRedMark 和 unRedMark", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.arrow_group_node", type: "bi.arrow_group_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
widget.doRedMark("AAA"); widget.doRedMark("AAA");
expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).not.toBe(0);
widget.unRedMark(); widget.unRedMark();
expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).toBe(0);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doClick", function (done) { it("doClick", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.arrow_group_node", type: "bi.arrow_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".expander-down-font").length).to.not.equal(0); expect(widget.element.find(".expander-down-font").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".expander-right-font").length).to.not.equal(0); expect(widget.element.find(".expander-right-font").length).not.toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -45,18 +45,18 @@ describe("test node.arrow", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("点击图标", function (done) { it("点击图标", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.arrow_group_node", type: "bi.arrow_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".expander-down-font").length).to.not.equal(0); expect(widget.element.find(".expander-down-font").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".expander-right-font").length).to.not.equal(0); expect(widget.element.find(".expander-right-font").length).not.toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -67,13 +67,13 @@ describe("test node.arrow", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("setText", function () { it("setText", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.arrow_group_node", type: "bi.arrow_group_node",
text: "AAA", text: "AAA",
}); });
widget.setText("BBB"); widget.setText("BBB");
expect(widget.element.find(".bi-text").text()).to.equal("BBB"); expect(widget.element.find(".bi-text").text()).toBe("BBB");
widget.destroy(); widget.destroy();
}); });
}); });

20
packages/fineui/src/case/button/node/__test__/node.first.plus.test.js

@ -3,38 +3,38 @@
* @date 2020/5/12 * @date 2020/5/12
*/ */
describe("test node.first.plus", function () { describe("test node.first.plus", () => {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doRedMark 和 unRedMark", function () { it("doRedMark 和 unRedMark", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.first_plus_group_node", type: "bi.first_plus_group_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
widget.doRedMark("AAA"); widget.doRedMark("AAA");
expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).not.toBe(0);
widget.unRedMark(); widget.unRedMark();
expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).toBe(0);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doClick", function (done) { it("doClick", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.first_plus_group_node", type: "bi.first_plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type2").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type2").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type2").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type2").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -45,18 +45,18 @@ describe("test node.first.plus", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("点击图标", function (done) { it("点击图标", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.first_plus_group_node", type: "bi.first_plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type2").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type2").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type2").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type2").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });

20
packages/fineui/src/case/button/node/__test__/node.icon.arrow.test.js

@ -3,38 +3,38 @@
* @date 2020/5/12 * @date 2020/5/12
*/ */
describe("test node.icon.arrow", function () { describe("test node.icon.arrow", () => {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doRedMark 和 unRedMark", function () { it("doRedMark 和 unRedMark", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.icon_arrow_node", type: "bi.icon_arrow_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
widget.doRedMark("AAA"); widget.doRedMark("AAA");
expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).not.toBe(0);
widget.unRedMark(); widget.unRedMark();
expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).toBe(0);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doClick", function (done) { it("doClick", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.icon_arrow_node", type: "bi.icon_arrow_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".expander-down-font").length).to.not.equal(0); expect(widget.element.find(".expander-down-font").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".expander-right-font").length).to.not.equal(0); expect(widget.element.find(".expander-right-font").length).not.toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -45,18 +45,18 @@ describe("test node.icon.arrow", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("点击图标", function (done) { it("点击图标", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.icon_arrow_node", type: "bi.icon_arrow_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".expander-down-font").length).to.not.equal(0); expect(widget.element.find(".expander-down-font").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".expander-right-font").length).to.not.equal(0); expect(widget.element.find(".expander-right-font").length).not.toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });

20
packages/fineui/src/case/button/node/__test__/node.last.plus.test.js

@ -3,38 +3,38 @@
* @date 2020/5/12 * @date 2020/5/12
*/ */
describe("test node.last.plus", function () { describe("test node.last.plus", () => {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doRedMark 和 unRedMark", function () { it("doRedMark 和 unRedMark", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.last_plus_group_node", type: "bi.last_plus_group_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
widget.doRedMark("AAA"); widget.doRedMark("AAA");
expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).not.toBe(0);
widget.unRedMark(); widget.unRedMark();
expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).toBe(0);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doClick", function (done) { it("doClick", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.last_plus_group_node", type: "bi.last_plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type4").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type4").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type4").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type4").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -45,18 +45,18 @@ describe("test node.last.plus", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("点击图标", function (done) { it("点击图标", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.last_plus_group_node", type: "bi.last_plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type4").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type4").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type4").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type4").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });

20
packages/fineui/src/case/button/node/__test__/node.mid.plus.test.js

@ -3,38 +3,38 @@
* @date 2020/5/12 * @date 2020/5/12
*/ */
describe("test node.mid.plus", function () { describe("test node.mid.plus", () => {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doRedMark 和 unRedMark", function () { it("doRedMark 和 unRedMark", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.mid_plus_group_node", type: "bi.mid_plus_group_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
widget.doRedMark("AAA"); widget.doRedMark("AAA");
expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).not.toBe(0);
widget.unRedMark(); widget.unRedMark();
expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).toBe(0);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doClick", function (done) { it("doClick", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.mid_plus_group_node", type: "bi.mid_plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type3").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type3").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type3").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type3").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -45,18 +45,18 @@ describe("test node.mid.plus", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("点击图标", function (done) { it("点击图标", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.mid_plus_group_node", type: "bi.mid_plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type3").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type3").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type3").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type3").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });

24
packages/fineui/src/case/button/node/__test__/node.multilayer.icon.arrow.test.js

@ -3,44 +3,44 @@
* @date 2020/5/12 * @date 2020/5/12
*/ */
describe("test node.multilayer.icon.arrow", function () { describe("test node.multilayer.icon.arrow", () => {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doRedMark 和 unRedMark", function () { it("doRedMark 和 unRedMark", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.multilayer_icon_arrow_node", type: "bi.multilayer_icon_arrow_node",
text: "要标红的AAA", text: "要标红的AAA",
layer: 3, layer: 3,
}); });
expect(widget.isOnce()).to.equal(true); expect(widget.isOnce()).toBe(true);
widget.doRedMark("AAA"); widget.doRedMark("AAA");
expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).not.toBe(0);
widget.unRedMark(); widget.unRedMark();
expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).toBe(0);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("isSelected 和 setSelected", function () { it("isSelected 和 setSelected", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.multilayer_icon_arrow_node", type: "bi.multilayer_icon_arrow_node",
text: "AAA", text: "AAA",
layer: 3, layer: 3,
}); });
widget.setSelected(true); widget.setSelected(true);
expect(widget.element.find(".active").length).to.not.equal(0); expect(widget.element.find(".active").length).not.toBe(0);
expect(widget.isSelected()).to.equal(true); expect(widget.isSelected()).toBe(true);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doClick", function (done) { it("doClick", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.multilayer_icon_arrow_node", type: "bi.multilayer_icon_arrow_node",
text: "AAA", text: "AAA",
@ -48,7 +48,7 @@ describe("test node.multilayer.icon.arrow", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.isSelected()).to.equal(true); expect(widget.isSelected()).toBe(true);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -57,7 +57,7 @@ describe("test node.multilayer.icon.arrow", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("点击图标", function (done) { it("点击图标", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.multilayer_icon_arrow_node", type: "bi.multilayer_icon_arrow_node",
text: "AAA", text: "AAA",
@ -65,7 +65,7 @@ describe("test node.multilayer.icon.arrow", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.node.element.click(); widget.node.element.click();
expect(widget.element.find(".expander-down-font").length).to.not.equal(0); expect(widget.element.find(".expander-down-font").length).not.toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });

20
packages/fineui/src/case/button/node/__test__/node.plus.test.js

@ -3,38 +3,38 @@
* @date 2020/5/12 * @date 2020/5/12
*/ */
describe("test node.plus", function () { describe("test node.plus", () => {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doRedMark 和 unRedMark", function () { it("doRedMark 和 unRedMark", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.plus_group_node", type: "bi.plus_group_node",
text: "要标红的AAA", text: "要标红的AAA",
}); });
widget.doRedMark("AAA"); widget.doRedMark("AAA");
expect(widget.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).not.toBe(0);
widget.unRedMark(); widget.unRedMark();
expect(widget.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(widget.element.find(".bi-keyword-red-mark").length).toBe(0);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("doClick", function (done) { it("doClick", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.plus_group_node", type: "bi.plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type1").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type1").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.click(); widget.element.click();
expect(widget.element.find(".tree-expand-icon-type1").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type1").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });
@ -45,18 +45,18 @@ describe("test node.plus", function () {
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("点击图标", function (done) { it("点击图标", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.plus_group_node", type: "bi.plus_group_node",
text: "AAA", text: "AAA",
}); });
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type1").length).to.not.equal(0); expect(widget.element.find(".tree-expand-icon-type1").length).not.toBe(0);
BI.delay(function () { BI.delay(function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.checkbox.element.click(); widget.checkbox.element.click();
expect(widget.element.find(".tree-expand-icon-type1").length).to.equal(0); expect(widget.element.find(".tree-expand-icon-type1").length).toBe(0);
widget.destroy(); widget.destroy();
done(); done();
}); });

98
packages/fineui/src/case/button/treeitem/__test__/item.treeleaf.test.js

@ -3,12 +3,12 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/5/8 * Created by windy on 2020/5/8
*/ */
describe("leafTest", function () { describe("leafTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("标红与高亮", function () { it("标红与高亮", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.first_tree_leaf_item", type: "bi.first_tree_leaf_item",
id: "1", id: "1",
@ -19,27 +19,27 @@ describe("leafTest", function () {
keyword: "B" keyword: "B"
}); });
textNode.doRedMark("C"); textNode.doRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textNode.unRedMark("C"); textNode.unRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textNode.doHighLight("C"); textNode.doHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); expect(textNode.element.find(".bi-high-light").length).not.toBe(0);
textNode.unHighLight("C"); textNode.unHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.equal(0); expect(textNode.element.find(".bi-high-light").length).toBe(0);
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("function", function () { it("function", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.first_tree_leaf_item", type: "bi.first_tree_leaf_item",
id: "1", id: "1",
pId: "-1" pId: "-1"
}); });
expect(textNode.getId()).to.equal("1"); expect(textNode.getId()).toBe("1");
expect(textNode.getPId()).to.equal("-1"); expect(textNode.getPId()).toBe("-1");
textNode.destroy(); textNode.destroy();
}); });
@ -47,7 +47,7 @@ describe("leafTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("标红与高亮1", function () { it("标红与高亮1", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.last_tree_leaf_item", type: "bi.last_tree_leaf_item",
id: "1", id: "1",
@ -58,27 +58,27 @@ describe("leafTest", function () {
keyword: "B" keyword: "B"
}); });
textNode.doRedMark("C"); textNode.doRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textNode.unRedMark("C"); textNode.unRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textNode.doHighLight("C"); textNode.doHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); expect(textNode.element.find(".bi-high-light").length).not.toBe(0);
textNode.unHighLight("C"); textNode.unHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.equal(0); expect(textNode.element.find(".bi-high-light").length).toBe(0);
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("function1", function () { it("function1", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.last_tree_leaf_item", type: "bi.last_tree_leaf_item",
id: "1", id: "1",
pId: "-1" pId: "-1"
}); });
expect(textNode.getId()).to.equal("1"); expect(textNode.getId()).toBe("1");
expect(textNode.getPId()).to.equal("-1"); expect(textNode.getPId()).toBe("-1");
textNode.destroy(); textNode.destroy();
}); });
@ -86,7 +86,7 @@ describe("leafTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("标红与高亮12", function () { it("标红与高亮12", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.mid_tree_leaf_item", type: "bi.mid_tree_leaf_item",
id: "1", id: "1",
@ -97,34 +97,34 @@ describe("leafTest", function () {
keyword: "B" keyword: "B"
}); });
textNode.doRedMark("C"); textNode.doRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textNode.unRedMark("C"); textNode.unRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textNode.doHighLight("C"); textNode.doHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); expect(textNode.element.find(".bi-high-light").length).not.toBe(0);
textNode.unHighLight("C"); textNode.unHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.equal(0); expect(textNode.element.find(".bi-high-light").length).toBe(0);
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("function12", function () { it("function12", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.mid_tree_leaf_item", type: "bi.mid_tree_leaf_item",
id: "1", id: "1",
pId: "-1" pId: "-1"
}); });
expect(textNode.getId()).to.equal("1"); expect(textNode.getId()).toBe("1");
expect(textNode.getPId()).to.equal("-1"); expect(textNode.getPId()).toBe("-1");
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("标红与高亮123", function () { it("标红与高亮123", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.icon_tree_leaf_item", type: "bi.icon_tree_leaf_item",
id: "1", id: "1",
@ -135,27 +135,27 @@ describe("leafTest", function () {
keyword: "B" keyword: "B"
}); });
textNode.doRedMark("C"); textNode.doRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textNode.unRedMark("C"); textNode.unRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textNode.doHighLight("C"); textNode.doHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); expect(textNode.element.find(".bi-high-light").length).not.toBe(0);
textNode.unHighLight("C"); textNode.unHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.equal(0); expect(textNode.element.find(".bi-high-light").length).toBe(0);
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("function123", function () { it("function123", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.icon_tree_leaf_item", type: "bi.icon_tree_leaf_item",
id: "1", id: "1",
pId: "-1" pId: "-1"
}); });
expect(textNode.getId()).to.equal("1"); expect(textNode.getId()).toBe("1");
expect(textNode.getPId()).to.equal("-1"); expect(textNode.getPId()).toBe("-1");
textNode.destroy(); textNode.destroy();
}); });
@ -163,7 +163,7 @@ describe("leafTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("标红与高亮1234", function () { it("标红与高亮1234", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.multilayer_icon_tree_leaf_item", type: "bi.multilayer_icon_tree_leaf_item",
id: "1", id: "1",
@ -174,27 +174,27 @@ describe("leafTest", function () {
keyword: "B" keyword: "B"
}); });
textNode.doRedMark("C"); textNode.doRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textNode.unRedMark("C"); textNode.unRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textNode.doHighLight("C"); textNode.doHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); expect(textNode.element.find(".bi-high-light").length).not.toBe(0);
textNode.unHighLight("C"); textNode.unHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.equal(0); expect(textNode.element.find(".bi-high-light").length).toBe(0);
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("function1234", function () { it("function1234", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.multilayer_icon_tree_leaf_item", type: "bi.multilayer_icon_tree_leaf_item",
id: "1", id: "1",
pId: "-1" pId: "-1"
}); });
expect(textNode.getId()).to.equal("1"); expect(textNode.getId()).toBe("1");
expect(textNode.getPId()).to.equal("-1"); expect(textNode.getPId()).toBe("-1");
textNode.destroy(); textNode.destroy();
}); });
@ -202,7 +202,7 @@ describe("leafTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("标红与高亮12345", function () { it("标红与高亮12345", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.tree_text_leaf_item", type: "bi.tree_text_leaf_item",
id: "1", id: "1",
@ -213,27 +213,27 @@ describe("leafTest", function () {
keyword: "B" keyword: "B"
}); });
textNode.doRedMark("C"); textNode.doRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.not.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).not.toBe(0);
textNode.unRedMark("C"); textNode.unRedMark("C");
expect(textNode.element.find(".bi-keyword-red-mark").length).to.equal(0); expect(textNode.element.find(".bi-keyword-red-mark").length).toBe(0);
textNode.doHighLight("C"); textNode.doHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.not.equal(0); expect(textNode.element.find(".bi-high-light").length).not.toBe(0);
textNode.unHighLight("C"); textNode.unHighLight("C");
expect(textNode.element.find(".bi-high-light").length).to.equal(0); expect(textNode.element.find(".bi-high-light").length).toBe(0);
textNode.destroy(); textNode.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("function12345", function () { it("function12345", () => {
var textNode = BI.Test.createWidget({ var textNode = BI.Test.createWidget({
type: "bi.tree_text_leaf_item", type: "bi.tree_text_leaf_item",
id: "1", id: "1",
pId: "-1" pId: "-1"
}); });
expect(textNode.getId()).to.equal("1"); expect(textNode.getId()).toBe("1");
expect(textNode.getPId()).to.equal("-1"); expect(textNode.getPId()).toBe("-1");
textNode.destroy(); textNode.destroy();
}); });

14
packages/fineui/src/case/colorchooser/__test__/colorchooser.test.js

@ -4,25 +4,25 @@
* Created by windy on 2020/3/3 * Created by windy on 2020/3/3
*/ */
describe("color_chooser_test", function () { describe("color_chooser_test", () => {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
height: 24 height: 24
}); });
widget.setValue("#69821b"); widget.setValue("#69821b");
expect(widget.getValue()).to.equal("#69821b"); expect(widget.getValue()).toBe("#69821b");
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
**/ **/
it("点选选值", function (done) { it("点选选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
height: 24 height: 24
@ -31,7 +31,7 @@ describe("color_chooser_test", function () {
BI.delay(function () { BI.delay(function () {
// 等300ms, button有debounce // 等300ms, button有debounce
widget.element.find(".bi-color-picker .bi-color-picker-button:nth-child(3)").click(); widget.element.find(".bi-color-picker .bi-color-picker-button:nth-child(3)").click();
expect(widget.getValue()).to.equal("#e5e5e5"); expect(widget.getValue()).toBe("#e5e5e5");
widget.destroy(); widget.destroy();
done(); done();
}, 300); }, 300);
@ -40,13 +40,13 @@ describe("color_chooser_test", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("默认值", function () { it("默认值", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.color_chooser", type: "bi.color_chooser",
height: 24, height: 24,
value: "#69821b" value: "#69821b"
}); });
expect(widget.getValue()).to.equal("#69821b"); expect(widget.getValue()).toBe("#69821b");
widget.destroy(); widget.destroy();
}); });
}); });

6
packages/fineui/src/case/colorchooser/farbtastic/__test__/farbtastic.test.js

@ -3,19 +3,19 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/3/20 * Created by windy on 2020/3/20
*/ */
describe("FarbtasticTest", function () { describe("FarbtasticTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("Farbtastic", function () { it("Farbtastic", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.farbtastic", type: "bi.farbtastic",
height: 200, height: 200,
width: 200 width: 200
}); });
a.setValue("#d56c6c"); a.setValue("#d56c6c");
expect(a.getValue()).to.equal("#d56c6c"); expect(a.getValue()).toBe("#d56c6c");
a.destroy(); a.destroy();
}); });
}); });

18
packages/fineui/src/case/combo/bubblecombo/__test__/combo.bubble.test.js

@ -4,12 +4,12 @@
* Created by windy on 2020/3/2 * Created by windy on 2020/3/2
*/ */
describe("bubble_combo", function () { describe("bubble_combo", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试弹出收起", function (done) { it("测试弹出收起", done => {
var bubbleCombo = BI.Test.createWidget({ var bubbleCombo = BI.Test.createWidget({
type: "bi.bubble_combo", type: "bi.bubble_combo",
el: { el: {
@ -34,7 +34,7 @@ describe("bubble_combo", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
bubbleCombo.element.find(".bi-button").click(); bubbleCombo.element.find(".bi-button").click();
expect(bubbleCombo.element.find(".bi-bubble-popup-view").css("display")).to.equal("block"); expect(bubbleCombo.element.find(".bi-bubble-popup-view").css("display")).toBe("block");
bubbleCombo.destroy(); bubbleCombo.destroy();
done(); done();
}) })
@ -43,7 +43,7 @@ describe("bubble_combo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试弹出收起", function (done) { it("测试弹出收起", done => {
var bubbleCombo = BI.Test.createWidget({ var bubbleCombo = BI.Test.createWidget({
type: "bi.bubble_combo", type: "bi.bubble_combo",
el: { el: {
@ -68,7 +68,7 @@ describe("bubble_combo", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
bubbleCombo.element.find(".bi-button").click(); bubbleCombo.element.find(".bi-button").click();
expect(bubbleCombo.element.find(".bi-bubble-popup-view").css("display")).to.equal("block"); expect(bubbleCombo.element.find(".bi-bubble-popup-view").css("display")).toBe("block");
bubbleCombo.destroy(); bubbleCombo.destroy();
done(); done();
}) })
@ -78,7 +78,7 @@ describe("bubble_combo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("bubble_bar_popup_view", function (done) { it("bubble_bar_popup_view", done => {
var bubbleCombo = BI.Test.createWidget({ var bubbleCombo = BI.Test.createWidget({
type: "bi.bubble_combo", type: "bi.bubble_combo",
el: { el: {
@ -96,7 +96,7 @@ describe("bubble_combo", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
bubbleCombo.element.find(".bi-button").click(); bubbleCombo.element.find(".bi-button").click();
expect(bubbleCombo.element.find(".bi-text:contains(确定)").length).to.equal(1); expect(bubbleCombo.element.find(".bi-text:contains(确定)").length).toBe(1);
bubbleCombo.destroy(); bubbleCombo.destroy();
done(); done();
}) })
@ -106,7 +106,7 @@ describe("bubble_combo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("text_bubble_bar_popup_view", function (done) { it("text_bubble_bar_popup_view", done => {
var bubbleCombo = BI.Test.createWidget({ var bubbleCombo = BI.Test.createWidget({
type: "bi.bubble_combo", type: "bi.bubble_combo",
el: { el: {
@ -124,7 +124,7 @@ describe("bubble_combo", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
bubbleCombo.element.find(".bi-button").click(); bubbleCombo.element.find(".bi-button").click();
expect(bubbleCombo.element.find(".bi-text:contains(确定)").length).to.equal(1); expect(bubbleCombo.element.find(".bi-text:contains(确定)").length).toBe(1);
bubbleCombo.destroy(); bubbleCombo.destroy();
done(); done();
}) })

8
packages/fineui/src/case/combo/editoriconcheckcombo/__test__/combo.editiconcheck.test.js

@ -4,12 +4,12 @@
* Created by windy on 2020/3/2 * Created by windy on 2020/3/2
*/ */
describe("edit_icon_check_combo", function () { describe("edit_icon_check_combo", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试弹出收起", function (done) { it("测试弹出收起", done => {
var combo = BI.Test.createWidget({ var combo = BI.Test.createWidget({
type: "bi.editor_icon_check_combo", type: "bi.editor_icon_check_combo",
watermark: "默认值", watermark: "默认值",
@ -30,7 +30,7 @@ describe("edit_icon_check_combo", function () {
BI.nextTick(function () { BI.nextTick(function () {
combo.element.find(".bi-editor-trigger").click(); combo.element.find(".bi-editor-trigger").click();
combo.element.find(".bi-text-icon-popup .bi-single-select-item").click(); combo.element.find(".bi-text-icon-popup .bi-single-select-item").click();
expect(combo.getValue()[0]).to.equal("3"); expect(combo.getValue()[0]).toBe("3");
combo.populate([{ combo.populate([{
text: "MVC-1", text: "MVC-1",
value: "4" value: "4"
@ -42,7 +42,7 @@ describe("edit_icon_check_combo", function () {
value: "6" value: "6"
}]); }]);
combo.setValue("4"); combo.setValue("4");
expect(combo.getValue()[0]).to.equal("4"); expect(combo.getValue()[0]).toBe("4");
combo.destroy(); combo.destroy();
done(); done();
}) })

28
packages/fineui/src/case/combo/iconcombo/combo.icon.js

@ -8,7 +8,6 @@ export class IconCombo extends Widget {
static xtype = "bi.icon_combo"; static xtype = "bi.icon_combo";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
_defaultConfig() { _defaultConfig() {
return extend(super._defaultConfig(...arguments), { return extend(super._defaultConfig(...arguments), {
@ -56,18 +55,18 @@ export class IconCombo extends Widget {
value: o.value, value: o.value,
isShowDown: o.isShowDown, isShowDown: o.isShowDown,
}); });
this.popupEl = createWidget(o.popup, { this.popup = createWidget(o.popup, {
type: IconComboPopup.xtype, type: IconComboPopup.xtype,
chooseType: o.chooseType, chooseType: o.chooseType,
items: o.items, items: o.items,
value: o.value, value: o.value,
}); });
this.popupEl.on(IconComboPopup.EVENT_CHANGE, () => { this.popup.on(IconComboPopup.EVENT_CHANGE, () => {
this.setValue(this.popupEl.getValue()); this.setValue(this.popup.getValue());
this.iconCombo.hideView(); this.iconCombo.hideView();
this.fireEvent(IconCombo.EVENT_CHANGE); this.fireEvent(IconCombo.EVENT_CHANGE);
}); });
this.popupEl.on(Controller.EVENT_CHANGE, (...args) => { this.popup.on(Controller.EVENT_CHANGE, (...args) => {
this.fireEvent(Controller.EVENT_CHANGE, ...args); this.fireEvent(Controller.EVENT_CHANGE, ...args);
}); });
this.iconCombo = createWidget({ this.iconCombo = createWidget({
@ -83,20 +82,11 @@ export class IconCombo extends Widget {
el: this.trigger, el: this.trigger,
hideWhenAnotherComboOpen: o.hideWhenAnotherComboOpen, hideWhenAnotherComboOpen: o.hideWhenAnotherComboOpen,
popup: { popup: {
el: this.popupEl, el: this.popup,
maxWidth: o.maxWidth, maxWidth: o.maxWidth,
maxHeight: o.maxHeight, maxHeight: o.maxHeight,
minWidth: o.minWidth, minWidth: o.minWidth,
ref: (ref) => {
this.popup = ref;
},
}, },
listeners: [{
eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => {
this.fireEvent(IconCombo.EVENT_BEFORE_POPUPVIEW);
},
}],
}); });
} }
@ -110,19 +100,15 @@ export class IconCombo extends Widget {
setValue(v) { setValue(v) {
this.trigger.setValue(v); this.trigger.setValue(v);
this.popupEl.setValue(v); this.popup.setValue(v);
} }
getValue() { getValue() {
const value = this.popupEl.getValue(); const value = this.popup.getValue();
return isNull(value) ? [] : isArray(value) ? value : [value]; return isNull(value) ? [] : isArray(value) ? value : [value];
} }
getPopup() {
return this.popup;
}
populate(items) { populate(items) {
this.options.items = items; this.options.items = items;
this.iconCombo.populate(items); this.iconCombo.populate(items);

10
packages/fineui/src/case/combo/icontextvaluecombo/__test__/combo.icontextvalue.test.js

@ -4,12 +4,12 @@
* Created by windy on 2020/3/2 * Created by windy on 2020/3/2
*/ */
describe("icontextvaluecombo", function () { describe("icontextvaluecombo", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试setValue", function () { it("测试setValue", () => {
var combo = BI.Test.createWidget({ var combo = BI.Test.createWidget({
type: "bi.icon_text_value_combo", type: "bi.icon_text_value_combo",
text: "默认值", text: "默认值",
@ -30,14 +30,14 @@ describe("icontextvaluecombo", function () {
}] }]
}); });
combo.setValue(2); combo.setValue(2);
expect(combo.getValue()[0]).to.equal(2); expect(combo.getValue()[0]).toBe(2);
combo.destroy(); combo.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试populate", function () { it("测试populate", () => {
var combo = BI.Test.createWidget({ var combo = BI.Test.createWidget({
type: "bi.text_value_combo", type: "bi.text_value_combo",
text: "默认值", text: "默认值",
@ -58,7 +58,7 @@ describe("icontextvaluecombo", function () {
value: 3 value: 3
}]); }]);
combo.setValue(2); combo.setValue(2);
expect(combo.getValue()[0]).to.equal(2); expect(combo.getValue()[0]).toBe(2);
combo.destroy(); combo.destroy();
}); });
}); });

20
packages/fineui/src/case/combo/searchtextvaluecombo/__test__/combo.searchtextvaluecombo.test.js

@ -4,10 +4,10 @@
* Created by windy on 2020/3/3 * Created by windy on 2020/3/3
*/ */
describe("search_text_value_combo", function () { describe("search_text_value_combo", () => {
var items; var items;
before(function () { beforeAll(() => {
items = BI.map(BI.makeArray(100, null), function(idx, v) { items = BI.map(BI.makeArray(100, null), function(idx, v) {
return { return {
text: idx, text: idx,
@ -20,7 +20,7 @@ describe("search_text_value_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.search_text_value_combo", type: "bi.search_text_value_combo",
width: 220, width: 220,
@ -28,28 +28,28 @@ describe("search_text_value_combo", function () {
items: items items: items
}); });
widget.setValue(2); widget.setValue(2);
expect(widget.getValue()[0]).to.equal(2); expect(widget.getValue()[0]).toBe(2);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
**/ **/
it("getValue", function () { it("getValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.search_text_value_combo", type: "bi.search_text_value_combo",
width: 220, width: 220,
items: items, items: items,
value: 2 value: 2
}); });
expect(widget.getValue()[0]).to.equal(2); expect(widget.getValue()[0]).toBe(2);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
**/ **/
it("点选选值", function (done) { it("点选选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.search_text_value_combo", type: "bi.search_text_value_combo",
width: 220, width: 220,
@ -59,7 +59,7 @@ describe("search_text_value_combo", function () {
// 为什么要delay 300呢,因为按钮有debounce // 为什么要delay 300呢,因为按钮有debounce
BI.delay(function () { BI.delay(function () {
widget.element.find(".bi-single-select-item:contains(10)").click(); widget.element.find(".bi-single-select-item:contains(10)").click();
expect(widget.getValue()[0]).to.equal(10); expect(widget.getValue()[0]).toBe(10);
widget.destroy(); widget.destroy();
done(); done();
}, 300); }, 300);
@ -68,7 +68,7 @@ describe("search_text_value_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("搜索选值", function (done) { it("搜索选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.search_text_value_combo", type: "bi.search_text_value_combo",
width: 220, width: 220,
@ -81,7 +81,7 @@ describe("search_text_value_combo", 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")[0].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]).toEqual(2);
widget.destroy(); widget.destroy();
done(); done();
}); });

14
packages/fineui/src/case/combo/textvaluecheckcombo/__test__/combo.textvaluecheck.test.js

@ -4,7 +4,7 @@
* Created by windy on 2020/3/5 * Created by windy on 2020/3/5
*/ */
describe("text_value_check_combo", function () { describe("text_value_check_combo", () => {
var items = BI.map(BI.makeArray(11, null), function(idx, v) { var items = BI.map(BI.makeArray(11, null), function(idx, v) {
return { return {
@ -17,7 +17,7 @@ describe("text_value_check_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.text_value_check_combo", type: "bi.text_value_check_combo",
width: 220, width: 220,
@ -25,28 +25,28 @@ describe("text_value_check_combo", function () {
items: items items: items
}); });
widget.setValue(2); widget.setValue(2);
expect(widget.getValue()[0]).to.equal(2); expect(widget.getValue()[0]).toBe(2);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
**/ **/
it("getValue", function () { it("getValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.text_value_check_combo", type: "bi.text_value_check_combo",
width: 220, width: 220,
items: items, items: items,
value: 2 value: 2
}); });
expect(widget.getValue()[0]).to.equal(2); expect(widget.getValue()[0]).toBe(2);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
**/ **/
it("点选选值", function (done) { it("点选选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.text_value_check_combo", type: "bi.text_value_check_combo",
width: 220, width: 220,
@ -56,7 +56,7 @@ describe("text_value_check_combo", function () {
// 为什么要delay 300呢,因为按钮有debounce // 为什么要delay 300呢,因为按钮有debounce
BI.delay(function () { BI.delay(function () {
widget.element.find(".bi-single-select-item:contains(10)").click(); widget.element.find(".bi-single-select-item:contains(10)").click();
expect(widget.getValue()[0]).to.equal(10); expect(widget.getValue()[0]).toBe(10);
widget.destroy(); widget.destroy();
done(); done();
}, 300); }, 300);

18
packages/fineui/src/case/combo/textvaluecombo/__test__/combo.textvalue.test.js

@ -4,12 +4,12 @@
* Created by windy on 2020/3/2 * Created by windy on 2020/3/2
*/ */
describe("textvaluecombo", function () { describe("textvaluecombo", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试setValue", function () { it("测试setValue", () => {
var combo = BI.Test.createWidget({ var combo = BI.Test.createWidget({
type: "bi.text_value_combo", type: "bi.text_value_combo",
text: "默认值", text: "默认值",
@ -30,14 +30,14 @@ describe("textvaluecombo", function () {
}] }]
}); });
combo.setValue(2); combo.setValue(2);
expect(combo.getValue()[0]).to.equal(2); expect(combo.getValue()[0]).toBe(2);
combo.destroy(); combo.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试populate", function () { it("测试populate", () => {
var combo = BI.Test.createWidget({ var combo = BI.Test.createWidget({
type: "bi.text_value_combo", type: "bi.text_value_combo",
text: "默认值", text: "默认值",
@ -58,14 +58,14 @@ describe("textvaluecombo", function () {
value: 3 value: 3
}]); }]);
combo.setValue(2); combo.setValue(2);
expect(combo.getValue()[0]).to.equal(2); expect(combo.getValue()[0]).toBe(2);
combo.destroy(); combo.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试small_setValue", function () { it("测试small_setValue", () => {
var combo = BI.Test.createWidget({ var combo = BI.Test.createWidget({
type: "bi.small_text_value_combo", type: "bi.small_text_value_combo",
text: "默认值", text: "默认值",
@ -86,14 +86,14 @@ describe("textvaluecombo", function () {
}] }]
}); });
combo.setValue(2); combo.setValue(2);
expect(combo.getValue()[0]).to.equal(2); expect(combo.getValue()[0]).toBe(2);
combo.destroy(); combo.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试small_populate", function () { it("测试small_populate", () => {
var combo = BI.Test.createWidget({ var combo = BI.Test.createWidget({
type: "bi.small_text_value_combo", type: "bi.small_text_value_combo",
text: "默认值", text: "默认值",
@ -114,7 +114,7 @@ describe("textvaluecombo", function () {
value: 3 value: 3
}]); }]);
combo.setValue(2); combo.setValue(2);
expect(combo.getValue()[0]).to.equal(2); expect(combo.getValue()[0]).toBe(2);
combo.destroy(); combo.destroy();
}); });
}); });

26
packages/fineui/src/case/editor/__test__/editor.clear.test.js

@ -3,12 +3,12 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/5/13 * Created by windy on 2020/5/13
*/ */
describe("clear_editor", function () { describe("clear_editor", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("clear-editor", function (done) { it("clear-editor", done => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.clear_editor", type: "bi.clear_editor",
width: 300, width: 300,
@ -20,11 +20,11 @@ describe("clear_editor", function () {
} }
}); });
editor.setWaterMark("AAAAA"); editor.setWaterMark("AAAAA");
expect(editor.element.find(".bi-water-mark").text()).to.equal("AAAAA"); expect(editor.element.find(".bi-water-mark").text()).toBe("AAAAA");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.focus(); editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () {
expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).toBe("长度必须大于4");
editor.destroy(); editor.destroy();
done(); done();
}) })
@ -33,7 +33,7 @@ describe("clear_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("clear", function (done) { it("clear", done => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.clear_editor", type: "bi.clear_editor",
width: 300, width: 300,
@ -46,7 +46,7 @@ describe("clear_editor", function () {
}); });
BI.nextTick(function () { BI.nextTick(function () {
editor.element.find(".search-close-h-font").click(); editor.element.find(".search-close-h-font").click();
expect(editor.element.find(".bi-input").val()).to.equal(""); expect(editor.element.find(".bi-input").val()).toBe("");
editor.destroy(); editor.destroy();
done(); done();
}); });
@ -55,7 +55,7 @@ describe("clear_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("setValue", function () { it("setValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.clear_editor", type: "bi.clear_editor",
width: 300, width: 300,
@ -66,7 +66,7 @@ describe("clear_editor", function () {
} }
}); });
editor.setValue("12345"); editor.setValue("12345");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.destroy(); editor.destroy();
}); });
@ -74,7 +74,7 @@ describe("clear_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("getValue", function () { it("getValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.clear_editor", type: "bi.clear_editor",
width: 300, width: 300,
@ -85,14 +85,14 @@ describe("clear_editor", function () {
return this.getValue().length > 4; return this.getValue().length > 4;
} }
}); });
expect(editor.getValue()).to.equal("12346"); expect(editor.getValue()).toBe("12346");
editor.destroy(); editor.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("getValue1", function () { it("getValue1", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.clear_editor", type: "bi.clear_editor",
width: 300, width: 300,
@ -103,7 +103,7 @@ describe("clear_editor", function () {
return this.getValue().length > 4; return this.getValue().length > 4;
} }
}); });
expect(editor.getValue()).to.equal("12346 7890"); expect(editor.getValue()).toBe("12346 7890");
editor.destroy(); editor.destroy();
}); });

18
packages/fineui/src/case/editor/__test__/editor.sign.test.js

@ -3,12 +3,12 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/5/13 * Created by windy on 2020/5/13
*/ */
describe("sign_editor", function () { describe("sign_editor", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("sign-editor", function (done) { it("sign-editor", done => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
width: 300, width: 300,
@ -20,11 +20,11 @@ describe("sign_editor", function () {
} }
}); });
editor.setWaterMark("AAAAA"); editor.setWaterMark("AAAAA");
expect(editor.element.find(".bi-water-mark").text()).to.equal("AAAAA"); expect(editor.element.find(".bi-water-mark").text()).toBe("AAAAA");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.focus(); editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () {
expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).toBe("长度必须大于4");
editor.destroy(); editor.destroy();
done(); done();
}) })
@ -33,7 +33,7 @@ describe("sign_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("setValue", function () { it("setValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
width: 300, width: 300,
@ -44,7 +44,7 @@ describe("sign_editor", function () {
} }
}); });
editor.setValue("12345"); editor.setValue("12345");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.destroy(); editor.destroy();
}); });
@ -52,7 +52,7 @@ describe("sign_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("getValue", function () { it("getValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.sign_editor", type: "bi.sign_editor",
width: 300, width: 300,
@ -63,7 +63,7 @@ describe("sign_editor", function () {
return this.getValue().length > 4; return this.getValue().length > 4;
} }
}); });
expect(editor.getValue()).to.equal("12346"); expect(editor.getValue()).toBe("12346");
editor.destroy(); editor.destroy();
}); });

18
packages/fineui/src/case/editor/__test__/editor.state.simple.test.js

@ -3,12 +3,12 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/5/13 * Created by windy on 2020/5/13
*/ */
describe("simple_state_editor", function () { describe("simple_state_editor", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("state-editor", function (done) { it("state-editor", done => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.simple_state_editor", type: "bi.simple_state_editor",
width: 300, width: 300,
@ -20,11 +20,11 @@ describe("simple_state_editor", function () {
} }
}); });
editor.setWaterMark("AAAAA"); editor.setWaterMark("AAAAA");
expect(editor.element.find(".bi-water-mark").text()).to.equal("AAAAA"); expect(editor.element.find(".bi-water-mark").text()).toBe("AAAAA");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.focus(); editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () {
expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).toBe("长度必须大于4");
editor.destroy(); editor.destroy();
done(); done();
}) })
@ -33,7 +33,7 @@ describe("simple_state_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("setValue", function () { it("setValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.simple_state_editor", type: "bi.simple_state_editor",
width: 300, width: 300,
@ -44,7 +44,7 @@ describe("simple_state_editor", function () {
} }
}); });
editor.setValue("12345"); editor.setValue("12345");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.destroy(); editor.destroy();
}); });
@ -52,7 +52,7 @@ describe("simple_state_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("getValue", function () { it("getValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.simple_state_editor", type: "bi.simple_state_editor",
width: 300, width: 300,
@ -63,7 +63,7 @@ describe("simple_state_editor", function () {
return this.getValue().length > 4; return this.getValue().length > 4;
} }
}); });
expect(editor.getValue()).to.equal("12346"); expect(editor.getValue()).toBe("12346");
editor.destroy(); editor.destroy();
}); });

18
packages/fineui/src/case/editor/__test__/editor.state.test.js

@ -3,12 +3,12 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/5/13 * Created by windy on 2020/5/13
*/ */
describe("state_editor", function () { describe("state_editor", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("state-editor", function (done) { it("state-editor", done => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.state_editor", type: "bi.state_editor",
width: 300, width: 300,
@ -20,11 +20,11 @@ describe("state_editor", function () {
} }
}); });
editor.setWaterMark("AAAAA"); editor.setWaterMark("AAAAA");
expect(editor.element.find(".bi-water-mark").text()).to.equal("AAAAA"); expect(editor.element.find(".bi-water-mark").text()).toBe("AAAAA");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.focus(); editor.focus();
BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () { BI.Test.triggerKeyDown(editor.element.find(".bi-input"), "8", 56, function () {
expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).to.equal("长度必须大于4"); expect(editor.element.find(".bi-bubble .bubble-text:first-child").text()).toBe("长度必须大于4");
editor.destroy(); editor.destroy();
done(); done();
}) })
@ -33,7 +33,7 @@ describe("state_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("setValue", function () { it("setValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.state_editor", type: "bi.state_editor",
width: 300, width: 300,
@ -44,7 +44,7 @@ describe("state_editor", function () {
} }
}); });
editor.setValue("12345"); editor.setValue("12345");
expect(editor.element.find(".bi-input").val()).to.equal("12345"); expect(editor.element.find(".bi-input").val()).toBe("12345");
editor.destroy(); editor.destroy();
}); });
@ -52,7 +52,7 @@ describe("state_editor", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("getValue", function () { it("getValue", () => {
var editor = BI.Test.createWidget({ var editor = BI.Test.createWidget({
type: "bi.state_editor", type: "bi.state_editor",
width: 300, width: 300,
@ -63,7 +63,7 @@ describe("state_editor", function () {
return this.getValue().length > 4; return this.getValue().length > 4;
} }
}); });
expect(editor.getValue()).to.equal("12346"); expect(editor.getValue()).toBe("12346");
editor.destroy(); editor.destroy();
}); });

16
packages/fineui/src/case/loader/__test__/loader.lazy.test.js

@ -4,12 +4,12 @@
* Created by windy on 2020/4/3 * Created by windy on 2020/4/3
*/ */
describe("lazy_loader", function () { describe("lazy_loader", () => {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function (done) { it("setValue", done => {
var items = BI.map(BI.range(0, 100), function (idx, v) { var items = BI.map(BI.range(0, 100), function (idx, v) {
return { return {
type: "bi.single_select_item", type: "bi.single_select_item",
@ -28,7 +28,7 @@ describe("lazy_loader", function () {
items: items items: items
}); });
BI.nextTick(function () { BI.nextTick(function () {
expect(widget.getAllButtons().length).to.equal(100); expect(widget.getAllButtons().length).toBe(100);
widget.addItems([{ widget.addItems([{
type: "bi.single_select_item", type: "bi.single_select_item",
text: 102, text: 102,
@ -38,13 +38,13 @@ describe("lazy_loader", function () {
text: 103, text: 103,
value: 103 value: 103
}]); }]);
expect(widget.getAllLeaves().length).to.equal(102); expect(widget.getAllLeaves().length).toBe(102);
widget.setValue(102); widget.setValue(102);
expect(widget.getValue()[0]).to.equal(102); expect(widget.getValue()[0]).toBe(102);
expect(widget.getSelectedButtons().length).to.equal(1); expect(widget.getSelectedButtons().length).toBe(1);
widget.setNotSelectedValue(102); widget.setNotSelectedValue(102);
expect(widget.getNotSelectedValue()[0]).to.equal(102); expect(widget.getNotSelectedValue()[0]).toBe(102);
expect(widget.getNotSelectedButtons().length).to.equal(1); expect(widget.getNotSelectedButtons().length).toBe(1);
widget.destroy(); widget.destroy();
done(); done();
}); });

16
packages/fineui/src/case/loader/__test__/loader.list.test.js

@ -4,12 +4,12 @@
* Created by windy on 2020/4/3 * Created by windy on 2020/4/3
*/ */
describe("list_loader", function () { describe("list_loader", () => {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function (done) { it("setValue", done => {
var items = BI.map(BI.range(0, 100), function (idx, v) { var items = BI.map(BI.range(0, 100), function (idx, v) {
return { return {
type: "bi.single_select_item", type: "bi.single_select_item",
@ -28,7 +28,7 @@ describe("list_loader", function () {
items: items items: items
}); });
BI.nextTick(function () { BI.nextTick(function () {
expect(widget.getAllButtons().length).to.equal(100); expect(widget.getAllButtons().length).toBe(100);
widget.addItems([{ widget.addItems([{
type: "bi.single_select_item", type: "bi.single_select_item",
text: 102, text: 102,
@ -38,13 +38,13 @@ describe("list_loader", function () {
text: 103, text: 103,
value: 103 value: 103
}]); }]);
expect(widget.getAllLeaves().length).to.equal(102); expect(widget.getAllLeaves().length).toBe(102);
widget.setValue(102); widget.setValue(102);
expect(widget.getValue()[0]).to.equal(102); expect(widget.getValue()[0]).toBe(102);
expect(widget.getSelectedButtons().length).to.equal(1); expect(widget.getSelectedButtons().length).toBe(1);
widget.setNotSelectedValue(102); widget.setNotSelectedValue(102);
expect(widget.getNotSelectedValue()[0]).to.equal(102); expect(widget.getNotSelectedValue()[0]).toBe(102);
expect(widget.getNotSelectedButtons().length).to.equal(1); expect(widget.getNotSelectedButtons().length).toBe(1);
widget.destroy(); widget.destroy();
done(); done();
}); });

40
packages/fineui/src/case/pager/__test__/pager.test.js

@ -4,12 +4,12 @@
* Created by windy on 2020/3/17 * Created by windy on 2020/3/17
*/ */
describe("PagerTest", function () { describe("PagerTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("allCountPager", function () { it("allCountPager", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.all_count_pager", type: "bi.all_count_pager",
pages: 3, pages: 3,
@ -17,17 +17,17 @@ describe("PagerTest", function () {
count: 1000 count: 1000
}); });
a.setCount(888); a.setCount(888);
expect(a.element.find(".row-count").text()).to.equal("888"); expect(a.element.find(".row-count").text()).toBe("888");
a.setAllPages(777); a.setAllPages(777);
a.setValue(4); a.setValue(4);
expect(a.element.find(".bi-input").val()).to.equal("4"); expect(a.element.find(".bi-input").val()).toBe("4");
expect(a.getCurrentPage()).to.equal(4); expect(a.getCurrentPage()).toBe(4);
expect(a.hasPrev()).to.equal(false); expect(a.hasPrev()).toBe(false);
expect(a.hasNext()).to.equal(true); expect(a.hasNext()).toBe(true);
a.populate(); a.populate();
expect(a.element.find(".bi-input").val()).to.equal("4"); expect(a.element.find(".bi-input").val()).toBe("4");
a.setPagerVisible(false); a.setPagerVisible(false);
expect(a.element.find(".bi-pager").css("display")).to.equal("none"); expect(a.element.find(".bi-pager").css("display")).toBe("none");
a.destroy(); a.destroy();
}); });
@ -35,7 +35,7 @@ describe("PagerTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("directionPager", function () { it("directionPager", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.direction_pager", type: "bi.direction_pager",
horizontal: { horizontal: {
@ -65,16 +65,16 @@ describe("PagerTest", function () {
}); });
a.populate(); a.populate();
a.setVPage(2); a.setVPage(2);
expect(a.getVPage()).to.equal(1); expect(a.getVPage()).toBe(1);
a.setHPage(2); a.setHPage(2);
expect(a.getHPage()).to.equal(1); expect(a.getHPage()).toBe(1);
expect(a.hasVNext()).to.equal(true); expect(a.hasVNext()).toBe(true);
expect(a.hasHNext()).to.equal(true); expect(a.hasHNext()).toBe(true);
expect(a.hasVPrev()).to.equal(false); expect(a.hasVPrev()).toBe(false);
expect(a.hasHPrev()).to.equal(false); expect(a.hasHPrev()).toBe(false);
a.setHPagerVisible(false) a.setHPagerVisible(false)
a.setVPagerVisible(false) a.setVPagerVisible(false)
expect(a.element.find(".bi-pager").css("display")).to.equal("none"); expect(a.element.find(".bi-pager").css("display")).toBe("none");
a.clear(); a.clear();
a.destroy(); a.destroy();
}); });
@ -82,7 +82,7 @@ describe("PagerTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("detail_Pager", function () { it("detail_Pager", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.detail_pager", type: "bi.detail_pager",
pages: 100 pages: 100
@ -90,8 +90,8 @@ describe("PagerTest", function () {
a.setAllPages(200); a.setAllPages(200);
a.populate(); a.populate();
a.setValue(200); a.setValue(200);
expect(a.hasPrev(200)).to.equal(true); expect(a.hasPrev(200)).toBe(true);
expect(a.hasNext(200)).to.equal(false); expect(a.hasNext(200)).toBe(false);
a.destroy(); a.destroy();
}); });
}); });

8
packages/fineui/src/case/segment/__test__/segment.test.js

@ -3,12 +3,12 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/3/17 * Created by windy on 2020/3/17
*/ */
describe("SegmentTest", function () { describe("SegmentTest", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("segment", function () { it("segment", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.segment", type: "bi.segment",
items: [{ items: [{
@ -23,11 +23,11 @@ describe("SegmentTest", function () {
}] }]
}); });
a.setValue(2); a.setValue(2);
expect(a.getValue()[0]).to.equal(2); expect(a.getValue()[0]).toBe(2);
a.setEnable(false); a.setEnable(false);
a.setEnabledValue(3); a.setEnabledValue(3);
a.setValue(3); a.setValue(3);
expect(a.getValue()[0]).to.equal(3); expect(a.getValue()[0]).toBe(3);
a.destroy(); a.destroy();
}); });
}); });

1
packages/fineui/src/case/toolbar/toolbar.multiselect.js

@ -126,7 +126,6 @@ export class MultiSelectBar extends BasicButton {
} }
setSelected(v) { setSelected(v) {
super.setSelected(v);
this.checkbox.setSelected(v); this.checkbox.setSelected(v);
this.setHalfSelected(false); this.setHalfSelected(false);
} }

4
packages/fineui/src/case/ztree/asynctree.js

@ -221,11 +221,15 @@ export class AsyncTree extends TreeView {
{ {
el: { el: {
type: IconLabel.xtype, type: IconLabel.xtype,
width: 20,
height: 20,
cls: "button-loading-font anim-rotate bi-card", cls: "button-loading-font anim-rotate bi-card",
ref: ref => { ref: ref => {
loadingIcon = ref; loadingIcon = ref;
}, },
}, },
left: 5,
top: 5,
}, },
], ],
}); });

10
packages/fineui/src/component/allvaluechooser/__test__/combo.allvaluechooser.test.js

@ -4,7 +4,7 @@
* Created by windy on 2020/3/4 * Created by windy on 2020/3/4
*/ */
describe("all_value_chooser_combo", function () { describe("all_value_chooser_combo", () => {
var items = BI.map(BI.makeArray(1000, null), function(idx, v) { var items = BI.map(BI.makeArray(1000, null), function(idx, v) {
return { return {
@ -29,7 +29,7 @@ describe("all_value_chooser_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.all_value_chooser_combo", type: "bi.all_value_chooser_combo",
width: 220, width: 220,
@ -38,14 +38,14 @@ describe("all_value_chooser_combo", function () {
} }
}); });
widget.setValue([1, 2]); widget.setValue([1, 2]);
expect(widget.getValue()).to.deep.equal([1, 2]); expect(widget.getValue()).toEqual([1, 2]);
widget.destroy(); widget.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
**/ **/
it("点选选值", function (done) { it("点选选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.all_value_chooser_combo", type: "bi.all_value_chooser_combo",
width: 220, width: 220,
@ -60,7 +60,7 @@ describe("all_value_chooser_combo", function () {
BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) { BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) {
widget.element.find(selector).click(); widget.element.find(selector).click();
}); });
expect(widget.getValue()).to.deep.equal([0, 1, 2]); expect(widget.getValue()).toEqual([0, 1, 2]);
done(); done();
}, 300); }, 300);
}); });

6
packages/fineui/src/component/allvaluemultitextvaluecombo/__test__/allvalue.multitextvalue.combo.test.js

@ -4,7 +4,7 @@
* Created by windy on 2020/3/4 * Created by windy on 2020/3/4
*/ */
describe("all_value_multi_text_value_combo", function () { describe("all_value_multi_text_value_combo", () => {
var items = BI.map(BI.makeArray(1000, null), function(idx, v) { var items = BI.map(BI.makeArray(1000, null), function(idx, v) {
return { return {
@ -17,14 +17,14 @@ describe("all_value_multi_text_value_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.all_value_multi_text_value_combo", type: "bi.all_value_multi_text_value_combo",
width: 220, width: 220,
items: items items: items
}); });
widget.setValue([1, 2]); widget.setValue([1, 2]);
expect(widget.getValue()).to.deep.equal([1, 2]); expect(widget.getValue()).toEqual([1, 2]);
widget.destroy(); widget.destroy();
}); });
}); });

30
packages/fineui/src/component/valuechooser/__test__/combo.valuechooser.insert.test.js

@ -3,7 +3,7 @@
* @version 2.0 * @version 2.0
* Created by windy on 2019/9/23 * Created by windy on 2019/9/23
*/ */
describe("value_chooser_insert_combo", function () { describe("value_chooser_insert_combo", () => {
var items = BI.map(BI.makeArray(1000, null), function(idx, v) { var items = BI.map(BI.makeArray(1000, null), function(idx, v) {
return { return {
@ -28,7 +28,7 @@ describe("value_chooser_insert_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_insert_combo", type: "bi.value_chooser_insert_combo",
width: 220, width: 220,
@ -40,7 +40,7 @@ describe("value_chooser_insert_combo", function () {
type: 1, type: 1,
value: [1, 2] value: [1, 2]
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 1, type: 1,
value: [1, 2] value: [1, 2]
}); });
@ -50,7 +50,7 @@ describe("value_chooser_insert_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("getValue", function () { it("getValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_insert_combo", type: "bi.value_chooser_insert_combo",
width: 220, width: 220,
@ -62,7 +62,7 @@ describe("value_chooser_insert_combo", function () {
value: [1, 2, 3] value: [1, 2, 3]
} }
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 2, type: 2,
value: [1, 2, 3] value: [1, 2, 3]
}); });
@ -72,7 +72,7 @@ describe("value_chooser_insert_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("点选选值", function (done) { it("点选选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_insert_combo", type: "bi.value_chooser_insert_combo",
width: 220, width: 220,
@ -94,7 +94,7 @@ describe("value_chooser_insert_combo", function () {
BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) { BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) {
widget.element.find(selector).click(); widget.element.find(selector).click();
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 2, type: 2,
value: [0, 1, 2] value: [0, 1, 2]
}); });
@ -107,7 +107,7 @@ describe("value_chooser_insert_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("搜索选值", function (done) { it("搜索选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_insert_combo", type: "bi.value_chooser_insert_combo",
width: 220, width: 220,
@ -124,7 +124,7 @@ describe("value_chooser_insert_combo", function () {
BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) { BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) {
widget.element.find(selector).click(); widget.element.find(selector).click();
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 1, type: 1,
value: [2, 12] value: [2, 12]
}); });
@ -139,7 +139,7 @@ describe("value_chooser_insert_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("新增值", function (done) { it("新增值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_insert_combo", type: "bi.value_chooser_insert_combo",
width: 220, width: 220,
@ -154,7 +154,7 @@ describe("value_chooser_insert_combo", function () {
BI.Test.triggerKeyDown(widget.element.find(".bi-multi-select-trigger .bi-input"), "z", 50, function () { BI.Test.triggerKeyDown(widget.element.find(".bi-multi-select-trigger .bi-input"), "z", 50, function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.find(".bi-text-button:contains(+点击新增\"z\")").click(); widget.element.find(".bi-text-button:contains(+点击新增\"z\")").click();
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 1, type: 1,
value: ["z"] value: ["z"]
}); });
@ -169,7 +169,7 @@ describe("value_chooser_insert_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("查看已选", function (done) { it("查看已选", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_insert_combo", type: "bi.value_chooser_insert_combo",
width: 220, width: 220,
@ -184,7 +184,7 @@ describe("value_chooser_insert_combo", function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.find(".bi-multi-select-check-selected-button").click(); widget.element.find(".bi-multi-select-check-selected-button").click();
BI.delay(function () { BI.delay(function () {
expect(widget.element.find(".display-list-item").length).to.equal(2); expect(widget.element.find(".display-list-item").length).toBe(2);
widget.destroy(); widget.destroy();
done(); done();
}, 300); }, 300);
@ -194,7 +194,7 @@ describe("value_chooser_insert_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("BI-64399", function (done) { it("BI-64399", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_insert_combo", type: "bi.value_chooser_insert_combo",
width: 220, width: 220,
@ -227,7 +227,7 @@ describe("value_chooser_insert_combo", function () {
BI.nextTick(function () { BI.nextTick(function () {
BI.Test.triggerKeyDown(widget.element.find(".bi-multi-select-trigger .bi-input"), "A", 65, function () { BI.Test.triggerKeyDown(widget.element.find(".bi-multi-select-trigger .bi-input"), "A", 65, function () {
BI.nextTick(function () { BI.nextTick(function () {
expect(widget.element.find(".bi-multi-select-search-pane .multi-select-toolbar").css("display")).to.equal("block"); expect(widget.element.find(".bi-multi-select-search-pane .multi-select-toolbar").css("display")).toBe("block");
widget.destroy(); widget.destroy();
done(); done();
}); });

22
packages/fineui/src/component/valuechooser/__test__/combo.valuechooser.test.js

@ -3,7 +3,7 @@
* @version 2.0 * @version 2.0
* Created by windy on 2019/9/23 * Created by windy on 2019/9/23
*/ */
describe("value_chooser_combo", function () { describe("value_chooser_combo", () => {
var items = BI.map(BI.makeArray(1000, null), function(idx, v) { var items = BI.map(BI.makeArray(1000, null), function(idx, v) {
return { return {
@ -28,7 +28,7 @@ describe("value_chooser_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_combo", type: "bi.value_chooser_combo",
width: 220, width: 220,
@ -40,7 +40,7 @@ describe("value_chooser_combo", function () {
type: 1, type: 1,
value: [1, 2] value: [1, 2]
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 1, type: 1,
value: [1, 2] value: [1, 2]
}); });
@ -50,7 +50,7 @@ describe("value_chooser_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("getValue", function () { it("getValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_combo", type: "bi.value_chooser_combo",
width: 220, width: 220,
@ -62,7 +62,7 @@ describe("value_chooser_combo", function () {
value: [1, 2, 3] value: [1, 2, 3]
} }
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 2, type: 2,
value: [1, 2, 3] value: [1, 2, 3]
}); });
@ -72,7 +72,7 @@ describe("value_chooser_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("点选选值", function (done) { it("点选选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_combo", type: "bi.value_chooser_combo",
width: 220, width: 220,
@ -94,7 +94,7 @@ describe("value_chooser_combo", function () {
BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) { BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) {
widget.element.find(selector).click(); widget.element.find(selector).click();
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 2, type: 2,
value: [0, 1, 2] value: [0, 1, 2]
}); });
@ -107,7 +107,7 @@ describe("value_chooser_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("搜索选值", function (done) { it("搜索选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_combo", type: "bi.value_chooser_combo",
width: 220, width: 220,
@ -124,7 +124,7 @@ describe("value_chooser_combo", function () {
BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) { BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) {
widget.element.find(selector).click(); widget.element.find(selector).click();
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 1, type: 1,
value: [2, 12] value: [2, 12]
}); });
@ -139,7 +139,7 @@ describe("value_chooser_combo", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("查看已选", function (done) { it("查看已选", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_combo", type: "bi.value_chooser_combo",
width: 220, width: 220,
@ -154,7 +154,7 @@ describe("value_chooser_combo", function () {
BI.nextTick(function () { BI.nextTick(function () {
widget.element.find(".bi-multi-select-check-selected-button").click(); widget.element.find(".bi-multi-select-check-selected-button").click();
BI.delay(function () { BI.delay(function () {
expect(widget.element.find(".display-list-item").length).to.equal(2); expect(widget.element.find(".display-list-item").length).toBe(2);
widget.destroy(); widget.destroy();
done(); done();
}, 300); }, 300);

14
packages/fineui/src/component/valuechooser/__test__/pane.valuechooser.test.js

@ -4,7 +4,7 @@
* Created by windy on 2019/9/23 * Created by windy on 2019/9/23
*/ */
describe("value_chooser_pane", function () { describe("value_chooser_pane", () => {
var items = BI.map(BI.makeArray(1000, null), function(idx, v) { var items = BI.map(BI.makeArray(1000, null), function(idx, v) {
return { return {
@ -29,7 +29,7 @@ describe("value_chooser_pane", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("setValue", function () { it("setValue", () => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_pane", type: "bi.value_chooser_pane",
width: 220, width: 220,
@ -41,7 +41,7 @@ describe("value_chooser_pane", function () {
type: 1, type: 1,
value: [1, 2] value: [1, 2]
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 1, type: 1,
value: [1, 2] value: [1, 2]
}); });
@ -51,7 +51,7 @@ describe("value_chooser_pane", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("点选选值", function (done) { it("点选选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_pane", type: "bi.value_chooser_pane",
width: 220, width: 220,
@ -69,7 +69,7 @@ describe("value_chooser_pane", function () {
BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) { BI.each(itemSelectorGetter([1,2,3]), function (idx, selector) {
widget.element.find(selector).click(); widget.element.find(selector).click();
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 2, type: 2,
value: [0, 1, 2] value: [0, 1, 2]
}); });
@ -82,7 +82,7 @@ describe("value_chooser_pane", function () {
/** /**
* test_author_windy * test_author_windy
**/ **/
it("搜索选值", function (done) { it("搜索选值", done => {
var widget = BI.Test.createWidget({ var widget = BI.Test.createWidget({
type: "bi.value_chooser_pane", type: "bi.value_chooser_pane",
width: 220, width: 220,
@ -98,7 +98,7 @@ describe("value_chooser_pane", function () {
BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) { BI.each(searchItemSelectorGetter([1,2]), function (idx, selector) {
widget.element.find(selector).click(); widget.element.find(selector).click();
}); });
expect(widget.getValue()).to.deep.equal({ expect(widget.getValue()).toEqual({
type: 1, type: 1,
value: [2, 12] value: [2, 12]
}); });

49
packages/fineui/src/core/1.lodash.js

@ -14,7 +14,7 @@
var undefined; var undefined;
/** Used as the semantic version number. */ /** Used as the semantic version number. */
var VERSION = '4.17.21'; var VERSION = '4.17.5';
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
@ -899,7 +899,7 @@
} }
/** /**
* Gets the value at `key`, unless `key` is "__proto__" or "constructor". * Gets the value at `key`, unless `key` is "__proto__".
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.
@ -907,10 +907,6 @@
* @returns {*} Returns the property value. * @returns {*} Returns the property value.
*/ */
function safeGet(object, key) { function safeGet(object, key) {
if (key === 'constructor' && typeof object[key] === 'function') {
return;
}
return key == '__proto__' return key == '__proto__'
? undefined ? undefined
: object[key]; : object[key];
@ -6845,46 +6841,6 @@
} }
}); });
/**
* Creates an array of elements split into two groups, the first of which
* contains elements `predicate` returns truthy for, the second of which
* contains elements `predicate` returns falsey for. The predicate is
* invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the array of grouped elements.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true },
* { 'user': 'pebbles', 'age': 1, 'active': false }
* ];
*
* _.partition(users, function(o) { return o.active; });
* // => objects for [['fred'], ['barney', 'pebbles']]
*
* // The `_.matches` iteratee shorthand.
* _.partition(users, { 'age': 1, 'active': false });
* // => objects for [['pebbles'], ['barney', 'fred']]
*
* // The `_.matchesProperty` iteratee shorthand.
* _.partition(users, ['active', false]);
* // => objects for [['barney', 'pebbles'], ['fred']]
*
* // The `_.property` iteratee shorthand.
* _.partition(users, 'active');
* // => objects for [['fred'], ['barney', 'pebbles']]
*/
var partition = createAggregator(function(result, value, key) {
result[key ? 0 : 1].push(value);
}, function() { return [[], []]; });
/** /**
* Creates an array of values by running each element in `collection` thru * Creates an array of values by running each element in `collection` thru
* `iteratee`. The iteratee is invoked with three arguments: * `iteratee`. The iteratee is invoked with three arguments:
@ -10092,7 +10048,6 @@
lodash.omit = omit; lodash.omit = omit;
lodash.omitBy = omitBy; lodash.omitBy = omitBy;
lodash.once = once; lodash.once = once;
lodash.partition = partition;
lodash.pick = pick; lodash.pick = pick;
lodash.pickBy = pickBy; lodash.pickBy = pickBy;
lodash.range = range; lodash.range = range;

2
packages/fineui/src/core/2.base.js

@ -1518,7 +1518,7 @@ export function getTime() {
} }
if (isNotNull(BI.timeZone)) { if (isNotNull(BI.timeZone)) {
// BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准 // BI-33791 1901年以前的东8区标准是GMT+0805, 统一无论是什么时间,都以整的0800这样的为基准
return dt.getTime() - BI.timeZone - new Date().getTimezoneOffset() * 60000; return dt.getTime() + BI.timeZone + new Date().getTimezoneOffset() * 60000;
} }
return dt.getTime(); return dt.getTime();

4
packages/fineui/src/core/5.inject.js

@ -62,7 +62,7 @@ const constantInjection = {};
export function constant(xtype, cls) { export function constant(xtype, cls) {
if (isNotNull(constantInjection[xtype])) { if (isNotNull(constantInjection[xtype])) {
_global.console && console.warn(`constant: [${xtype}]already registered`); _global.console && console.error(`constant: [${xtype}]already registered`);
} else { } else {
constantInjection[xtype] = cls; constantInjection[xtype] = cls;
} }
@ -427,7 +427,7 @@ const providers = {},
export const Providers = { export const Providers = {
getProvider: (type, config) => { getProvider: (type, config) => {
if (!providerInjection[type]) { if (!providerInjection[type]) {
_global.console && console.warn(`provider: [${type}] undefined`); _global.console && console.error(`provider: [${type}] undefined`);
} }
runConfigFunction(type); runConfigFunction(type);
if (!providers[type]) { if (!providers[type]) {

110
packages/fineui/src/core/__test__/alias.test.js

@ -1,9 +1,9 @@
/** /**
* Created by windy on 2018/01/23. * Created by windy on 2018/01/23.
*/ */
describe("aliasFunctionTest", function () { describe("aliasFunctionTest", () => {
before(function () { beforeAll(() => {
BI.specialCharsMap = { BI.specialCharsMap = {
"\\\\": "0", "\\\\": "0",
".": "1", ".": "1",
@ -14,39 +14,39 @@ describe("aliasFunctionTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("htmlEncode和htmlDecode", function () { it("htmlEncode和htmlDecode", () => {
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&nbsp;2&amp;&lt;/a&gt;"); expect(encodeString).toBe("&lt;a&gt;1&nbsp;2&amp;&lt;/a&gt;");
expect(BI.htmlDecode(encodeString)).to.equal(targetString); expect(BI.htmlDecode(encodeString)).toBe(targetString);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("encodeURIComponent和decodeURIComponent", function () { it("encodeURIComponent和decodeURIComponent", () => {
var targetString = "tableName./\\"; var targetString = "tableName./\\";
var encodeString = BI.encodeURIComponent(targetString); var encodeString = BI.encodeURIComponent(targetString);
expect(encodeString).to.equal("tableName120"); expect(encodeString).toBe("tableName120");
expect(BI.decodeURIComponent(encodeString)).to.equal(targetString); expect(BI.decodeURIComponent(encodeString)).toBe(targetString);
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("cjkEncode 和 cjkDecode ", function () { it("cjkEncode 和 cjkDecode ", () => {
expect(BI.cjkEncode("测试")).to.eql("[6d4b][8bd5]"); expect(BI.cjkEncode("测试")).toEqual("[6d4b][8bd5]");
expect(BI.cjkEncode(123)).to.eql(123); expect(BI.cjkEncode(123)).toEqual(123);
expect(BI.cjkDecode("[6d4b][8bd5]")).to.eql("测试"); expect(BI.cjkDecode("[6d4b][8bd5]")).toEqual("测试");
expect(BI.cjkDecode("6d4b 8bd5")).to.eql("6d4b 8bd5"); expect(BI.cjkDecode("6d4b 8bd5")).toEqual("6d4b 8bd5");
expect(BI.cjkDecode(null)).to.eql(""); expect(BI.cjkDecode(null)).toEqual("");
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("jsonEncode 和 jsonDecode", function () { it("jsonEncode 和 jsonDecode", () => {
var jsonString = '{"a":1,"b":"测\\"试","c":[5,6],"d":null,"e":false}'; var jsonString = '{"a":1,"b":"测\\"试","c":[5,6],"d":null,"e":false}';
var obj = { var obj = {
a: 1, a: 1,
@ -55,81 +55,81 @@ describe("aliasFunctionTest", function () {
d: null, d: null,
e: false, e: false,
}; };
expect(BI.jsonEncode(obj)).to.eql(jsonString); expect(BI.jsonEncode(obj)).toEqual(jsonString);
expect(BI.jsonDecode(jsonString)).to.eql(obj); expect(BI.jsonDecode(jsonString)).toEqual(obj);
expect(BI.jsonEncode({ a: function(){return 1} })).to.eql('{"a":function(){return 1}}'); expect(BI.jsonEncode({ a: function(){return 1} })).toEqual('{"a":function(){return 1}}');
expect(BI.jsonDecode("{__time__:878313600000}")).to.eql(new Date(878313600000)); expect(BI.jsonDecode("{__time__:878313600000}")).toEqual(new Date(878313600000));
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("getEncodeURL", function () { it("getEncodeURL", () => {
expect(BI.getEncodeURL("design/{tableName}/{fieldName}",{tableName: "A", fieldName: "a"})).to.eql("design/A/a"); expect(BI.getEncodeURL("design/{tableName}/{fieldName}",{tableName: "A", fieldName: "a"})).toEqual("design/A/a");
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("contentFormat", function () { it("contentFormat", () => {
expect(BI.contentFormat("", "DTyyyy-MM-dd")).to.eql(""); expect(BI.contentFormat("", "DTyyyy-MM-dd")).toEqual("");
expect(BI.contentFormat(878313600000, "")).to.eql("878313600000"); expect(BI.contentFormat(878313600000, "")).toEqual("878313600000");
expect(BI.contentFormat("test", "T")).to.eql("test"); expect(BI.contentFormat("test", "T")).toEqual("test");
expect(BI.contentFormat(878313600000, "E")).to.eql("9E11"); expect(BI.contentFormat(878313600000, "E")).toEqual("9E11");
expect(BI.contentFormat(1000.23456789, "0,000.####")).to.eql("1,000.2346"); expect(BI.contentFormat(1000.23456789, "0,000.####")).toEqual("1,000.2346");
expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd")).to.eql("1997-11-09"); expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd")).toEqual("1997-11-09");
expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd HH:mm:ss a")).to.eql("1997-11-09 13:00:00 pm"); expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd HH:mm:ss a")).toEqual("1997-11-09 13:00:00 pm");
expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd hh:mm:ss a")).to.eql("1997-11-09 01:00:00 pm"); expect(BI.contentFormat(879051600000, "DTyyyy-MM-dd hh:mm:ss a")).toEqual("1997-11-09 01:00:00 pm");
expect(BI.contentFormat(879051600000, "DTyyy-M-d H:m:s a")).to.eql("97-11-9 13:0:0 pm"); expect(BI.contentFormat(879051600000, "DTyyy-M-d H:m:s a")).toEqual("97-11-9 13:0:0 pm");
expect(BI.contentFormat(879048000000, "DTyyy-M-d h:m:s a")).to.eql("97-11-9 12:0:0 pm"); expect(BI.contentFormat(879048000000, "DTyyy-M-d h:m:s a")).toEqual("97-11-9 12:0:0 pm");
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("parseFmt", function () { it("parseFmt", () => {
expect(BI.parseFmt("yyyy-MM-dd HH:mm:ss")).to.eql("%Y-%X-%d %H:%M:%S"); expect(BI.parseFmt("yyyy-MM-dd HH:mm:ss")).toEqual("%Y-%X-%d %H:%M:%S");
expect(BI.parseFmt("yyyy-MM-d hh:mm:ss")).to.eql("%Y-%X-%e %I:%M:%S"); expect(BI.parseFmt("yyyy-MM-d hh:mm:ss")).toEqual("%Y-%X-%e %I:%M:%S");
expect(BI.parseFmt("")).to.eql(""); expect(BI.parseFmt("")).toEqual("");
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("str2Date", function () { it("str2Date", () => {
expect(BI.str2Date('2013-12-12', 'yyyy-MM-dd')).to.eql(new Date(2013, 11, 12)); expect(BI.str2Date('2013-12-12', 'yyyy-MM-dd')).toEqual(new Date(2013, 11, 12));
expect(BI.str2Date('2013-12-12', 123)).to.eql(null); expect(BI.str2Date('2013-12-12', 123)).toBeNull();
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("object2Number", function () { it("object2Number", () => {
expect(BI.object2Number(null)).to.eql(0); expect(BI.object2Number(null)).toEqual(0);
expect(BI.object2Number(123)).to.eql(123); expect(BI.object2Number(123)).toEqual(123);
expect(BI.object2Number("1.23")).to.eql(1.23); expect(BI.object2Number("1.23")).toEqual(1.23);
expect(BI.object2Number({ a: 2 })).to.eql(NaN); expect(BI.object2Number({ a: 2 })).toEqual(NaN);
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("object2Date", function () { it("object2Date", () => {
expect(BI.object2Date(null)).to.eql(new Date()); expect(BI.object2Date(null)).toEqual(new Date());
expect(BI.object2Date(new Date(1997, 10, 9))).to.eql(new Date(1997, 10, 9)); expect(BI.object2Date(new Date(1997, 10, 9))).toEqual(new Date(1997, 10, 9));
expect(BI.object2Date(879051600000)).to.eql(new Date(879051600000)); expect(BI.object2Date(879051600000)).toEqual(new Date(879051600000));
expect(BI.object2Time("1997-11-09")).to.eql(new Date(1997, 10, 9)); expect(BI.object2Time("1997-11-09")).toEqual(new Date(1997, 10, 9));
expect(BI.object2Date({ a: 2 })).to.eql(new Date()); expect(BI.object2Date({ a: 2 })).toEqual(new Date());
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("object2Time", function () { it("object2Time", () => {
expect(BI.object2Time(null)).to.eql(new Date()); expect(BI.object2Time(null)).toEqual(new Date());
expect(BI.object2Time(new Date(1997, 11, 9))).to.eql(new Date(1997, 11, 9)); expect(BI.object2Time(new Date(1997, 11, 9))).toEqual(new Date(1997, 11, 9));
expect(BI.object2Time("1997-11-09 13:00:00")).to.eql(new Date(1997, 10, 9, 13, 0, 0)); expect(BI.object2Time("1997-11-09 13:00:00")).toEqual(new Date(1997, 10, 9, 13, 0, 0));
expect(BI.object2Time("13:00:00")).to.eql(new Date(1970, 0, 1, 13, 0, 0)); expect(BI.object2Time("13:00:00")).toEqual(new Date(1970, 0, 1, 13, 0, 0));
}); });
}); });

280
packages/fineui/src/core/__test__/base.test.js

@ -1,16 +1,16 @@
/** /**
* Created by windy on 2018/01/24. * Created by windy on 2018/01/24.
*/ */
describe("baseFunctionTest", function () { describe("baseFunctionTest", () => {
before(function () { beforeAll(() => {
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("formatEl和stripEL", function () { it("formatEl和stripEL", () => {
var obj1 = { var obj1 = {
type: "a", type: "a",
pro: {}, pro: {},
@ -24,53 +24,53 @@ describe("baseFunctionTest", function () {
items: [] items: []
} }
}; };
expect(BI.formatEL(obj1)).to.deep.equal(obj2); expect(BI.formatEL(obj1)).toEqual(obj2);
expect(BI.formatEL(obj2)).to.deep.equal(obj2); expect(BI.formatEL(obj2)).toEqual(obj2);
expect(BI.stripEL(obj1)).to.deep.equal(obj1); expect(BI.stripEL(obj1)).toEqual(obj1);
expect(BI.stripEL(obj2)).to.deep.equal(obj1); expect(BI.stripEL(obj2)).toEqual(obj1);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("encodeURIComponent和decodeURIComponent", function () { it("encodeURIComponent和decodeURIComponent", () => {
var targetString = "tableName./\\"; var targetString = "tableName./\\";
var encodeString = BI.encodeURIComponent(targetString); var encodeString = BI.encodeURIComponent(targetString);
expect(encodeString).to.equal("tableName120"); expect(encodeString).toBe("tableName120");
expect(BI.decodeURIComponent(encodeString)).to.equal(targetString); expect(BI.decodeURIComponent(encodeString)).toBe(targetString);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("count", function () { it("count", () => {
var a = []; var a = [];
expect(BI.count(1, 100)).to.equal(99); expect(BI.count(1, 100)).toBe(99);
BI.count(0, 100, function (v) { BI.count(0, 100, function (v) {
a[v] = 0; a[v] = 0;
}); });
expect(a.length).to.equal(100); expect(a.length).toBe(100);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("concat", function () { it("concat", () => {
expect(BI.concat([1], [2])).to.deep.equal([1, 2]); expect(BI.concat([1], [2])).toEqual([1, 2]);
expect(BI.concat(1, 2)).to.equal("12"); expect(BI.concat(1, 2)).toBe("12");
expect(BI.concat("1", "2")).to.equal("12"); expect(BI.concat("1", "2")).toBe("12");
expect(BI.concat({a: 1}, {b: 1})).to.deep.equal({a: 1, b: 1}); expect(BI.concat({a: 1}, {b: 1})).toEqual({a: 1, b: 1});
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("remove", function () { it("remove", () => {
var a = [1, 2, 3, 4, 5, 6]; var a = [1, 2, 3, 4, 5, 6];
BI.remove(a, function (i, v) { BI.remove(a, function (i, v) {
return v === 4; return v === 4;
}); });
expect(a).to.deep.equal([1, 2, 3, 5, 6]); expect(a).toEqual([1, 2, 3, 5, 6]);
var b = { var b = {
a: 1, a: 1,
b: 2 b: 2
@ -78,7 +78,7 @@ describe("baseFunctionTest", function () {
BI.remove(b, function (key) { BI.remove(b, function (key) {
return key === "a"; return key === "a";
}); });
expect(b).to.deep.equal({ expect(b).toEqual({
b: 2 b: 2
}); });
}); });
@ -86,16 +86,16 @@ describe("baseFunctionTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("removeAt", function () { it("removeAt", () => {
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; var a = [1, 2, 3, 4, 5, 6, 7, 8, 9];
BI.removeAt(a, 2); BI.removeAt(a, 2);
expect(a).to.deep.equal([1, 2, 4, 5, 6, 7, 8, 9]); expect(a).toEqual([1, 2, 4, 5, 6, 7, 8, 9]);
var b = { var b = {
a: 1, a: 1,
b: 2 b: 2
}; };
BI.removeAt(b, "a"); BI.removeAt(b, "a");
expect(b).to.deep.equal({ expect(b).toEqual({
b: 2 b: 2
}); });
}); });
@ -103,27 +103,27 @@ describe("baseFunctionTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("makeArray", function () { it("makeArray", () => {
var a = BI.makeArray(2, 1); var a = BI.makeArray(2, 1);
expect(a).to.deep.equal([1, 1]); expect(a).toEqual([1, 1]);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("concat-string", function () { it("concat-string", () => {
// concat-string // concat-string
expect(BI.concat("a", "b", "c")).to.equal("abc"); expect(BI.concat("a", "b", "c")).toBe("abc");
// concat-array // concat-array
expect(BI.concat([1], [2], [3])).to.deep.equal([1, 2, 3]); expect(BI.concat([1], [2], [3])).toEqual([1, 2, 3]);
// concat-object-array // concat-object-array
expect(BI.concat([{text: 1, value: 1}], [{text: 2, value: 2}], [{text: 3, value: 3}])).to.deep.equal([{text: 1, value: 1}, {text: 2, value: 2}, {text: 3, value: 3}]); expect(BI.concat([{text: 1, value: 1}], [{text: 2, value: 2}], [{text: 3, value: 3}])).toEqual([{text: 1, value: 1}, {text: 2, value: 2}, {text: 3, value: 3}]);
// concat-object // concat-object
expect(BI.concat({a: 1}, {b: 2}, {c: 3})).to.deep.equal({ expect(BI.concat({a: 1}, {b: 2}, {c: 3})).toEqual({
a: 1, a: 1,
b: 2, b: 2,
c: 3 c: 3
@ -133,11 +133,11 @@ describe("baseFunctionTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("assert-warning", function () { it("assert-warning", () => {
expect(BI.assert("a", "a")).to.equal(true); expect(BI.assert("a", "a")).toBe(true);
expect(BI.assert("a", function (v) { expect(BI.assert("a", function (v) {
return v === "a"; return v === "a";
})).to.equal(true); })).toBe(true);
var test = ""; var test = "";
try { try {
BI.assert("a", function (v) { BI.assert("a", function (v) {
@ -146,13 +146,13 @@ describe("baseFunctionTest", function () {
} catch (e) { } catch (e) {
test = true; test = true;
} }
expect(test).to.equal(true); expect(test).toBe(true);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("packageItems", function () { it("packageItems", () => {
expect(BI.packageItems([{ expect(BI.packageItems([{
type: "a", type: "a",
text: "b" text: "b"
@ -163,7 +163,7 @@ describe("baseFunctionTest", function () {
type: "bi.vertical" type: "bi.vertical"
}, { }, {
type: "bi.center_adapt" type: "bi.center_adapt"
}])).to.deep.equal([{ }])).toEqual([{
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{
el: { el: {
@ -195,29 +195,29 @@ describe("baseFunctionTest", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("inverse", function () { it("inverse", () => {
expect(BI.inverse(7, 1)).to.equal(6); expect(BI.inverse(7, 1)).toBe(6);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("key", function () { it("key", () => {
var a = { var a = {
c: 1, c: 1,
d: 2 d: 2
}; };
expect(BI.firstKey(a)).to.equal("c"); expect(BI.firstKey(a)).toBe("c");
expect(BI.lastKey(a)).to.equal("d"); expect(BI.lastKey(a)).toBe("d");
expect(BI.firstObject(a)).to.equal(1); expect(BI.firstObject(a)).toBe(1);
expect(BI.lastObject(a)).to.equal(2); expect(BI.lastObject(a)).toBe(2);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("back", function () { it("back", () => {
var a = [{ var a = [{
c: 1, c: 1,
d: 2 d: 2
@ -232,147 +232,147 @@ describe("baseFunctionTest", function () {
BI.backEach(a, function (idx, v) { BI.backEach(a, function (idx, v) {
c.push(v.d); c.push(v.d);
}); });
expect(c).to.deep.equal([6, 4, 2]); expect(c).toEqual([6, 4, 2]);
expect(BI.backEvery(a, function (idx, v) { expect(BI.backEvery(a, function (idx, v) {
return v.c = 1; return v.c = 1;
})).to.equal(true); })).toBe(true);
expect(BI.backFindKey({ expect(BI.backFindKey({
c: 5, c: 5,
d: 6 d: 6
}, function (value, key) { }, function (value, key) {
return key === "c"; return key === "c";
})).to.equal("c"); })).toBe("c");
expect(BI.backFind({ expect(BI.backFind({
c: 5, c: 5,
d: 6 d: 6
}, function (v, key) { }, function (v, key) {
return v === 5; return v === 5;
})).to.deep.equal(5); })).toEqual(5);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("others", function () { it("others", () => {
expect(BI.abc2Int("B")).to.equal(2); expect(BI.abc2Int("B")).toBe(2);
expect(BI.int2Abc(2)).to.equal("B"); expect(BI.int2Abc(2)).toBe("B");
expect(BI.has({a: "1", b: "2"}, "a")).to.equal(true); expect(BI.has({a: "1", b: "2"}, "a")).toBe(true);
expect(Object.isFrozen(BI.freeze({a: "1", b: "2"}))).to.equal(true); expect(Object.isFrozen(BI.freeze({a: "1", b: "2"}))).toBe(true);
expect(BI.isCapitalEqual("A", "a")).to.equal(true); expect(BI.isCapitalEqual("A", "a")).toBe(true);
expect(BI.isEmptyString("a")).to.equal(false); expect(BI.isEmptyString("a")).toBe(false);
expect(BI.isNotEmptyString("a")).to.equal(true); expect(BI.isNotEmptyString("a")).toBe(true);
expect(BI.isWindow("a")).to.equal(false); expect(BI.isWindow("a")).toBe(false);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("deepFunc", function () { it("deepFunc", () => {
expect(BI.isDeepMatch({b: {c: {e: 3}}, d:2}, {b: {c: {e: 3}}, d:2})).to.equal(true); expect(BI.isDeepMatch({b: {c: {e: 3}}, d:2}, {b: {c: {e: 3}}, d:2})).toBe(true);
expect(BI.deepIndexOf([{a: 1}, {b: 2}, {c: 3}], {c: 3})).to.equal(2); expect(BI.deepIndexOf([{a: 1}, {b: 2}, {c: 3}], {c: 3})).toBe(2);
var remove = [{a: 1}, {b: 2}, {c: 3}]; var remove = [{a: 1}, {b: 2}, {c: 3}];
BI.deepRemove(remove, {c: 3}); BI.deepRemove(remove, {c: 3});
expect(remove).to.deep.equal([{a: 1}, {b: 2}]); expect(remove).toEqual([{a: 1}, {b: 2}]);
expect(BI.deepWithout([{a: 1}, {b: 2}, {c: 3}], {c: 3})).to.deep.equal([{a: 1}, {b: 2}]); expect(BI.deepWithout([{a: 1}, {b: 2}, {c: 3}], {c: 3})).toEqual([{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.deepUnique([{c: 3}, {a: 1}, {b: 2}, {c: 3}, {c: 3}])).toEqual([{c: 3}, {a: 1}, {b: 2}]);
expect(BI.deepDiff({a: 1, b: 2}, {a: 1, c: 2})).to.deep.equal(["b", "c"]); expect(BI.deepDiff({a: 1, b: 2}, {a: 1, c: 2})).toEqual(["b", "c"]);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("number", function () { it("number", () => {
expect(BI.parseSafeInt(9007199254740992)).to.equal(9007199254740991); expect(BI.parseSafeInt(9007199254740992)).toBe(9007199254740991);
expect(BI.isNegativeInteger(-3)).to.equal(true); expect(BI.isNegativeInteger(-3)).toBe(true);
expect(BI.isFloat(1.2)).to.equal(true); expect(BI.isFloat(1.2)).toBe(true);
expect(BI.isOdd(1)).to.equal(true); expect(BI.isOdd(1)).toBe(true);
expect(BI.isOdd("a")).to.equal(false); expect(BI.isOdd("a")).toBe(false);
expect(BI.isEven("a")).to.equal(false); expect(BI.isEven("a")).toBe(false);
expect(BI.isEven(2)).to.equal(true); expect(BI.isEven(2)).toBe(true);
expect(BI.sum([1, 2, 3, 4, 5, 6, 7])).to.equal(28); expect(BI.sum([1, 2, 3, 4, 5, 6, 7])).toBe(28);
expect(BI.average([1, 2, 3, 4, 5, 6, 7])).to.equal(4); expect(BI.average([1, 2, 3, 4, 5, 6, 7])).toBe(4);
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("string", function () { it("string", () => {
expect(BI.toLowerCase("AAAAA")).to.equal("aaaaa"); expect(BI.toLowerCase("AAAAA")).toBe("aaaaa");
expect(BI.isLiteral("AAAAA")).to.equal(false); expect(BI.isLiteral("AAAAA")).toBe(false);
expect(BI.stripQuotes("AAAAA")).to.equal("AAAAA"); expect(BI.stripQuotes("AAAAA")).toBe("AAAAA");
expect(BI.camelize("background-color")).to.equal("backgroundColor"); expect(BI.camelize("background-color")).toBe("backgroundColor");
expect(BI.escape("'\\")).to.equal("\\'\\\\"); expect(BI.escape("'\\")).toBe("\\'\\\\");
expect(BI.leftPad("123", 5, "0")).to.equal("00123"); expect(BI.leftPad("123", 5, "0")).toBe("00123");
const cls = "my-class", text = "Some text"; const cls = "my-class", text = "Some text";
expect(BI.format("<div class=\"{0}\">{1}</div>", cls, text)).to.equal("<div class=\"my-class\">Some text</div>"); expect(BI.format("<div class=\"{0}\">{1}</div>", cls, text)).toBe("<div class=\"my-class\">Some text</div>");
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("checkDateVoid", function () { it("checkDateVoid", () => {
const minDate = "1900-02-02"; const minDate = "1900-02-02";
const maxDate = "2099-11-29"; const maxDate = "2099-11-29";
expect(BI.checkDateVoid(1899, 2, 2, minDate, maxDate)).to.eql(["y"]); expect(BI.checkDateVoid(1899, 2, 2, minDate, maxDate)).toEqual(["y"]);
expect(BI.checkDateVoid(2100, 2, 2, minDate, maxDate)).to.eql(["y", 1]); expect(BI.checkDateVoid(2100, 2, 2, minDate, maxDate)).toEqual(["y", 1]);
expect(BI.checkDateVoid(1900, 1, 2, minDate, maxDate)).to.eql(["m"]); expect(BI.checkDateVoid(1900, 1, 2, minDate, maxDate)).toEqual(["m"]);
expect(BI.checkDateVoid(2099, 12, 2, minDate, maxDate)).to.eql(["m", 1]); expect(BI.checkDateVoid(2099, 12, 2, minDate, maxDate)).toEqual(["m", 1]);
expect(BI.checkDateVoid(1900, 2, 1, minDate, maxDate)).to.eql(["d"]); expect(BI.checkDateVoid(1900, 2, 1, minDate, maxDate)).toEqual(["d"]);
expect(BI.checkDateVoid(2099, 11, 30, minDate, maxDate)).to.eql(["d", 1]); expect(BI.checkDateVoid(2099, 11, 30, minDate, maxDate)).toEqual(["d", 1]);
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("parseDateTime", function () { it("parseDateTime", () => {
expect(BI.parseDateTime("19971109", "%y%x%d")).to.eql(BI.getDate(1997, 10, 9)); expect(BI.parseDateTime("19971109", "%y%x%d")).toEqual(BI.getDate(1997, 10, 9));
expect(BI.parseDateTime("12:34:56", "%H:%M:%S")).to.eql(BI.getDate(1935, 0, 25, 12, 34, 56)); expect(BI.parseDateTime("12:34:56", "%H:%M:%S")).toEqual(BI.getDate(1935, 0, 25, 12, 34, 56));
expect(BI.parseDateTime("1997-11-09 3:23:23 pm", "%y-%x-%d %H:%M:%S %P")).to.eql(BI.getDate(1997, 10, 9, 15, 23, 23)); expect(BI.parseDateTime("1997-11-09 3:23:23 pm", "%y-%x-%d %H:%M:%S %P")).toEqual(BI.getDate(1997, 10, 9, 15, 23, 23));
expect(BI.parseDateTime("1997-11-09 15:23:23 am", "%y-%x-%d %H:%M:%S %P")).to.eql(BI.getDate(1997, 10, 9, 3, 23, 23)); expect(BI.parseDateTime("1997-11-09 15:23:23 am", "%y-%x-%d %H:%M:%S %P")).toEqual(BI.getDate(1997, 10, 9, 3, 23, 23));
expect(BI.parseDateTime("a-b-c d:e:f", "%y-%x-%d %H:%M:%S").toString()).to.eql(BI.getDate().toString()); expect(BI.parseDateTime("a-b-c d:e:f", "%y-%x-%d %H:%M:%S").toString()).toEqual(BI.getDate().toString());
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("getDate 和 getTime", function () { it("getDate 和 getTime", () => {
expect(BI.getDate().toString()).to.eql(new Date().toString()); expect(BI.getDate().toString()).toEqual(new Date().toString());
expect(BI.getDate(1997)).to.eql(new Date(1997)); expect(BI.getDate(1997)).toEqual(new Date(1997));
expect(BI.getDate(1997, 10)).to.eql(new Date(1997, 10)); expect(BI.getDate(1997, 10)).toEqual(new Date(1997, 10));
expect(BI.getDate(1997, 10, 9)).to.eql(new Date(1997, 10, 9)); expect(BI.getDate(1997, 10, 9)).toEqual(new Date(1997, 10, 9));
expect(BI.getDate(1997, 10, 9, 12)).to.eql(new Date(1997, 10, 9, 12)); expect(BI.getDate(1997, 10, 9, 12)).toEqual(new Date(1997, 10, 9, 12));
expect(BI.getDate(1997, 10, 9, 12, 34)).to.eql(new Date(1997, 10, 9, 12, 34)); expect(BI.getDate(1997, 10, 9, 12, 34)).toEqual(new Date(1997, 10, 9, 12, 34));
expect(BI.getDate(1997, 10, 9, 12, 34, 56)).to.eql(new Date(1997, 10, 9, 12, 34, 56)); expect(BI.getDate(1997, 10, 9, 12, 34, 56)).toEqual(new Date(1997, 10, 9, 12, 34, 56));
expect(BI.getDate(1997, 10, 9, 12, 34, 56, 78)).to.eql(new Date(1997, 10, 9, 12, 34, 56, 78)); expect(BI.getDate(1997, 10, 9, 12, 34, 56, 78)).toEqual(new Date(1997, 10, 9, 12, 34, 56, 78));
expect(BI.getTime()).to.eql(new Date().getTime()); expect(BI.getTime()).toEqual(new Date().getTime());
expect(BI.getTime(1997)).to.eql(new Date(1997).getTime()); expect(BI.getTime(1997)).toEqual(new Date(1997).getTime());
expect(BI.getTime(1997, 10)).to.eql(new Date(1997, 10).getTime()); expect(BI.getTime(1997, 10)).toEqual(new Date(1997, 10).getTime());
expect(BI.getTime(1997, 10, 9)).to.eql(new Date(1997, 10, 9).getTime()); expect(BI.getTime(1997, 10, 9)).toEqual(new Date(1997, 10, 9).getTime());
expect(BI.getTime(1997, 10, 9, 12)).to.eql(new Date(1997, 10, 9, 12).getTime()); expect(BI.getTime(1997, 10, 9, 12)).toEqual(new Date(1997, 10, 9, 12).getTime());
expect(BI.getTime(1997, 10, 9, 12, 34)).to.eql(new Date(1997, 10, 9, 12, 34).getTime()); expect(BI.getTime(1997, 10, 9, 12, 34)).toEqual(new Date(1997, 10, 9, 12, 34).getTime());
expect(BI.getTime(1997, 10, 9, 12, 34, 56)).to.eql(new Date(1997, 10, 9, 12, 34, 56).getTime()); expect(BI.getTime(1997, 10, 9, 12, 34, 56)).toEqual(new Date(1997, 10, 9, 12, 34, 56).getTime());
expect(BI.getTime(1997, 10, 9, 12, 34, 56, 78)).to.eql(new Date(1997, 10, 9, 12, 34, 56, 78).getTime()); expect(BI.getTime(1997, 10, 9, 12, 34, 56, 78)).toEqual(new Date(1997, 10, 9, 12, 34, 56, 78).getTime());
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("数字相关方法补充", function () { it("数字相关方法补充", () => {
const iteratee = function (a, b) { const iteratee = function (a, b) {
return a > b ? a : b; return a > b ? a : b;
}; };
expect(BI.isNaturalNumber(1.25)).to.eql(false); expect(BI.isNaturalNumber(1.25)).toEqual(false);
expect(BI.isPositiveInteger(-15)).to.eql(false); expect(BI.isPositiveInteger(-15)).toEqual(false);
expect(BI.isNegativeInteger(+15)).to.eql(false); expect(BI.isNegativeInteger(+15)).toEqual(false);
expect(BI.isFloat(15)).to.eql(false); expect(BI.isFloat(15)).toEqual(false);
expect(BI.sum([4, 3, 2, 1], iteratee)).to.eql(12); expect(BI.sum([4, 3, 2, 1], iteratee)).toEqual(12);
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("集合相关方法补充", function () { it("集合相关方法补充", () => {
const array = [{ const array = [{
user: "barney", user: "barney",
active: true, active: true,
@ -383,39 +383,39 @@ describe("baseFunctionTest", function () {
user: "pebbles", user: "pebbles",
active: false, active: false,
}]; }];
expect(BI.backEvery(array, (index, value) => value.user === "kobi")).to.eql(false); expect(BI.backEvery(array, (index, value) => value.user === "kobi")).toEqual(false);
expect(BI.backFind(array, ["active", false])).to.eql(array[2]); expect(BI.backFind(array, ["active", false])).toEqual(array[2]);
expect(BI.abc2Int("ABCD999")).to.eql(0); expect(BI.abc2Int("ABCD999")).toEqual(0);
expect(BI.int2Abc(0)).to.eql(""); expect(BI.int2Abc(0)).toEqual("");
expect(BI.int2Abc(26)).to.eql("Z"); expect(BI.int2Abc(26)).toEqual("Z");
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("数组相关方法补充", function () { it("数组相关方法补充", () => {
expect(BI.makeArrayByArray([], 5)).to.eql([]); expect(BI.makeArrayByArray([], 5)).toEqual([]);
expect(BI.uniq(null, true, (a, b) => a > b)).to.eql([]); expect(BI.uniq(null, true, (a, b) => a > b)).toEqual([]);
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("对象相关方法补充", function () { it("对象相关方法补充", () => {
var obj = { var obj = {
a: 1, a: 1,
b: 2, b: 2,
c: 3, c: 3,
}; };
expect(BI.has(obj, [])).to.eql(false); expect(BI.has(obj, [])).toEqual(false);
expect(BI.has(obj, ["a", "b"])).to.eql(true); expect(BI.has(obj, ["a", "b"])).toEqual(true);
expect(BI.freeze("1")).to.eql("1"); expect(BI.freeze("1")).toEqual("1");
}); });
/** /**
* test_author_kobi * test_author_kobi
**/ **/
it("deep方法补充", function () { it("deep方法补充", () => {
var obj = { var obj = {
a: 1, a: 1,
b: 2, b: 2,
@ -426,19 +426,19 @@ describe("baseFunctionTest", function () {
}, },
}, },
}; };
expect(BI.isDeepMatch(null, { d: 3, e: { f: 4 } })).to.eql(false); expect(BI.isDeepMatch(null, { d: 3, e: { f: 4 } })).toEqual(false);
expect(BI.isDeepMatch(obj, { d: 3, e: { f: 5 } })).to.eql(false); expect(BI.isDeepMatch(obj, { d: 3, e: { f: 5 } })).toEqual(false);
expect(BI.deepIndexOf(obj, { d: 3, e: { f: 5 } })).to.eql(-1); expect(BI.deepIndexOf(obj, { d: 3, e: { f: 5 } })).toEqual(-1);
expect(BI.deepRemove(obj, { d: 3, e: { f: 4 } })).to.eql(true); expect(BI.deepRemove(obj, { d: 3, e: { f: 4 } })).toEqual(true);
expect(BI.deepWithout(obj, { d: 3, e: { f: 4 } })).to.eql({ a: 1, b: 2 }); expect(BI.deepWithout(obj, { d: 3, e: { f: 4 } })).toEqual({ a: 1, b: 2 });
}); });
/** /**
* test_author_teller * test_author_teller
* 只传一个时分秒format的时间进去后,在某些情况下,返回的是当前时间,然而想要的是返回正确的时分秒 * 只传一个时分秒format的时间进去后,在某些情况下,返回的是当前时间,然而想要的是返回正确的时分秒
*/ */
it("parseDateTime2", function () { it("parseDateTime2", () => {
var date = BI.getDate(); var date = BI.getDate();
expect(BI.parseDateTime("14:13:16", "%H:%M:%S").getTime()).to.eql(BI.getDate(date.getFullYear(), date.getMonth(), 14, 14, 13, 16).getTime()); expect(BI.parseDateTime("14:13:16", "%H:%M:%S").getTime()).toEqual(BI.getDate(date.getFullYear(), date.getMonth(), 14, 14, 13, 16).getTime());
}); });
}); });

24
packages/fineui/src/core/__test__/context.test.js

@ -1,15 +1,15 @@
/** /**
* Created by guy on 2018/01/23. * Created by guy on 2018/01/23.
*/ */
describe("contextTest", function () { describe("contextTest", () => {
before(function () { beforeAll(() => {
}); });
/** /**
* test_author_guy * test_author_guy
*/ */
it("context测试", function () { it("context测试", () => {
var ParentStore = BI.inherit(Fix.Model, { var ParentStore = BI.inherit(Fix.Model, {
state: function () { state: function () {
@ -70,9 +70,9 @@ describe("contextTest", function () {
type: "demo.demo" type: "demo.demo"
}); });
expect(demo.child.model.currContext).to.equal("默认context"); expect(demo.child.model.currContext).toBe("默认context");
demo.child.store.changeContext(); demo.child.store.changeContext();
expect(demo.model.context).to.equal("改变后的context"); expect(demo.model.context).toBe("改变后的context");
demo.destroy(); demo.destroy();
}); });
@ -80,7 +80,7 @@ describe("contextTest", function () {
/** /**
* test_author_guy * test_author_guy
*/ */
it("异步context测试-loader的populate测试", function (done) { it("异步context测试-loader的populate测试", done => {
var ParentStore = BI.inherit(Fix.Model, { var ParentStore = BI.inherit(Fix.Model, {
state: function () { state: function () {
@ -167,7 +167,7 @@ describe("contextTest", function () {
demo.child.populate(); demo.child.populate();
setTimeout(function () { setTimeout(function () {
expect(demo.labels[0].model.currContext).to.equal("默认context"); expect(demo.labels[0].model.currContext).toBe("默认context");
demo.destroy(); demo.destroy();
done(); done();
}, 0); }, 0);
@ -176,7 +176,7 @@ describe("contextTest", function () {
/** /**
* test_author_guy * test_author_guy
*/ */
it("异步context测试-beforeInit测试", function (done) { it("异步context测试-beforeInit测试", done => {
var ParentStore = BI.inherit(Fix.Model, { var ParentStore = BI.inherit(Fix.Model, {
state: function () { state: function () {
@ -242,7 +242,7 @@ describe("contextTest", function () {
}); });
setTimeout(function () { setTimeout(function () {
expect(demo.child.model.currContext).to.equal("默认context"); expect(demo.child.model.currContext).toBe("默认context");
demo.destroy(); demo.destroy();
done(); done();
}, 0); }, 0);
@ -251,7 +251,7 @@ describe("contextTest", function () {
/** /**
* test_author_guy * test_author_guy
*/ */
it("inject测试", function () { it("inject测试", () => {
var ParentStore = BI.inherit(Fix.Model, { var ParentStore = BI.inherit(Fix.Model, {
state: function () { state: function () {
@ -312,9 +312,9 @@ describe("contextTest", function () {
type: "demo.demo" type: "demo.demo"
}); });
expect(demo.child.model.currContext).to.equal("默认context"); expect(demo.child.model.currContext).toBe("默认context");
demo.child.store.changeContext(); demo.child.store.changeContext();
expect(demo.model.context).to.equal("默认context"); expect(demo.model.context).toBe("默认context");
demo.destroy(); demo.destroy();
}); });

8
packages/fineui/src/core/__test__/widget.test.js

@ -1,15 +1,15 @@
/** /**
* Created by guy on 2018/01/23. * Created by guy on 2018/01/23.
*/ */
describe("widgetTest", function () { describe("widgetTest", () => {
before(function () { beforeAll(() => {
}); });
/** /**
* test_author_guy * test_author_guy
*/ */
it("widget生命周期测试", function () { it("widget生命周期测试", () => {
var Demo = BI.inherit(BI.Widget, { var Demo = BI.inherit(BI.Widget, {
render: function () { render: function () {
@ -31,7 +31,7 @@ describe("widgetTest", function () {
} }
}); });
expect(demo.element.text()).to.equal("new"); expect(demo.element.text()).toBe("new");
demo.destroy(); demo.destroy();
}); });

11
packages/fineui/src/core/constant/writable.var.js

@ -138,13 +138,4 @@ addDescriptor("DOM", {
addDescriptor("nextTick", { addDescriptor("nextTick", {
get: () => nextTick, get: () => nextTick,
set: setNextTick, set: setNextTick,
}); });
export let PasteLimit = 2000;
export const setPasteLimit = v => {
PasteLimit = v;
};
addDescriptor("PasteLimit", {
get: () => PasteLimit,
set: setPasteLimit,
});

6
packages/fineui/src/core/controller/controller.broadcast.js

@ -16,13 +16,13 @@ export class BroadcastController extends Controller {
this._broadcasts[name] = []; this._broadcasts[name] = [];
} }
this._broadcasts[name].push(fn); this._broadcasts[name].push(fn);
return () => this.remove(name, fn); return () => this.remove(name, fn);
} }
send(name) { send(name) {
const args = [].slice.call(arguments, 1); const args = [].slice.call(arguments, 1);
each(this._broadcasts[name]?.slice?.(), (i, fn) => fn(...args)); each(this._broadcasts[name], (i, fn) => fn(...args));
} }
remove(name, fn) { remove(name, fn) {
@ -34,7 +34,7 @@ export class BroadcastController extends Controller {
} else { } else {
delete this._broadcasts[name]; delete this._broadcasts[name];
} }
return this; return this;
} }
} }

2
packages/fineui/src/core/controller/controller.layer.js

@ -108,7 +108,7 @@ export class LayerController extends Controller {
height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || "", height: offset.height || (w.outerHeight() - (offset.top || 0) - (offset.bottom || 0)) || "",
}; };
const { top, left, scaleY, scaleX } = getPositionRelativeContainingBlockRect(layout.element[0].parentNode || layout.element[0]); const { top, left, scaleY, scaleX } = getPositionRelativeContainingBlockRect(layout.element[0]);
css.top = (css.top - top) / scaleY; css.top = (css.top - top) / scaleY;
css.left = (css.left - left) / scaleX; css.left = (css.left - left) / scaleX;

38
packages/fineui/src/core/func/__test__/date.test.js

@ -1,31 +1,31 @@
/** /**
* Created by windy on 2018/01/23. * Created by windy on 2018/01/23.
*/ */
describe("dateFunctionTest", function () { describe("dateFunctionTest", () => {
before(function () { beforeAll(() => {
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("getWeekNumber", function () { it("getWeekNumber", () => {
expect(BI.print(BI.getDate(2005, 0, 1), "%Y-%W")).to.equal("2004-53"); expect(BI.print(BI.getDate(2005, 0, 1), "%Y-%W")).toBe("2004-53");
expect(BI.print(BI.getDate(2005, 0, 2), "%Y-%W")).to.equal("2004-53"); expect(BI.print(BI.getDate(2005, 0, 2), "%Y-%W")).toBe("2004-53");
expect(BI.print(BI.getDate(2005, 11, 31), "%Y-%W")).to.equal("2005-52"); expect(BI.print(BI.getDate(2005, 11, 31), "%Y-%W")).toBe("2005-52");
expect(BI.print(BI.getDate(2007, 0, 1), "%Y-%W")).to.equal("2007-01"); expect(BI.print(BI.getDate(2007, 0, 1), "%Y-%W")).toBe("2007-01");
expect(BI.print(BI.getDate(2007, 11, 30), "%Y-%W")).to.equal("2007-52"); expect(BI.print(BI.getDate(2007, 11, 30), "%Y-%W")).toBe("2007-52");
expect(BI.print(BI.getDate(2007, 11, 31), "%Y-%W")).to.equal("2008-01"); expect(BI.print(BI.getDate(2007, 11, 31), "%Y-%W")).toBe("2008-01");
expect(BI.print(BI.getDate(2008, 0, 1), "%Y-%W")).to.equal("2008-01"); expect(BI.print(BI.getDate(2008, 0, 1), "%Y-%W")).toBe("2008-01");
expect(BI.print(BI.getDate(2008, 11, 28), "%Y-%W")).to.equal("2008-52"); expect(BI.print(BI.getDate(2008, 11, 28), "%Y-%W")).toBe("2008-52");
expect(BI.print(BI.getDate(2008, 11, 29), "%Y-%W")).to.equal("2009-01"); expect(BI.print(BI.getDate(2008, 11, 29), "%Y-%W")).toBe("2009-01");
expect(BI.print(BI.getDate(2008, 11, 30), "%Y-%W")).to.equal("2009-01"); expect(BI.print(BI.getDate(2008, 11, 30), "%Y-%W")).toBe("2009-01");
expect(BI.print(BI.getDate(2008, 11, 31), "%Y-%W")).to.equal("2009-01"); expect(BI.print(BI.getDate(2008, 11, 31), "%Y-%W")).toBe("2009-01");
expect(BI.print(BI.getDate(2009, 0, 1), "%Y-%W")).to.equal("2009-01"); expect(BI.print(BI.getDate(2009, 0, 1), "%Y-%W")).toBe("2009-01");
expect(BI.print(BI.getDate(2009, 11, 31), "%Y-%W")).to.equal("2009-53"); expect(BI.print(BI.getDate(2009, 11, 31), "%Y-%W")).toBe("2009-53");
expect(BI.print(BI.getDate(2010, 0, 1), "%Y-%W")).to.equal("2009-53"); expect(BI.print(BI.getDate(2010, 0, 1), "%Y-%W")).toBe("2009-53");
expect(BI.print(BI.getDate(2010, 0, 2), "%Y-%W")).to.equal("2009-53"); expect(BI.print(BI.getDate(2010, 0, 2), "%Y-%W")).toBe("2009-53");
expect(BI.print(BI.getDate(2010, 0, 3), "%Y-%W")).to.equal("2009-53"); expect(BI.print(BI.getDate(2010, 0, 3), "%Y-%W")).toBe("2009-53");
}); });
}); });

14
packages/fineui/src/core/func/__test__/function.test.js

@ -3,22 +3,22 @@
* @Maintainers: lei.wang * @Maintainers: lei.wang
* @Date: 2019-04-16 * @Date: 2019-04-16
*/ */
describe("core-function-test", function () { describe("core-function-test", () => {
/** /**
* test_author_lei.wang * test_author_lei.wang
*/ */
it("createDistinctName-支持字符串数组", function () { it("createDistinctName-支持字符串数组", () => {
const names = ["name", "name1"]; const names = ["name", "name1"];
expect(BI.Func.createDistinctName(names, "name")).to.equal("name2"); expect(BI.Func.createDistinctName(names, "name")).toBe("name2");
expect(BI.Func.createDistinctName(names, "name2")).to.equal("name2"); expect(BI.Func.createDistinctName(names, "name2")).toBe("name2");
}); });
/** /**
* test_author_lei.wang * test_author_lei.wang
*/ */
it("createDistinctName-支持对象数组数组", function () { it("createDistinctName-支持对象数组数组", () => {
const names = [{ name: "name" }, { name: "name1" }]; const names = [{ name: "name" }, { name: "name1" }];
expect(BI.Func.createDistinctName(names, "name")).to.equal("name2"); expect(BI.Func.createDistinctName(names, "name")).toBe("name2");
expect(BI.Func.createDistinctName(names, "name2")).to.equal("name2"); expect(BI.Func.createDistinctName(names, "name2")).toBe("name2");
}); });
}); });

10
packages/fineui/src/core/func/__test__/string.test.js

@ -3,17 +3,17 @@
* @version 2.0 * @version 2.0
* Created by windy on 2020/6/5 * Created by windy on 2020/6/5
*/ */
describe("dateFunctionTest", function () { describe("dateFunctionTest", () => {
before(function () { beforeAll(() => {
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("getWeekNumber", function () { it("getWeekNumber", () => {
expect(BI.replaceAll(null, "A", "b")).to.equal(null); expect(BI.replaceAll(null, "A", "b")).toBeNull();
expect(BI.replaceAll("A", "A", "b")).to.equal("b"); expect(BI.replaceAll("A", "A", "b")).toBe("b");
}); });
}); });

7
packages/fineui/src/core/func/alias.js

@ -9,8 +9,7 @@ import {
leftPad, leftPad,
parseDateTime, parseDateTime,
values, values,
isArray, isArray
getDate
} from "../2.base"; } from "../2.base";
import { replaceAll } from "./string"; import { replaceAll } from "./string";
import { getFullDayName, getMonthName, getTimezone } from "./date"; import { getFullDayName, getMonthName, getTimezone } from "./date";
@ -681,10 +680,10 @@ export const contentFormat = function(cv, fmt) {
if (!(cv instanceof Date)) { if (!(cv instanceof Date)) {
if (typeof cv === "number") { if (typeof cv === "number") {
// 毫秒数类型 // 毫秒数类型
cv = getDate(cv); cv = new Date(cv);
} else { } else {
// 字符串类型转化为date类型 // 字符串类型转化为date类型
cv = getDate(Date.parse((`${cv}`).replace(/-|\./g, "/"))); cv = new Date(Date.parse((`${cv}`).replace(/-|\./g, "/")));
} }
} }
if (!isInvalidDate(cv) && !isNull(cv)) { if (!isInvalidDate(cv) && !isNull(cv)) {

36
packages/fineui/src/core/platform/web/jquery/__test__/fn.test.js

@ -4,73 +4,79 @@
* Created by windy on 2019/12/9 * Created by windy on 2019/12/9
*/ */
describe("标红test", function () { describe("标红test", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("无多音字标红", function () { it("无多音字标红", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.layout", type: "bi.layout",
}); });
a.element.__textKeywordMarked__("无多音字", "w"); a.element.__textKeywordMarked__("无多音字", "w");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">无</span>多音字"); expect(a.element.html()).toBe("<span class=\"bi-keyword-red-mark\">无</span>多音字");
a.destroy(); a.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("含有多音字标红", function () { it("含有多音字标红", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.layout", type: "bi.layout",
}); });
a.element.__textKeywordMarked__("长期协议", "z"); a.element.__textKeywordMarked__("长期协议", "z");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">长</span>期协议"); expect(a.element.html()).toBe("<span class=\"bi-keyword-red-mark\">长</span>期协议");
a.element.__textKeywordMarked__("长期协议", "c"); a.element.__textKeywordMarked__("长期协议", "c");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">长</span>期协议"); expect(a.element.html()).toBe("<span class=\"bi-keyword-red-mark\">长</span>期协议");
a.destroy(); a.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("多音字错位标红", function () { it("多音字错位标红", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.layout", type: "bi.layout",
}); });
a.element.__textKeywordMarked__("呵呵呵", "h"); a.element.__textKeywordMarked__("呵呵呵", "h");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">呵</span><span class=\"bi-keyword-red-mark\">呵</span><span class=\"bi-keyword-red-mark\">呵</span>"); expect(a.element.html()).toBe(
"<span class=\"bi-keyword-red-mark\">呵</span><span class=\"bi-keyword-red-mark\">呵</span><span class=\"bi-keyword-red-mark\">呵</span>"
);
a.element.__textKeywordMarked__("呵呵呵", "hh"); a.element.__textKeywordMarked__("呵呵呵", "hh");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">呵呵</span>呵"); expect(a.element.html()).toBe("<span class=\"bi-keyword-red-mark\">呵呵</span>呵");
a.element.__textKeywordMarked__("呵呵呵", "hhh"); a.element.__textKeywordMarked__("呵呵呵", "hhh");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">呵呵呵</span>"); expect(a.element.html()).toBe("<span class=\"bi-keyword-red-mark\">呵呵呵</span>");
a.destroy(); a.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("原文和拼音都匹配标红", function () { it("原文和拼音都匹配标红", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.layout", type: "bi.layout",
}); });
a.element.__textKeywordMarked__("啊a", "a"); a.element.__textKeywordMarked__("啊a", "a");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">啊</span><span class=\"bi-keyword-red-mark\">a</span>"); expect(a.element.html()).toBe(
"<span class=\"bi-keyword-red-mark\">啊</span><span class=\"bi-keyword-red-mark\">a</span>"
);
a.element.__textKeywordMarked__("a啊", "a"); a.element.__textKeywordMarked__("a啊", "a");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">a</span><span class=\"bi-keyword-red-mark\">啊</span>"); expect(a.element.html()).toBe(
"<span class=\"bi-keyword-red-mark\">a</span><span class=\"bi-keyword-red-mark\">啊</span>"
);
a.destroy(); a.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("中文拼音", function () { it("中文拼音", () => {
var a = BI.Test.createWidget({ var a = BI.Test.createWidget({
type: "bi.layout", type: "bi.layout",
}); });
a.element.__textKeywordMarked__("日期", "日期"); a.element.__textKeywordMarked__("日期", "日期");
expect(a.element.html()).to.equal("<span class=\"bi-keyword-red-mark\">日期</span>"); expect(a.element.html()).toBe("<span class=\"bi-keyword-red-mark\">日期</span>");
a.destroy(); a.destroy();
}); });
}); });

10
packages/fineui/src/core/utils/__test__/aes.test.js

@ -4,23 +4,23 @@
* @LastEditor: fay * @LastEditor: fay
* @LastEditTime: 2020-03-02 16:56:43 * @LastEditTime: 2020-03-02 16:56:43
*/ */
describe("aesDecrypt", function () { describe("aesDecrypt", () => {
/** /**
* test_author_fay * test_author_fay
*/ */
it("aesEncrypt", function () { it("aesEncrypt", () => {
var text = "test"; var text = "test";
expect(BI.aesEncrypt(text, "0123456789ABCDEF")).to.eql("0No4i/uz2cfoo6zQMHaL1A=="); expect(BI.aesEncrypt(text, "0123456789ABCDEF")).toEqual("0No4i/uz2cfoo6zQMHaL1A==");
}); });
/** /**
* test_author_fay * test_author_fay
*/ */
it("aesDecrypt", function () { it("aesDecrypt", () => {
var text = "0No4i/uz2cfoo6zQMHaL1A=="; var text = "0No4i/uz2cfoo6zQMHaL1A==";
expect(BI.aesDecrypt(text, "0123456789ABCDEF")).to.eql("test"); expect(BI.aesDecrypt(text, "0123456789ABCDEF")).toEqual("test");
}); });
}); });

38
packages/fineui/src/core/utils/dom.js

@ -2,7 +2,7 @@
* 对DOM操作的通用函数 * 对DOM操作的通用函数
*/ */
import $ from "jquery"; import $ from "jquery";
import { each, isEmpty, isNotEmptyObject } from "../2.base"; import { each, isEmpty, isNotNull, isNull } from "../2.base";
import { Widget } from "../4.widget"; import { Widget } from "../4.widget";
import { isIE } from "./../platform"; import { isIE } from "./../platform";
@ -102,37 +102,23 @@ export function getTextSizeHeight(text, fontSize = 12) {
} }
// 获取滚动条的宽度,页面display: none时候获取到的为0 // 获取滚动条的宽度,页面display: none时候获取到的为0
const _scrollWidthMap = {}; let _scrollWidth = null;
export function getScrollWidth(css) { export function getScrollWidth(css) {
/** if (isNull(_scrollWidth) || isNotNull(css) || _scrollWidth === 0) {
* 指定 scrollbar-width: none; const ul = Widget._renderEngine.createElement("<div>").width(50).height(50)
* 支持的浏览器版本结果肯定为 0无需重复计算
*/
const supportScrollWidth = 'scrollbarWidth' in document.documentElement.style;
const hasNoneScrollWidth =
supportScrollWidth && isNotEmptyObject(css) && [css["scrollbar-width"], css["scrollbarWidth"]].includes("none");
const key = JSON.stringify(css) || "default";
if (hasNoneScrollWidth) {
return 0;
} else if (!_scrollWidthMap[key]) {
const ul = Widget._renderEngine
.createElement("<div>")
.width(50)
.height(50)
.css({ .css({
position: "absolute", position: "absolute",
top: "-9999px", top: "-9999px",
overflow: "scroll", overflow: "scroll",
...css, ...css
}) })
.appendTo("body"); .appendTo("body");
_scrollWidthMap[key] = ul[0].offsetWidth - ul[0].clientWidth; _scrollWidth = ul[0].offsetWidth - ul[0].clientWidth;
ul.destroy(); ul.destroy();
} }
return _scrollWidthMap[key]; return _scrollWidth;
} }
export function getImage(param, fillStyle, backgroundColor) { export function getImage(param, fillStyle, backgroundColor) {
@ -757,13 +743,11 @@ export function getComboPosition(combo, popup, extraWidth, extraHeight, needAdap
} }
if (needAdaptHeight === true && popup.resetHeight) { if (needAdaptHeight === true && popup.resetHeight) {
const comboRect = combo.element[0].getBoundingClientRect(); const comboRect = combo.element[0].getBoundingClientRect();
const scale = comboRect.height === 0 ? 1 : comboRect.height / combo.element.height();
const relativeOffset = positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0; const relativeOffset = positionRelativeElement ? positionRelativeElement.getBoundingClientRect().top : 0;
const positionTop = position.top + relativeOffset; if (position.top < comboRect.top) {
if (positionTop < comboRect.top) { popup.resetHeight(Math.min(viewportBounds.height - position.top - relativeOffset, comboRect.top, maxHeight));
popup.resetHeight(Math.min((viewportBounds.height - positionTop) / scale, comboRect.top / scale, maxHeight)); } else if (position.top >= comboRect.bottom) {
} else if (positionTop >= comboRect.bottom) { popup.resetHeight(Math.min(viewportBounds.height - position.top - relativeOffset, viewportBounds.height - comboRect.bottom, maxHeight));
popup.resetHeight(Math.min((viewportBounds.height - positionTop) / scale, (viewportBounds.height - comboRect.bottom) / scale, maxHeight));
} }
} }

8
packages/fineui/src/less/base/colorchooser/colorpicker/button.colorshow.less

@ -4,12 +4,4 @@
&.active, &:active { &.active, &:active {
border-color: @color-bi-border-active-chooser-show-button; border-color: @color-bi-border-active-chooser-show-button;
} }
}
.bi-theme-dark {
.bi-color-chooser-show-button {
&.active, &:active {
border-color: @color-bi-border-active-chooser-show-button-theme-dark;
}
}
} }

16
packages/fineui/src/less/base/single/button/button.less

@ -578,12 +578,6 @@ body .bi-button, #body .bi-button {
.bi-theme-dark, #body .bi-theme-dark { .bi-theme-dark, #body .bi-theme-dark {
.bi-button { .bi-button {
background-color: @color-bi-background-button-theme-dark;
&.clear {
background-color: transparent;
}
&.button-ignore { &.button-ignore {
background-color: @color-bi-background-ignore-button-theme-dark; background-color: @color-bi-background-ignore-button-theme-dark;
@ -649,15 +643,5 @@ body .bi-button, #body .bi-button {
} }
} }
} }
&.button-common {
&.light {
background-color: @color-bi-background-common-light-button-theme-dark;
&, & .b-font:before {
color: @color-bi-text-common-light-button-theme-dark;
}
}
}
} }
} }

2
packages/fineui/src/less/base/single/button/switch.less

@ -25,7 +25,7 @@
.bi-switch { .bi-switch {
background-color: @color-bi-background-switch-theme-dark; background-color: @color-bi-background-switch-theme-dark;
&.active { &.active {
background-color: @color-bi-background-active-switch-theme-dark; background-color: @color-bi-background-active-switch;
} }
} }
} }

7
packages/fineui/src/less/base/tree/ztree.less

@ -335,10 +335,3 @@
margin-right: 2px; margin-right: 2px;
vertical-align: top; vertical-align: top;
} }
.ztree .button-loading-font {
.use-scale(width, 20px);
.use-scale(height, 20px);
.use-scale(left, 5px);
.use-scale(top, 5px);
}

6
packages/fineui/src/less/core/utils/common.less

@ -104,10 +104,6 @@
.bi-theme-dark { .bi-theme-dark {
.bi-focus-shadow { .bi-focus-shadow {
&:focus, &:hover {
border-color: @color-bi-border-highlight-theme-dark;
}
&.disabled { &.disabled {
&:hover { &:hover {
border-color: @border-color-line-theme-dark; border-color: @border-color-line-theme-dark;
@ -146,7 +142,7 @@
.bi-theme-dark { .bi-theme-dark {
.bi-background { .bi-background {
background-color: @color-bi-background-theme-dark; background-color: @color-bi-background-normal-theme-dark;
color: @color-bi-text-background-theme-dark; color: @color-bi-text-background-theme-dark;
& .bi-input { & .bi-input {

6
packages/fineui/src/less/core/utils/list-item.less

@ -161,12 +161,12 @@
} }
} }
&.active, &:active { &.active, &:active {
color: @color-bi-text-highlight-theme-dark; color: @color-bi-text-highlight;
& .bi-input { & .bi-input {
color: @color-bi-text-highlight-theme-dark; color: @color-bi-text-highlight;
} }
& .bi-textarea { & .bi-textarea {
color: @color-bi-text-highlight-theme-dark; color: @color-bi-text-highlight;
} }
} }
&.disabled { &.disabled {

3
packages/fineui/src/less/lib/colors.less

@ -38,7 +38,6 @@
//基本提亮颜色 //基本提亮颜色
@color-bi-text-highlight: @font-color-highlight; @color-bi-text-highlight: @font-color-highlight;
@color-bi-text-highlight-theme-dark: @font-color-highlight;
//标红色 //标红色
@color-bi-text-redmark: @font-color-warning; @color-bi-text-redmark: @font-color-warning;
@ -51,7 +50,6 @@
@color-bi-background-normal: @background-color-normal; @color-bi-background-normal: @background-color-normal;
//深色主题普通背景 //深色主题普通背景
@color-bi-background-normal-theme-dark: @background-color-normal-theme-dark; @color-bi-background-normal-theme-dark: @background-color-normal-theme-dark;
@color-bi-background-theme-dark: @background-color-normal-theme-dark;
//默认背景 //默认背景
@color-bi-background-default: @background-color-default; @color-bi-background-default: @background-color-default;
//深色主题默认背景 //深色主题默认背景
@ -134,6 +132,5 @@
@color-bi-border-warning: @border-color-warning; @color-bi-border-warning: @border-color-warning;
//边框提亮 //边框提亮
@color-bi-border-highlight: @border-color-highlight; @color-bi-border-highlight: @border-color-highlight;
@color-bi-border-highlight-theme-dark: @border-color-highlight;
@color-bi-alert-warning: @color-bi-orange; @color-bi-alert-warning: @color-bi-orange;

4
packages/fineui/src/less/lib/theme.less

@ -62,7 +62,6 @@
// 按钮 // 按钮
@color-bi-border-button: @color-bi-border-highlight; @color-bi-border-button: @color-bi-border-highlight;
@color-bi-background-button: @color-bi-background-highlight; @color-bi-background-button: @color-bi-background-highlight;
@color-bi-background-button-theme-dark: @color-bi-background-highlight;
@color-bi-text-common-button: @color-bi-text; @color-bi-text-common-button: @color-bi-text;
@color-bi-text-common-clear-button: @color-bi-text-highlight; @color-bi-text-common-clear-button: @color-bi-text-highlight;
@color-bi-text-common-plain-button: @color-bi-text-highlight; @color-bi-text-common-plain-button: @color-bi-text-highlight;
@ -76,9 +75,7 @@
@color-bi-background-hover-common-ghost-button-theme-dark: @color-bi-background-default; @color-bi-background-hover-common-ghost-button-theme-dark: @color-bi-background-default;
@color-bi-text-common-light-button: @color-bi-text-highlight; @color-bi-text-common-light-button: @color-bi-text-highlight;
@color-bi-text-common-light-button-theme-dark: @color-bi-text-highlight;
@color-bi-background-common-light-button: @color-bi-background-light-blue; @color-bi-background-common-light-button: @color-bi-background-light-blue;
@color-bi-background-common-light-button-theme-dark: @color-bi-background-light-blue;
@color-bi-background-hover-common-light-button: @color-bi-background-light-blue; @color-bi-background-hover-common-light-button: @color-bi-background-light-blue;
@color-bi-background-active-common-light-button: @color-bi-background-light-blue; @color-bi-background-active-common-light-button: @color-bi-background-light-blue;
@color-bi-background-hover-plain-button: @color-black-5; @color-bi-background-hover-plain-button: @color-black-5;
@ -205,7 +202,6 @@
@color-bi-border-picker-button-mask: @color-bi-border-black; @color-bi-border-picker-button-mask: @color-bi-border-black;
@color-bi-border-picker-button-mask-theme-dark: @color-bi-border-default; @color-bi-border-picker-button-mask-theme-dark: @color-bi-border-default;
@color-bi-border-active-chooser-show-button: @color-bi-border-highlight; @color-bi-border-active-chooser-show-button: @color-bi-border-highlight;
@color-bi-border-active-chooser-show-button-theme-dark: @color-bi-border-highlight;
@color-bi-background-disabled-chooser-popup-mask: @color-bi-background-default; @color-bi-background-disabled-chooser-popup-mask: @color-bi-background-default;
// combo // combo
@color-bi-border-hover-combo: @color-bi-border-highlight; @color-bi-border-hover-combo: @color-bi-border-highlight;

32
packages/fineui/src/widget/datepane/__test__/datepane.test.js

@ -4,12 +4,12 @@
* Created by windy on 2019/9/2 * Created by windy on 2019/9/2
*/ */
describe("DatePane", function () { describe("DatePane", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("defaultValue", function () { it("defaultValue", () => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_pane", type: "bi.dynamic_date_pane",
value: { value: {
@ -21,16 +21,16 @@ describe("DatePane", function () {
} }
}, },
}); });
expect(datePane.element.find(".bi-year-combo .bi-label").text()).to.equal("2017"); expect(datePane.element.find(".bi-year-combo .bi-label").text()).toBe("2017");
expect(datePane.element.find(".bi-month-combo .bi-label").text()).to.equal("12"); expect(datePane.element.find(".bi-month-combo .bi-label").text()).toBe("12");
expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).to.equal("11"); expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).toBe("11");
datePane.destroy(); datePane.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("setStaticValue", function () { it("setStaticValue", () => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_pane", type: "bi.dynamic_date_pane",
}); });
@ -42,16 +42,16 @@ describe("DatePane", function () {
day: 11 day: 11
} }
}); });
expect(datePane.element.find(".bi-year-combo .bi-label").text()).to.equal("2017"); expect(datePane.element.find(".bi-year-combo .bi-label").text()).toBe("2017");
expect(datePane.element.find(".bi-month-combo .bi-label").text()).to.equal("12"); expect(datePane.element.find(".bi-month-combo .bi-label").text()).toBe("12");
expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).to.equal("11"); expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).toBe("11");
datePane.destroy(); datePane.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("setDynamicValue", function () { it("setDynamicValue", () => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_pane", type: "bi.dynamic_date_pane",
}); });
@ -65,7 +65,7 @@ describe("DatePane", function () {
day: 1 day: 1
} }
}); });
expect(datePane.element.find(".bi-line-segment-button.active").text()).to.equal("动态时间"); expect(datePane.element.find(".bi-line-segment-button.active").text()).toBe("动态时间");
datePane.setValue({ datePane.setValue({
type: 2, type: 2,
@ -73,14 +73,14 @@ describe("DatePane", function () {
workDay: 1 workDay: 1
} }
}); });
expect(datePane.element.find(".bi-line-segment-button.active").text()).to.equal("动态时间"); expect(datePane.element.find(".bi-line-segment-button.active").text()).toBe("动态时间");
datePane.destroy(); datePane.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("getStaticValue", function (done) { it("getStaticValue", done => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_pane", type: "bi.dynamic_date_pane",
value: { value: {
@ -97,7 +97,7 @@ describe("DatePane", function () {
datePane.element.find(".bi-month-combo .bi-list-item-select").get(2).click(); datePane.element.find(".bi-month-combo .bi-list-item-select").get(2).click();
BI.nextTick(function () { BI.nextTick(function () {
datePane.element.find(".bi-calendar:visible .bi-list-item-select :contains(27)").parent().click(); datePane.element.find(".bi-calendar:visible .bi-list-item-select :contains(27)").parent().click();
expect(datePane.getValue()).to.deep.equal({ expect(datePane.getValue()).toEqual({
type: 1, type: 1,
value: { value: {
year: 2019, year: 2019,
@ -114,7 +114,7 @@ describe("DatePane", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("getDynamicValue", function (done) { it("getDynamicValue", done => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_pane", type: "bi.dynamic_date_pane",
value: { value: {
@ -129,7 +129,7 @@ describe("DatePane", function () {
BI.nextTick(function () { BI.nextTick(function () {
datePane.element.find(".bi-multi-select-item.active").click(); datePane.element.find(".bi-multi-select-item.active").click();
datePane.element.find(".bi-multi-select-item").click(); datePane.element.find(".bi-multi-select-item").click();
expect(datePane.getValue()).to.deep.equal({ expect(datePane.getValue()).toEqual({
type: 2, type: 2,
value: { value: {
workDay: -0 workDay: -0

16
packages/fineui/src/widget/datetime/__test__/datetime.test.js

@ -4,9 +4,9 @@
* Created by windy on 2019/9/6 * Created by windy on 2019/9/6
*/ */
describe("DateTime", function () { describe("DateTime", () => {
before(function () { beforeAll(() => {
BI.holidays = { BI.holidays = {
"2010-02-28": true, "2010-02-28": true,
"2010-02-27": true "2010-02-27": true
@ -16,7 +16,7 @@ describe("DateTime", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("defaultValue", function () { it("defaultValue", () => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.date_time_combo", type: "bi.date_time_combo",
value: { value: {
@ -28,14 +28,14 @@ describe("DateTime", function () {
second: 12 second: 12
} }
}); });
expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).toBe("2018-02-23 12:12:12");
dateCombo.destroy(); dateCombo.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击确定选值", function (done) { it("点击确定选值", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.date_time_combo", type: "bi.date_time_combo",
value: { value: {
@ -51,7 +51,7 @@ describe("DateTime", function () {
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click(); dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click();
dateCombo.element.find(".bi-date-time-popup .bi-text:contains(确定)").parent().click(); dateCombo.element.find(".bi-date-time-popup .bi-text:contains(确定)").parent().click();
expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-16 12:12:12"); expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).toBe("2018-02-16 12:12:12");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}) })
@ -61,7 +61,7 @@ describe("DateTime", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击取消不选值", function (done) { it("点击取消不选值", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.date_time_combo", type: "bi.date_time_combo",
value: { value: {
@ -77,7 +77,7 @@ describe("DateTime", function () {
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click(); dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(16)").parent().click();
dateCombo.element.find(".bi-date-time-popup .bi-text:contains(取消)").parent().click(); dateCombo.element.find(".bi-date-time-popup .bi-text:contains(取消)").parent().click();
expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).toBe("2018-02-23 12:12:12");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}) })

32
packages/fineui/src/widget/datetimepane/__test__/datetimepane.test.js

@ -9,12 +9,12 @@
* Created by windy on 2019/9/2 * Created by windy on 2019/9/2
*/ */
describe("DateTimePane", function () { describe("DateTimePane", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("defaultValue", function () { it("defaultValue", () => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_time_pane", type: "bi.dynamic_date_time_pane",
value: { value: {
@ -26,16 +26,16 @@ describe("DateTimePane", function () {
} }
}, },
}); });
expect(datePane.element.find(".bi-year-combo .bi-label").text()).to.equal("2017"); expect(datePane.element.find(".bi-year-combo .bi-label").text()).toBe("2017");
expect(datePane.element.find(".bi-month-combo .bi-label").text()).to.equal("12"); expect(datePane.element.find(".bi-month-combo .bi-label").text()).toBe("12");
expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).to.equal("11"); expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).toBe("11");
datePane.destroy(); datePane.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("setStaticValue", function () { it("setStaticValue", () => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_time_pane", type: "bi.dynamic_date_time_pane",
}); });
@ -47,16 +47,16 @@ describe("DateTimePane", function () {
day: 11 day: 11
} }
}); });
expect(datePane.element.find(".bi-year-combo .bi-label").text()).to.equal("2017"); expect(datePane.element.find(".bi-year-combo .bi-label").text()).toBe("2017");
expect(datePane.element.find(".bi-month-combo .bi-label").text()).to.equal("12"); expect(datePane.element.find(".bi-month-combo .bi-label").text()).toBe("12");
expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).to.equal("11"); expect(datePane.element.find(".bi-calendar .bi-list-item-select.active .bi-text").text()).toBe("11");
datePane.destroy(); datePane.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("setDynamicValue", function () { it("setDynamicValue", () => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_time_pane", type: "bi.dynamic_date_time_pane",
}); });
@ -70,7 +70,7 @@ describe("DateTimePane", function () {
day: 1 day: 1
} }
}); });
expect(datePane.element.find(".bi-line-segment-button.active").text()).to.equal("动态时间"); expect(datePane.element.find(".bi-line-segment-button.active").text()).toBe("动态时间");
datePane.setValue({ datePane.setValue({
type: 2, type: 2,
@ -78,14 +78,14 @@ describe("DateTimePane", function () {
workDay: 1 workDay: 1
} }
}); });
expect(datePane.element.find(".bi-line-segment-button.active").text()).to.equal("动态时间"); expect(datePane.element.find(".bi-line-segment-button.active").text()).toBe("动态时间");
datePane.destroy(); datePane.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("getStaticValue", function (done) { it("getStaticValue", done => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_time_pane", type: "bi.dynamic_date_time_pane",
value: { value: {
@ -103,7 +103,7 @@ describe("DateTimePane", function () {
BI.nextTick(function () { BI.nextTick(function () {
datePane.element.find(".bi-calendar:visible .bi-list-item-select :contains(27)").parent().click(); datePane.element.find(".bi-calendar:visible .bi-list-item-select :contains(27)").parent().click();
datePane.element.find(".bi-date-time-select .bi-number-editor .top-button").get(0).click(); datePane.element.find(".bi-date-time-select .bi-number-editor .top-button").get(0).click();
expect(datePane.getValue()).to.deep.equal({ expect(datePane.getValue()).toEqual({
type: 1, type: 1,
value: { value: {
year: 2019, year: 2019,
@ -123,7 +123,7 @@ describe("DateTimePane", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("getDynamicValue", function (done) { it("getDynamicValue", done => {
var datePane = BI.Test.createWidget({ var datePane = BI.Test.createWidget({
type: "bi.dynamic_date_time_pane", type: "bi.dynamic_date_time_pane",
value: { value: {
@ -138,7 +138,7 @@ describe("DateTimePane", function () {
BI.nextTick(function () { BI.nextTick(function () {
datePane.element.find(".bi-multi-select-item.active").click(); datePane.element.find(".bi-multi-select-item.active").click();
datePane.element.find(".bi-multi-select-item").click(); datePane.element.find(".bi-multi-select-item").click();
expect(datePane.getValue()).to.deep.equal({ expect(datePane.getValue()).toEqual({
type: 2, type: 2,
value: { value: {
workDay: -0 workDay: -0

14
packages/fineui/src/widget/downlist/__test__/downlist.test.js

@ -4,19 +4,19 @@
* Created by windy on 2019/9/3 * Created by windy on 2019/9/3
*/ */
describe("DownListCombo", function () { describe("DownListCombo", () => {
/** /**
* test_author_windy * test_author_windy
*/ */
it("defaultValue", function () { it("defaultValue", () => {
var downListCombo = BI.Test.createWidget({ var downListCombo = BI.Test.createWidget({
type: "bi.down_list_combo", type: "bi.down_list_combo",
adjustLength: 10, adjustLength: 10,
items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]] items: [[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":12},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}],[{"el":{"text":"column 1111","iconCls1":"dot-e-font","value":11},"children":[{"text":"column 1.1","value":21,"cls":"dot-e-font"},{"text":"column 1.2","value":22,"cls":"dot-e-font"}]}]]
}); });
downListCombo.setValue([{value: 12, childValue: 21}]); downListCombo.setValue([{value: 12, childValue: 21}]);
expect(downListCombo.getValue()).to.deep.equal([ { childValue: 21, value: 12 } ]); expect(downListCombo.getValue()).toEqual([ { childValue: 21, value: 12 } ]);
downListCombo.destroy(); downListCombo.destroy();
}); });
@ -24,7 +24,7 @@ describe("DownListCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击父亲选值", function (done) { it("点击父亲选值", done => {
var downListCombo = BI.Test.createWidget({ var downListCombo = BI.Test.createWidget({
type: "bi.down_list_combo", type: "bi.down_list_combo",
height: 30, height: 30,
@ -34,7 +34,7 @@ describe("DownListCombo", function () {
downListCombo.element.children(".pull-down-font").click(); downListCombo.element.children(".pull-down-font").click();
BI.nextTick(function () { BI.nextTick(function () {
downListCombo.element.find(".bi-down-list-group:last-child .bi-down-list-item").click(); downListCombo.element.find(".bi-down-list-group:last-child .bi-down-list-item").click();
expect(downListCombo.getValue()).to.deep.equal([ { value: 33 } ]); expect(downListCombo.getValue()).toEqual([ { value: 33 } ]);
downListCombo.destroy(); downListCombo.destroy();
done(); done();
}); });
@ -44,7 +44,7 @@ describe("DownListCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击儿子选值", function (done) { it("点击儿子选值", done => {
var downListCombo = BI.Test.createWidget({ var downListCombo = BI.Test.createWidget({
type: "bi.down_list_combo", type: "bi.down_list_combo",
height: 30, height: 30,
@ -55,7 +55,7 @@ describe("DownListCombo", function () {
BI.Test.triggerMouseover(downListCombo.element.find(".bi-down-list-group:first-child .bi-down-list-group-item"), function () { BI.Test.triggerMouseover(downListCombo.element.find(".bi-down-list-group:first-child .bi-down-list-group-item"), function () {
BI.nextTick(function () { BI.nextTick(function () {
downListCombo.element.find(".child-down-list-item:first-child").click(); downListCombo.element.find(".child-down-list-item:first-child").click();
expect(downListCombo.getValue()).to.deep.equal([ { childValue: 21, value: 12 } ]); expect(downListCombo.getValue()).toEqual([ { childValue: 21, value: 12 } ]);
downListCombo.destroy(); downListCombo.destroy();
done(); done();
}); });

7
packages/fineui/src/widget/downlist/combo.downlist.js

@ -108,9 +108,6 @@ export class DownListCombo extends Widget {
stopPropagation: o.stopPropagation, stopPropagation: o.stopPropagation,
maxHeight: o.maxHeight, maxHeight: o.maxHeight,
minWidth: o.minWidth, minWidth: o.minWidth,
ref: (ref) => {
this.popup = ref;
},
...o.popup, ...o.popup,
}, },
}); });
@ -128,10 +125,6 @@ export class DownListCombo extends Widget {
this.downlistcombo.showView(e); this.downlistcombo.showView(e);
} }
getPopup() {
return this.popup;
}
populate(items) { populate(items) {
this.popupView.populate(items); this.popupView.populate(items);
} }

46
packages/fineui/src/widget/dynamicdate/__test__/dynamicdate.test.js

@ -4,9 +4,9 @@
* Created by windy on 2019/9/4 * Created by windy on 2019/9/4
*/ */
describe("DateCombo", function () { describe("DateCombo", () => {
before(function () { beforeAll(() => {
BI.holidays = { BI.holidays = {
"2010-02-28": true, "2010-02-28": true,
"2010-02-27": true "2010-02-27": true
@ -16,7 +16,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("defaultValue", function () { it("defaultValue", () => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
value: { value: {
@ -28,14 +28,14 @@ describe("DateCombo", function () {
} }
} }
}); });
expect(dateCombo.element.find(".bi-date-trigger .bi-label").text()).to.equal("2018-02-23"); expect(dateCombo.element.find(".bi-date-trigger .bi-label").text()).toBe("2018-02-23");
dateCombo.destroy(); dateCombo.destroy();
}); });
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试输入值收起下拉清空值下拉出现", function (done) { it("测试输入值收起下拉清空值下拉出现", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -54,11 +54,11 @@ describe("DateCombo", function () {
// 输入8, 检查popup是否收起 // 输入8, 检查popup是否收起
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "8", 56, function () { BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "8", 56, function () {
BI.nextTick(function () { BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).to.equal(0); expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).toBe(0);
// 清空输入, 检查popup是否弹出 // 清空输入, 检查popup是否弹出
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () { BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () {
BI.nextTick(function () { BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).to.equal("block"); expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").css("display")).toBe("block");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}); });
@ -72,7 +72,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("trigger的confirm-下拉面板选值confirm", function (done) { it("trigger的confirm-下拉面板选值confirm", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -82,7 +82,7 @@ describe("DateCombo", function () {
dateCombo.element.find(".bi-date-trigger .bi-basic-button").click(); dateCombo.element.find(".bi-date-trigger .bi-basic-button").click();
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click(); dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click();
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).to.equal(0); expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).toBe(0);
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}) })
@ -92,7 +92,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("下拉后直接点击外部的触发的confirm", function (done) { it("下拉后直接点击外部的触发的confirm", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -105,7 +105,7 @@ describe("DateCombo", function () {
var input = dateCombo.element.find(".bi-date-trigger .bi-input"); var input = dateCombo.element.find(".bi-date-trigger .bi-input");
BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () { BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () {
BI.delay(function () { BI.delay(function () {
expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).to.equal(0); expect(dateCombo.element.find(".bi-date-trigger + .bi-popup-view").length).toBe(0);
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}, 300); }, 300);
@ -118,7 +118,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击清空", function (done) { it("点击清空", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -135,7 +135,7 @@ describe("DateCombo", function () {
dateCombo.element.find(".bi-date-trigger .bi-basic-button").click(); dateCombo.element.find(".bi-date-trigger .bi-basic-button").click();
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-dynamic-date-popup .bi-text:contains(清除)").parent().click(); dateCombo.element.find(".bi-dynamic-date-popup .bi-text:contains(清除)").parent().click();
expect(BI.isNull(dateCombo.getValue())).to.equal(true); expect(BI.isNull(dateCombo.getValue())).toBe(true);
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}) })
@ -144,7 +144,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击今天", function (done) { it("点击今天", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -162,7 +162,7 @@ describe("DateCombo", function () {
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-dynamic-date-popup .bi-text:contains(今天)").parent().click(); dateCombo.element.find(".bi-dynamic-date-popup .bi-text:contains(今天)").parent().click();
var date = BI.getDate(); var date = BI.getDate();
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 1, type: 1,
value: { value: {
year: date.getFullYear(), year: date.getFullYear(),
@ -179,7 +179,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击确定", function (done) { it("点击确定", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -196,7 +196,7 @@ describe("DateCombo", function () {
dateCombo.element.find(".bi-date-trigger .bi-basic-button").click(); dateCombo.element.find(".bi-date-trigger .bi-basic-button").click();
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-dynamic-date-popup .bi-text:contains(确定)").parent().click(); dateCombo.element.find(".bi-dynamic-date-popup .bi-text:contains(确定)").parent().click();
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 1, type: 1,
value: { value: {
year: 2018, year: 2018,
@ -212,7 +212,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试动态默认值", function () { it("测试动态默认值", () => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -229,7 +229,7 @@ describe("DateCombo", function () {
} }
} }
}); });
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 2, type: 2,
value: { value: {
year: -1, year: -1,
@ -246,7 +246,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试工作日动态默认值", function () { it("测试工作日动态默认值", () => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -258,7 +258,7 @@ describe("DateCombo", function () {
} }
} }
}); });
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 2, type: 2,
value: { value: {
workDay: -1 workDay: -1
@ -271,7 +271,7 @@ describe("DateCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("trigger的输入日期后confirm", function (done) { it("trigger的输入日期后confirm", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_combo", type: "bi.dynamic_date_combo",
width: 220, width: 220,
@ -292,7 +292,7 @@ describe("DateCombo", function () {
input.val("2017-1-1"); input.val("2017-1-1");
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), null, BI.KeyCode.ENTER, function () { BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-trigger .bi-input"), null, BI.KeyCode.ENTER, function () {
BI.delay(function () { BI.delay(function () {
expect(dateCombo.element.find(".bi-date-trigger .bi-text-button").text()).to.equal("2017-01-01"); expect(dateCombo.element.find(".bi-date-trigger .bi-text-button").text()).toBe("2017-01-01");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}, 300); }, 300);

2
packages/fineui/src/widget/dynamicdate/dynamicdate.card.js

@ -45,7 +45,6 @@ export class DynamicDateCard extends Widget {
props = { props = {
baseCls: "bi-dynamic-date-card", baseCls: "bi-dynamic-date-card",
supportWorkDay: true,
}; };
render() { render() {
@ -163,7 +162,6 @@ export class DynamicDateCard extends Widget {
logic: { logic: {
dynamic: true, dynamic: true,
}, },
invisible: !this.options.supportWorkDay,
text: i18nText("BI-Basic_Work_Day"), text: i18nText("BI-Basic_Work_Day"),
value: DynamicDateCard.TYPE.WORK_DAY, value: DynamicDateCard.TYPE.WORK_DAY,
listeners: [ listeners: [

28
packages/fineui/src/widget/dynamicdate/dynamicdate.combo.js

@ -28,7 +28,7 @@ export class DynamicDateCombo extends Single {
static EVENT_ERROR = "EVENT_ERROR"; static EVENT_ERROR = "EVENT_ERROR";
static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; static EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW"; static EVENT_BEFORE_YEAR_MONTH_POPUPVIEW = "EVENT_BEFORE_YEAR_MONTH_POPUPVIEW";
static Static = 1; static Static = 1;
static Dynamic = 2; static Dynamic = 2;
@ -51,7 +51,6 @@ export class DynamicDateCombo extends Single {
attributes: { attributes: {
tabIndex: -1, tabIndex: -1,
}, },
supportWorkDay: true,
isNeedAdjustHeight: false, isNeedAdjustHeight: false,
isNeedAdjustWidth: false, isNeedAdjustWidth: false,
isPreview: false, // 是否是预览状态 isPreview: false, // 是否是预览状态
@ -205,12 +204,11 @@ export class DynamicDateCombo extends Single {
isPreview: opts.isPreview, isPreview: opts.isPreview,
width: opts.isNeedAdjustWidth ? opts.width : undefined, width: opts.isNeedAdjustWidth ? opts.width : undefined,
supportDynamic: opts.supportDynamic, supportDynamic: opts.supportDynamic,
supportWorkDay: opts.supportWorkDay,
behaviors: opts.behaviors, behaviors: opts.behaviors,
min: opts.minDate, min: opts.minDate,
max: opts.maxDate, max: opts.maxDate,
ref: _ref => { ref: _ref => {
this.popupEl = _ref; this.popup = _ref;
}, },
listeners: [ listeners: [
{ {
@ -240,7 +238,7 @@ export class DynamicDateCombo extends Single {
{ {
eventName: DynamicDatePopup.BUTTON_OK_EVENT_CHANGE, eventName: DynamicDatePopup.BUTTON_OK_EVENT_CHANGE,
action: () => { action: () => {
const value = this.popupEl.getValue(); const value = this.popup.getValue();
if (this._checkValue(value)) { if (this._checkValue(value)) {
this.setValue(value); this.setValue(value);
} }
@ -251,7 +249,7 @@ export class DynamicDateCombo extends Single {
{ {
eventName: DynamicDatePopup.EVENT_CHANGE, eventName: DynamicDatePopup.EVENT_CHANGE,
action: () => { action: () => {
this.setValue(this.popupEl.getValue()); this.setValue(this.popup.getValue());
this.combo.hideView(); this.combo.hideView();
this.fireEvent(DynamicDateCombo.EVENT_CONFIRM); this.fireEvent(DynamicDateCombo.EVENT_CONFIRM);
}, },
@ -264,10 +262,6 @@ export class DynamicDateCombo extends Single {
} }
], ],
}, },
ref: (ref) => {
this.popup = ref;
},
...opts.popup,
}, },
// // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起 // // DEC-4250 和复选下拉一样,点击triggerBtn不默认收起
// hideChecker: function (e) { // hideChecker: function (e) {
@ -277,9 +271,9 @@ export class DynamicDateCombo extends Single {
{ {
eventName: Combo.EVENT_BEFORE_POPUPVIEW, eventName: Combo.EVENT_BEFORE_POPUPVIEW,
action: () => { action: () => {
this.popupEl.setMinDate(opts.minDate); this.popup.setMinDate(opts.minDate);
this.popupEl.setMaxDate(opts.maxDate); this.popup.setMaxDate(opts.maxDate);
this.popupEl.setValue(this.storeValue); this.popup.setValue(this.storeValue);
this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW); this.fireEvent(DynamicDateCombo.EVENT_BEFORE_POPUPVIEW);
}, },
} }
@ -338,14 +332,14 @@ export class DynamicDateCombo extends Single {
const o = this.options; const o = this.options;
o.minDate = minDate; o.minDate = minDate;
this.trigger.setMinDate(minDate); this.trigger.setMinDate(minDate);
this.popupEl && this.popupEl.setMinDate(minDate); this.popup && this.popup.setMinDate(minDate);
} }
setMaxDate(maxDate) { setMaxDate(maxDate) {
const o = this.options; const o = this.options;
o.maxDate = maxDate; o.maxDate = maxDate;
this.trigger.setMaxDate(maxDate); this.trigger.setMaxDate(maxDate);
this.popupEl && this.popupEl.setMaxDate(maxDate); this.popup && this.popup.setMaxDate(maxDate);
} }
setValue(v) { setValue(v) {
@ -362,10 +356,6 @@ export class DynamicDateCombo extends Single {
return this.trigger.getKey(); return this.trigger.getKey();
} }
getPopup() {
return this.popup;
}
hidePopupView() { hidePopupView() {
this.combo.hideView(); this.combo.hideView();
} }

2
packages/fineui/src/widget/dynamicdate/dynamicdate.param.item.js

@ -79,7 +79,7 @@ export class DynamicDateParamItem extends Widget {
value: 0, value: 0,
}, },
{ {
text: i18nText("BI-Basic_Later"), text: i18nText("BI-Basic_Behind"),
value: 1, value: 1,
} }
], ],

2
packages/fineui/src/widget/dynamicdate/dynamicdate.popup.js

@ -34,7 +34,6 @@ export class DynamicDatePopup extends Widget {
baseCls: "bi-dynamic-date-popup", baseCls: "bi-dynamic-date-popup",
width: 272, width: 272,
supportDynamic: true, supportDynamic: true,
supportWorkDay: true,
isPreview: false, // 是否是预览状态 isPreview: false, // 是否是预览状态
}; };
@ -165,7 +164,6 @@ export class DynamicDatePopup extends Widget {
return { return {
type: DynamicDateCard.xtype, type: DynamicDateCard.xtype,
cls: "dynamic-date-pane", cls: "dynamic-date-pane",
supportWorkDay: this.options.supportWorkDay,
listeners: [ listeners: [
{ {
eventName: "EVENT_CHANGE", eventName: "EVENT_CHANGE",

46
packages/fineui/src/widget/dynamicdatetime/__test__/dynamicdatetime.test.js

@ -4,9 +4,9 @@
* Created by windy on 2019/9/4 * Created by windy on 2019/9/4
*/ */
describe("DateTimeCombo", function () { describe("DateTimeCombo", () => {
before(function () { beforeAll(() => {
BI.holidays = { BI.holidays = {
"2010-02-28": true, "2010-02-28": true,
"2010-02-27": true "2010-02-27": true
@ -16,7 +16,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("defaultValue", function (done) { it("defaultValue", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
value: { value: {
@ -32,7 +32,7 @@ describe("DateTimeCombo", function () {
} }
}); });
BI.nextTick(function () { BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).to.equal("2018-02-23 12:12:12"); expect(dateCombo.element.find(".bi-date-time-trigger .bi-label").text()).toBe("2018-02-23 12:12:12");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}) })
@ -41,7 +41,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试输入值收起下拉清空值下拉出现", function (done) { it("测试输入值收起下拉清空值下拉出现", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -63,11 +63,11 @@ describe("DateTimeCombo", function () {
// 输入8, 检查popup是否收起 // 输入8, 检查popup是否收起
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "8", 56, function () { BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "8", 56, function () {
BI.nextTick(function () { BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").length).to.equal(0); expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").length).toBe(0);
// 清空输入, 检查popup是否弹出 // 清空输入, 检查popup是否弹出
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () { BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () {
BI.nextTick(function () { BI.nextTick(function () {
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("block"); expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).toBe("block");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}); });
@ -81,7 +81,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("trigger的confirm-下拉面板选值confirm", function (done) { it("trigger的confirm-下拉面板选值confirm", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -92,7 +92,7 @@ describe("DateTimeCombo", function () {
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click(); dateCombo.element.find(".bi-calendar:visible .bi-list-item-select :contains(5)").parent().click();
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).to.equal("block"); expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").css("display")).toBe("block");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}) })
@ -102,7 +102,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("下拉后直接点击外部的触发的confirm", function (done) { it("下拉后直接点击外部的触发的confirm", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -115,7 +115,7 @@ describe("DateTimeCombo", function () {
var input = dateCombo.element.find(".bi-date-time-trigger .bi-input"); var input = dateCombo.element.find(".bi-date-time-trigger .bi-input");
BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () { BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () {
BI.delay(function () { BI.delay(function () {
expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").length).to.equal(0); expect(dateCombo.element.find(".bi-date-time-trigger + .bi-popup-view").length).toBe(0);
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}, 300); }, 300);
@ -128,7 +128,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击清空", function (done) { it("点击清空", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -148,7 +148,7 @@ describe("DateTimeCombo", function () {
dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click();
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(清除)").parent().click(); dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(清除)").parent().click();
expect(BI.isNull(dateCombo.getValue())).to.equal(true); expect(BI.isNull(dateCombo.getValue())).toBe(true);
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}) })
@ -157,7 +157,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击今天", function (done) { it("点击今天", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -178,7 +178,7 @@ describe("DateTimeCombo", function () {
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(今天)").parent().click(); dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(今天)").parent().click();
var date = BI.getDate(); var date = BI.getDate();
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 1, type: 1,
value: { value: {
year: date.getFullYear(), year: date.getFullYear(),
@ -198,7 +198,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("点击确定", function (done) { it("点击确定", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -218,7 +218,7 @@ describe("DateTimeCombo", function () {
dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click();
BI.nextTick(function () { BI.nextTick(function () {
dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(确定)").parent().click(); dateCombo.element.find(".bi-dynamic-date-time-popup .bi-text:contains(确定)").parent().click();
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 1, type: 1,
value: { value: {
year: 2018, year: 2018,
@ -237,7 +237,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试动态默认值", function () { it("测试动态默认值", () => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -255,7 +255,7 @@ describe("DateTimeCombo", function () {
} }
}); });
dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click(); dateCombo.element.find(".bi-date-time-trigger .bi-basic-button").click();
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 2, type: 2,
value: { value: {
year: -1, year: -1,
@ -272,7 +272,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("测试工作日动态默认值", function () { it("测试工作日动态默认值", () => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -284,7 +284,7 @@ describe("DateTimeCombo", function () {
} }
} }
}); });
expect(dateCombo.getValue()).to.deep.equal({ expect(dateCombo.getValue()).toEqual({
type: 2, type: 2,
value: { value: {
workDay: -1 workDay: -1
@ -297,7 +297,7 @@ describe("DateTimeCombo", function () {
/** /**
* test_author_windy * test_author_windy
*/ */
it("trigger的输入日期后confirm", function (done) { it("trigger的输入日期后confirm", done => {
var dateCombo = BI.Test.createWidget({ var dateCombo = BI.Test.createWidget({
type: "bi.dynamic_date_time_combo", type: "bi.dynamic_date_time_combo",
width: 220, width: 220,
@ -318,7 +318,7 @@ describe("DateTimeCombo", function () {
input.val("2017-1-1"); input.val("2017-1-1");
BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), null, BI.KeyCode.ENTER, function () { BI.Test.triggerKeyDown(dateCombo.element.find(".bi-date-time-trigger .bi-input"), null, BI.KeyCode.ENTER, function () {
BI.delay(function () { BI.delay(function () {
expect(dateCombo.element.find(".bi-date-time-trigger .bi-text-button").text()).to.equal("2017-01-01 00:00:00"); expect(dateCombo.element.find(".bi-date-time-trigger .bi-text-button").text()).toBe("2017-01-01 00:00:00");
dateCombo.destroy(); dateCombo.destroy();
done(); done();
}, 300); }, 300);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save