mirror of
https://gitlab.com/JKANetwork/CheckServer.git
synced 2026-02-23 13:33:47 +01:00
Start again
This commit is contained in:
61
vendors/echarts/test/ut/.jshintrc
vendored
Normal file
61
vendors/echarts/test/ut/.jshintrc
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"bitwise": false,
|
||||
"camelcase": true,
|
||||
"curly": true,
|
||||
"es3": true,
|
||||
"eqeqeq": true,
|
||||
"forin": true,
|
||||
"freeze": true,
|
||||
"immed": true,
|
||||
"latedef": "nofunc",
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonbsp": true,
|
||||
"nonew": true,
|
||||
"plusplus": false,
|
||||
"quotmark": "single",
|
||||
"undef": true,
|
||||
"predef": ["define", "require", "describe", "expect", "beforeEach", "it"],
|
||||
"unused": "vars",
|
||||
"strict": false,
|
||||
"maxparams": 20,
|
||||
"maxdepth": 6,
|
||||
"maxlen": 120,
|
||||
|
||||
"asi": false,
|
||||
"boss": true,
|
||||
"debug": false,
|
||||
"eqnull": true,
|
||||
"esnext": false,
|
||||
"evil": false,
|
||||
"expr": true,
|
||||
"funcscope": false,
|
||||
"globalstrict": false,
|
||||
"iterator": false,
|
||||
"lastsemic": false,
|
||||
"laxbreak": true,
|
||||
"laxcomma": false,
|
||||
"loopfunc": false,
|
||||
"multistr": false,
|
||||
"notypeof": false,
|
||||
"proto": false,
|
||||
"scripturl": false,
|
||||
"shadow": true,
|
||||
"sub": true,
|
||||
"supernew": false,
|
||||
"validthis": true,
|
||||
|
||||
"browser": true,
|
||||
"jasmine": true,
|
||||
"couch": false,
|
||||
"devel": true,
|
||||
"dojo": false,
|
||||
"jquery": false,
|
||||
"mootools": false,
|
||||
"node": true,
|
||||
"nonstandard": true,
|
||||
"prototypejs": false,
|
||||
"rhino": false,
|
||||
"wsh": true
|
||||
}
|
||||
20
vendors/echarts/test/ut/MIT.LICENSE
vendored
Normal file
20
vendors/echarts/test/ut/MIT.LICENSE
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008-2014 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
23
vendors/echarts/test/ut/config.js
vendored
Normal file
23
vendors/echarts/test/ut/config.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
require.config({
|
||||
baseUrl: '../',
|
||||
paths: {
|
||||
'geoJson': '../geoData/geoJson',
|
||||
'theme': '../theme',
|
||||
'data': './data',
|
||||
'map': '../map',
|
||||
'extension': '../extension'
|
||||
},
|
||||
packages: [
|
||||
{
|
||||
main: 'echarts',
|
||||
location: '../src',
|
||||
name: 'echarts'
|
||||
},
|
||||
{
|
||||
main: 'zrender',
|
||||
location: '../../zrender/src',
|
||||
name: 'zrender'
|
||||
}
|
||||
]
|
||||
// urlArgs: '_v_=' + +new Date()
|
||||
});
|
||||
10
vendors/echarts/test/ut/configure
vendored
Normal file
10
vendors/echarts/test/ut/configure
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
if [ "$#" -eq 1 ]; then
|
||||
# use specific version
|
||||
old=$1
|
||||
else
|
||||
# use last release
|
||||
old=$(git rev-list --tags --max-count=1)
|
||||
fi
|
||||
mkdir -p tmp
|
||||
cp ../../dist/echarts.js "tmp/newEcharts.js"
|
||||
git show $old:dist/echarts.js > 'tmp/oldEcharts.js'
|
||||
271
vendors/echarts/test/ut/core/uiHelper.js
vendored
Normal file
271
vendors/echarts/test/ut/core/uiHelper.js
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
(function (context) {
|
||||
|
||||
var helper = context.uiHelper = {};
|
||||
|
||||
// canvas comparing strategy, 'stack' or 'content'
|
||||
var STRATEGY = 'stack';
|
||||
// always display images even if no error
|
||||
var ALWAYS_SHOW_IMAGE = true;
|
||||
|
||||
// dom for failed cases
|
||||
var failedDom = document.createElement('div');
|
||||
failedDom.setAttribute('id', 'failed-panel');
|
||||
var hasFailedDom = false;
|
||||
|
||||
/**
|
||||
* expect canvas.toDataURL to be the same by old and new echarts
|
||||
* @param {string} title title of suite and case
|
||||
* @param {function} doTest test body
|
||||
* @param {function} done done callback provided by jasmine
|
||||
*/
|
||||
helper.expectEqualCanvasContent = function(title, doTest, done) {
|
||||
var that = this;
|
||||
window.require(['oldEcharts', 'newEcharts'], function (oldE, newE) {
|
||||
var oldImg = doTest(oldE).toDataURL();
|
||||
var newImg = doTest(newE).toDataURL();
|
||||
if (ALWAYS_SHOW_IMAGE || oldImg !== newImg) {
|
||||
that.addFailedCases(title, oldImg, newImg);
|
||||
}
|
||||
expect(oldImg).toEqual(newImg);
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* expect canvas operation stack provided by canteen
|
||||
* to be the same by old and new echarts
|
||||
* @param {string} title title of suite and case
|
||||
* @param {function} doTest test body
|
||||
* @param {function} done done callback provided by jasmine
|
||||
*/
|
||||
helper.expectEqualCanvasStack = function(title, doTest, done) {
|
||||
window.require(['oldEcharts', 'newEcharts'], function (oldE, newE) {
|
||||
var oldCanvas = doTest(oldE);
|
||||
var newCanvas = doTest(newE);
|
||||
var oldImg = oldCanvas.toDataURL();
|
||||
var newImg = newCanvas.toDataURL();
|
||||
if (ALWAYS_SHOW_IMAGE || oldImg !== newImg) {
|
||||
helper.addFailedCases(title, oldImg, newImg);
|
||||
}
|
||||
var oldCtx = oldCanvas.getContext('2d');
|
||||
var newCtx = newCanvas.getContext('2d');
|
||||
// hash of canvas operation stack, provided by canteen
|
||||
// https://github.com/platfora/Canteen
|
||||
// console.log(oldCtx.hash());
|
||||
expect(oldCtx.hash()).toEqual(newCtx.hash());
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* expect canvas with strategy
|
||||
* @param {string} title title of suite and case
|
||||
* @param {function} doTest test body
|
||||
* @param {function} done done callback provided by jasmine
|
||||
*/
|
||||
helper.expectEqualCanvas = function(title, doTest, done) {
|
||||
if (STRATEGY === 'content') {
|
||||
helper.expectEqualCanvasContent(title, doTest, done);
|
||||
} else if (STRATEGY === 'stack') {
|
||||
helper.expectEqualCanvasStack(title, doTest, done);
|
||||
} else {
|
||||
console.error('Invalid equal canvas strategy!');
|
||||
}
|
||||
};
|
||||
|
||||
var optionCompareHelper = function(isExpectEqual,
|
||||
title,
|
||||
option1,
|
||||
option2) {
|
||||
|
||||
it(title, function(done) {
|
||||
window.require(['newEcharts'], function (ec) {
|
||||
var canvas1 = helper.getRenderedCanvas(ec, function(myChart) {
|
||||
myChart.setOption(helper.preprocessOption(option1));
|
||||
});
|
||||
var canvas2 = helper.getRenderedCanvas(ec, function(myChart) {
|
||||
myChart.setOption(helper.preprocessOption(option2));
|
||||
});
|
||||
var ctx1 = canvas1.getContext('2d');
|
||||
var ctx2 = canvas2.getContext('2d');
|
||||
var img1 = canvas1.toDataURL();
|
||||
var img2 = canvas2.toDataURL();
|
||||
|
||||
var compare1 = compare2 = null;
|
||||
if (STRATEGY === 'content') {
|
||||
compare1 = img1;
|
||||
compare2 = img2;
|
||||
} else if (STRATEGY === 'stack') {
|
||||
compare1 = ctx1.hash()
|
||||
compare2 = ctx2.hash();
|
||||
} else {
|
||||
console.error('Invalid equal canvas strategy!');
|
||||
}
|
||||
|
||||
if (isExpectEqual) {
|
||||
expect(compare1).toEqual(compare2);
|
||||
} else {
|
||||
expect(compare1).not.toEqual(compare2);
|
||||
}
|
||||
|
||||
if (ALWAYS_SHOW_IMAGE || (compare1 === compare2) ^ isExpectEqual) {
|
||||
helper.addFailedCases(title, img1, img2);
|
||||
// console.log(title);
|
||||
// console.log(JSON.stringify(ctx1.stack()));
|
||||
// console.log(JSON.stringify(ctx2.stack()));
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* expect two options have the same canvas for new echarts
|
||||
* @param {string} title title of test case
|
||||
* @param {object} option1 one echarts option
|
||||
* @param {object} option2 the other echarts option
|
||||
* @param {function} done callback for jasmine
|
||||
*/
|
||||
helper.expectEqualOption = function(title, option1, option2) {
|
||||
optionCompareHelper(true, title, option1, option2);
|
||||
};
|
||||
|
||||
/**
|
||||
* expect two options have different canvas for new echarts
|
||||
* @param {string} title title of test case
|
||||
* @param {object} option1 one echarts option
|
||||
* @param {object} option2 the other echarts option
|
||||
* @param {function} done callback for jasmine
|
||||
*/
|
||||
helper.expectNotEqualOption = function(title, option1, option2) {
|
||||
optionCompareHelper(false, title, option1, option2);
|
||||
};
|
||||
|
||||
/**
|
||||
* get rendered canvas with echarts and operations
|
||||
* @param {object} echarts echarts
|
||||
* @param {function} operations operations with echarts
|
||||
* @return {Canvas} canvas rendered by echarts
|
||||
*/
|
||||
helper.getRenderedCanvas = function(echarts, operations) {
|
||||
// init canvas with echarts
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = 400;
|
||||
canvas.height = 300;
|
||||
var myChart = echarts.init(canvas);
|
||||
|
||||
// user defined operations
|
||||
operations(myChart);
|
||||
|
||||
return canvas;
|
||||
};
|
||||
|
||||
/**
|
||||
* run test with only setOption
|
||||
* @param {string} name name of the test
|
||||
* @param {object} option echarts option
|
||||
*/
|
||||
helper.testOption = function(name, option) {
|
||||
var doTest = function(ec) {
|
||||
var canvas = helper.getRenderedCanvas(ec, function(myChart) {
|
||||
myChart.setOption(helper.preprocessOption(option));
|
||||
});
|
||||
return canvas;
|
||||
};
|
||||
it(name, function(done) {
|
||||
if (STRATEGY === 'content') {
|
||||
helper.expectEqualCanvasContent(name, doTest, done);
|
||||
} else if (STRATEGY === 'stack') {
|
||||
helper.expectEqualCanvasStack(name, doTest, done);
|
||||
} else {
|
||||
console.error('Invalid equal canvas strategy!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* preprocess option and set default values
|
||||
* @param {object} option echarts option
|
||||
* @return {object} processed option
|
||||
*/
|
||||
helper.preprocessOption = function(option) {
|
||||
if (typeof option.animation === 'undefined') {
|
||||
option.animation = false;
|
||||
}
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* run test with setOption for whole spec
|
||||
* @param {string} specName spec name
|
||||
* @param {object[]} suites arrary of suites
|
||||
*/
|
||||
helper.testOptionSpec = function(specName, suites) {
|
||||
for (var sid = 0, slen = suites.length; sid < slen; ++sid) {
|
||||
(function(suiteName, cases) {
|
||||
describe(suiteName, function() {
|
||||
for (var cid = 0, clen = cases.length; cid < clen; ++cid) {
|
||||
var name = specName + ' - ' + suiteName + ': '
|
||||
+ cases[cid].name;
|
||||
if (cases[cid].test === 'equalOption') {
|
||||
helper.expectEqualOption(name, cases[cid].option1,
|
||||
cases[cid].option2);
|
||||
} else if (cases[cid].test === 'notEqualOption') {
|
||||
helper.expectNotEqualOption(name, cases[cid].option1,
|
||||
cases[cid].option2);
|
||||
} else {
|
||||
helper.testOption(name, cases[cid].option);
|
||||
}
|
||||
}
|
||||
});
|
||||
})(suites[sid].name, suites[sid].cases);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name name of the test
|
||||
* @param {string} oldImgSrc old canvas.toDataURL value
|
||||
* @param {string} newImgSrc new canvas.toDataURL value
|
||||
* add a failed case in dom
|
||||
*/
|
||||
helper.addFailedCases = function(name, oldImgSrc, newImgSrc) {
|
||||
// group of this case
|
||||
var group = document.createElement('div');
|
||||
var title = document.createElement('h6');
|
||||
title.innerHTML = name + '. Here are old, new, and diff images.';
|
||||
group.appendChild(title);
|
||||
|
||||
// old image and new image
|
||||
var oldImg = document.createElement('img');
|
||||
oldImg.src = oldImgSrc;
|
||||
oldImg.setAttribute('title', 'Old Image');
|
||||
var newImg = document.createElement('img');
|
||||
newImg.src = newImgSrc;
|
||||
newImg.setAttribute('title', 'New Image');
|
||||
group.appendChild(oldImg);
|
||||
group.appendChild(newImg);
|
||||
|
||||
// diff image
|
||||
var diff = imagediff.diff(oldImg, newImg);
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = oldImg.width;
|
||||
canvas.height = oldImg.height;
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.putImageData(diff, 0, 0);
|
||||
var diffImg = document.createElement('img');
|
||||
diffImg.src = canvas.toDataURL();
|
||||
diffImg.setAttribute('title', 'Diff Image');
|
||||
group.appendChild(diffImg);
|
||||
|
||||
failedDom.appendChild(group);
|
||||
|
||||
// append to dom
|
||||
if (!hasFailedDom) {
|
||||
var body = document.getElementsByTagName('body')[0];
|
||||
body.appendChild(failedDom);
|
||||
hasFailedDom = true;
|
||||
}
|
||||
};
|
||||
|
||||
})(window);
|
||||
310
vendors/echarts/test/ut/core/utHelper.js
vendored
Normal file
310
vendors/echarts/test/ut/core/utHelper.js
vendored
Normal file
@@ -0,0 +1,310 @@
|
||||
(function (context) {
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @type {Object}
|
||||
*/
|
||||
var helper = context.utHelper = {};
|
||||
|
||||
var nativeSlice = Array.prototype.slice;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* var testCase = helper.prepare([
|
||||
* 'echarts/chart/line',
|
||||
* 'echarts/component/grid',
|
||||
* 'echarts/component/toolbox'
|
||||
* ])
|
||||
*
|
||||
* testCase('test_case_1', function (grid, line, toolbox) {
|
||||
* // Real test case.
|
||||
* // this.echarts can be visited.
|
||||
* });
|
||||
*
|
||||
* testCase.requireId(['echarts/model/Component'])('test_case_2', function (Component) {
|
||||
* // Real test case.
|
||||
* // this.echarts can be visited.
|
||||
* });
|
||||
*
|
||||
* testCase.createChart()(function(grid, line, toolbox) {
|
||||
* // this.echarts can be visited.
|
||||
* // this.chart can be visited.
|
||||
* // this.charts[0] can be visited, this.charts[0] === this.chart
|
||||
* // this.el can be visited.
|
||||
* // this.els[0] can be visited, this.els[0] === this.el
|
||||
* });
|
||||
*
|
||||
* testCase.createChart(2)(function(grid, line, toolbox) {
|
||||
* // this.echarts can be visited.
|
||||
* // this.chart can be visited.
|
||||
* // this.charts[0] can be visited, this.charts[0] === this.chart
|
||||
* // this.charts[1] can be visited.
|
||||
* // this.el can be visited.
|
||||
* // this.els[0] can be visited, this.els[0] === this.el
|
||||
* // this.els[1] can be visited.
|
||||
* });
|
||||
*
|
||||
*
|
||||
* @public
|
||||
* @params {Array.<string>} [requireId] Like:
|
||||
* @return {Function} testCase function wrap.
|
||||
*/
|
||||
helper.prepare = function (requireId) {
|
||||
|
||||
window.beforeEach(function (done) {
|
||||
window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
||||
done();
|
||||
});
|
||||
|
||||
return wrapTestCaseFn(genContext({requireId: requireId}));
|
||||
|
||||
|
||||
function wrapTestCaseFn(context) {
|
||||
|
||||
var testCase = function (name, doTest) {
|
||||
|
||||
var requireId = context.requireId;
|
||||
if (!(requireId instanceof Array)) {
|
||||
requireId = requireId != null ? [] : [requireId];
|
||||
}
|
||||
requireId = ['echarts'].concat(requireId);
|
||||
|
||||
window.it(name, function (done) {
|
||||
helper.resetPackageLoader(onLoaderReset);
|
||||
|
||||
function onLoaderReset() {
|
||||
window.require(requireId, onModuleLoaded);
|
||||
}
|
||||
|
||||
function onModuleLoaded(echarts) {
|
||||
var createResult = createChart(context, echarts);
|
||||
|
||||
var userScope = {
|
||||
echarts: echarts,
|
||||
chart: createResult.charts[0],
|
||||
charts: createResult.charts.slice(),
|
||||
el: createResult.els[0],
|
||||
els: createResult.els.slice()
|
||||
};
|
||||
doTest.apply(
|
||||
userScope,
|
||||
Array.prototype.slice.call(arguments, 1)
|
||||
);
|
||||
|
||||
removeChart(createResult);
|
||||
|
||||
done();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
testCase.requireId = function (requireId) {
|
||||
return wrapTestCaseFn(genContext({requireId: requireId}, context));
|
||||
};
|
||||
|
||||
testCase.createChart = function (chartCount) {
|
||||
chartCount == null && (chartCount = 1);
|
||||
return wrapTestCaseFn(genContext({chartCount: chartCount}, context));
|
||||
};
|
||||
|
||||
return testCase;
|
||||
}
|
||||
|
||||
function genContext(props, originalContext) {
|
||||
var context = {};
|
||||
if (originalContext) {
|
||||
for (var key in originalContext) {
|
||||
if (originalContext.hasOwnProperty(key)) {
|
||||
context[key] = originalContext[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (props) {
|
||||
for (var key in props) {
|
||||
if (props.hasOwnProperty(key)) {
|
||||
context[key] = props[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
function createChart(context, echarts) {
|
||||
var els = [];
|
||||
var charts = [];
|
||||
for (var i = 0; i < context.chartCount || 0; i++) {
|
||||
var el = document.createElement('div');
|
||||
document.body.appendChild(el);
|
||||
els.push(el);
|
||||
charts.push(echarts.init(el, null, {renderer: 'canvas'}));
|
||||
}
|
||||
return {charts: charts, els: els};
|
||||
}
|
||||
|
||||
function removeChart(createResult) {
|
||||
for (var i = 0; i < createResult.charts.length; i++) {
|
||||
var chart = createResult.charts[i];
|
||||
chart && chart.dispose();
|
||||
}
|
||||
for (var i = 0; i < createResult.els.length; i++) {
|
||||
var el = createResult.els[i];
|
||||
el && document.body.removeChild(el);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} target
|
||||
* @param {*} source
|
||||
*/
|
||||
helper.extend = function (target, source) {
|
||||
for (var key in source) {
|
||||
if (source.hasOwnProperty(key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
helper.g = function (id) {
|
||||
return document.getElementById(id);
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
helper.removeEl = function (el) {
|
||||
var parent = helper.parentEl(el);
|
||||
parent && parent.removeChild(el);
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
helper.parentEl = function (el) {
|
||||
//parentElement for ie.
|
||||
return el.parentElement || el.parentNode;
|
||||
};
|
||||
|
||||
/**
|
||||
* 得到head
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
helper.getHeadEl = function (s) {
|
||||
return document.head
|
||||
|| document.getElementsByTagName('head')[0]
|
||||
|| document.documentElement;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
helper.curry = function (func) {
|
||||
var args = nativeSlice.call(arguments, 1);
|
||||
return function () {
|
||||
return func.apply(this, args.concat(nativeSlice.call(arguments)));
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
helper.bind = function (func, context) {
|
||||
var args = nativeSlice.call(arguments, 2);
|
||||
return function () {
|
||||
return func.apply(context, args.concat(nativeSlice.call(arguments)));
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Load javascript script
|
||||
*
|
||||
* @param {string} resource Like 'xx/xx/xx.js';
|
||||
*/
|
||||
helper.loadScript = function (url, id, callback) {
|
||||
var head = helper.getHeadEl();
|
||||
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('type', 'text/javascript');
|
||||
script.setAttribute('charset', 'utf-8');
|
||||
if (id) {
|
||||
script.setAttribute('id', id);
|
||||
}
|
||||
script.setAttribute('src', url);
|
||||
|
||||
// @see jquery
|
||||
// Attach handlers for all browsers
|
||||
script.onload = script.onreadystatechange = function () {
|
||||
|
||||
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
|
||||
// Handle memory leak in IE
|
||||
script.onload = script.onreadystatechange = null;
|
||||
// Dereference the script
|
||||
script = undefined;
|
||||
callback && callback();
|
||||
}
|
||||
};
|
||||
|
||||
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
||||
// This arises when a base node is used (jquery #2709 and #4378).
|
||||
head.insertBefore(script, head.firstChild);
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset package loader, where esl is cleaned and reloaded.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
helper.resetPackageLoader = function (then) {
|
||||
// Clean esl
|
||||
var eslEl = helper.g('esl');
|
||||
if (eslEl) {
|
||||
helper.removeEl(eslEl);
|
||||
}
|
||||
var eslConfig = helper.g('esl');
|
||||
if (eslConfig) {
|
||||
helper.removeEl(eslConfig);
|
||||
}
|
||||
context.define = null;
|
||||
context.require = null;
|
||||
|
||||
// Import esl.
|
||||
helper.loadScript('../esl.js', 'esl', function () {
|
||||
helper.loadScript('config.js', 'config', function () {
|
||||
then();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @param {Array.<string>} deps
|
||||
* @param {Array.<Function>} testFnList
|
||||
* @param {Function} done All done callback.
|
||||
*/
|
||||
helper.resetPackageLoaderEachTest = function (deps, testFnList, done) {
|
||||
var i = -1;
|
||||
next();
|
||||
|
||||
function next() {
|
||||
i++;
|
||||
if (testFnList.length <= i) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
helper.resetPackageLoader(function () {
|
||||
window.require(deps, function () {
|
||||
testFnList[i].apply(null, arguments);
|
||||
next();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
})(window);
|
||||
566
vendors/echarts/test/ut/lib/canteen.js
vendored
Normal file
566
vendors/echarts/test/ut/lib/canteen.js
vendored
Normal file
@@ -0,0 +1,566 @@
|
||||
/**
|
||||
* Canteen v1.0.4
|
||||
* August 19th, 2015
|
||||
*
|
||||
* Copyright 2015 Platfora, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
;(function() {
|
||||
// ================================ Constants ================================
|
||||
var CONTEXT_2D_ATTRIBUTES = [
|
||||
'fillStyle',
|
||||
'font',
|
||||
'globalAlpha',
|
||||
'globalCompositeOperation',
|
||||
'lineCap',
|
||||
'lineDashOffset',
|
||||
'lineJoin',
|
||||
'lineWidth',
|
||||
'miterLimit',
|
||||
'shadowBlur',
|
||||
'shadowColor',
|
||||
'shadowOffsetX',
|
||||
'shadowOffsetY',
|
||||
'strokeStyle',
|
||||
'textAlign',
|
||||
'textBaseline'
|
||||
];
|
||||
|
||||
// ================================ Utils ================================
|
||||
|
||||
function each(arr, func) {
|
||||
var len = arr.length,
|
||||
n;
|
||||
|
||||
for (n=0; n<len; n++) {
|
||||
func(arr[n], n);
|
||||
}
|
||||
}
|
||||
|
||||
function round(val, decimalPoints) {
|
||||
var power = Math.pow(10, decimalPoints);
|
||||
return Math.round(val * power) / power;
|
||||
}
|
||||
|
||||
function roundArr(arr, decimalPoints) {
|
||||
var len = arr.length,
|
||||
ret = [],
|
||||
n;
|
||||
|
||||
for (n=0; n<len; n++) {
|
||||
if (isNumber(arr[n])) {
|
||||
ret.push(round(arr[n], decimalPoints));
|
||||
}
|
||||
else {
|
||||
ret.push(arr[n]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function isFunction(func) {
|
||||
return func && {}.toString.call(func) === '[object Function]';
|
||||
}
|
||||
|
||||
function isNumber(val) {
|
||||
return typeof val === 'number';
|
||||
}
|
||||
|
||||
// ================================ Canteen Class ================================
|
||||
|
||||
/**
|
||||
* Canteen Constructor
|
||||
* @constructor
|
||||
*/
|
||||
var Canteen = function(context) {
|
||||
var that = this;
|
||||
|
||||
this._stack = [];
|
||||
this.context = context;
|
||||
|
||||
// add observable attributes
|
||||
each(CONTEXT_2D_ATTRIBUTES, function(key, n) {
|
||||
Object.defineProperty(that, key, {
|
||||
get: function() {
|
||||
return that.context[key];
|
||||
},
|
||||
set: function(val) {
|
||||
that._pushAttr(key, val);
|
||||
that.context[key] = val;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Canteen methods
|
||||
Canteen.prototype = {
|
||||
/**
|
||||
* get a stack of operations
|
||||
* @method stack
|
||||
* @param {Object} config
|
||||
* @param {String} [config.loose=false] - strict mode returns method calls with arguments and property names
|
||||
* with values. loose mode only returns method calls and property names
|
||||
* @param {Number} [config.decimalPoints=3] - number of decimal points to round numeric values to. The default is
|
||||
* 3, i.e. 1.23456 will round to 1.234
|
||||
* @returns {Array}
|
||||
* @public
|
||||
*/
|
||||
stack: function(config) {
|
||||
var config = config || {},
|
||||
loose = config.loose,
|
||||
decimalPoints = config.decimalPoints === undefined ? 3 : config.decimalPoints,
|
||||
ret = [];
|
||||
|
||||
if (loose) {
|
||||
each(this._stack, function(el, n) {
|
||||
ret.push(el.method || el.attr);
|
||||
});
|
||||
}
|
||||
else {
|
||||
each(this._stack, function(el, n) {
|
||||
// if method instruction
|
||||
if (el.method) {
|
||||
ret.push({
|
||||
method: el.method,
|
||||
arguments: roundArr(el.arguments, decimalPoints)
|
||||
});
|
||||
}
|
||||
// if attr
|
||||
else if (el.attr) {
|
||||
ret.push({
|
||||
attr: el.attr,
|
||||
val: isNumber(el.val) ? round(el.val, decimalPoints) : el.val
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
/**
|
||||
* serialize a stack into a string
|
||||
* @method json
|
||||
* @param {Object} config
|
||||
* @param {String} [config.loose=false] - strict mode returns method calls with arguments and property names
|
||||
* with values. loose mode only returns method calls and property names
|
||||
* @param {Number} [config.decimalPoints=3] - number of decimal points to round numeric values to. The default is
|
||||
* 3, i.e. 1.23456 will round to 1.234
|
||||
* @returns {String}
|
||||
* @public
|
||||
*/
|
||||
json: function(config) {
|
||||
return JSON.stringify(this.stack(config));
|
||||
},
|
||||
/**
|
||||
* convert a stack into a small hash string for easy comparisons
|
||||
* @method hash
|
||||
* @param {Object} config
|
||||
* @param {String} [config.loose=false] - strict mode returns method calls with arguments and property names
|
||||
* with values. loose mode only returns method calls and property names
|
||||
* @param {Number} [config.decimalPoints=3] - number of decimal points to round numeric values to. The default is
|
||||
* 3, i.e. 1.23456 will round to 1.234
|
||||
* @public
|
||||
* @returns {String}
|
||||
*/
|
||||
hash: function(config) {
|
||||
return Canteen.md5(this.json(config));
|
||||
},
|
||||
/**
|
||||
* clear the stack
|
||||
* @method clear
|
||||
* @public
|
||||
*/
|
||||
clear: function() {
|
||||
this._stack = [];
|
||||
},
|
||||
/**
|
||||
* push instruction method onto the stack
|
||||
* @method _pushMethod
|
||||
* @param {String} method
|
||||
* @param {arguments} args
|
||||
* @private
|
||||
*/
|
||||
_pushMethod: function(method, args) {
|
||||
this._stack.push({
|
||||
method: method,
|
||||
arguments: Array.prototype.slice.call(args, 0)
|
||||
});
|
||||
|
||||
this._slice();
|
||||
},
|
||||
/**
|
||||
* push instruction attribute onto the stack
|
||||
* @method _pushAttr
|
||||
* @param {String} attr
|
||||
* @param {*} val
|
||||
* @private
|
||||
*/
|
||||
_pushAttr: function(attr, val) {
|
||||
this._stack.push({
|
||||
attr: attr,
|
||||
val: val
|
||||
});
|
||||
|
||||
this._slice();
|
||||
},
|
||||
/**
|
||||
* slice the stack if needed. This means making sure that it doesn't exceed
|
||||
* the STACK_SIZE. if it does, then shorten the stack starting from the beginning
|
||||
* @method _slice
|
||||
* @private
|
||||
*/
|
||||
_slice: function() {
|
||||
var stack = this._stack,
|
||||
len = stack.length,
|
||||
exceded = len - Canteen.globals.STACK_SIZE;
|
||||
if (exceded > 0) {
|
||||
this._stack = stack.slice(exceded);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// generate observable methods and add them to the Canteen prototype
|
||||
(function(){
|
||||
var proto = CanvasRenderingContext2D.prototype,
|
||||
key, val, desc;
|
||||
|
||||
function addMethod(key, val) {
|
||||
Canteen.prototype[key] = function() {
|
||||
this._pushMethod(key, arguments);
|
||||
return this.context[key].apply(this.context, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
for (key in proto) {
|
||||
desc = Object.getOwnPropertyDescriptor(CanvasRenderingContext2D.prototype, key);
|
||||
val = (desc && desc.value ? proto[key] : null);
|
||||
if (isFunction(val)) {
|
||||
addMethod(key, val);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
// ================================ Global Config ================================
|
||||
/**
|
||||
* global config. You can directly change these values in order to configure Canteen
|
||||
* @static
|
||||
* @example
|
||||
* // change stack size to 3000
|
||||
* Canteen.globals.STACK_SIZE = 3000;
|
||||
*/
|
||||
Canteen.globals = {
|
||||
STACK_SIZE: 10000
|
||||
};
|
||||
|
||||
// ================================ Initialization ================================
|
||||
|
||||
// override the canvas context getContext method in order to automatically instantiate
|
||||
// a Canteen instance and wrap the native context object
|
||||
(function(){
|
||||
var origGetContext = HTMLCanvasElement.prototype.getContext;
|
||||
|
||||
HTMLCanvasElement.prototype.getContext = function() {
|
||||
var context = origGetContext.apply(this, arguments);
|
||||
|
||||
// if the context already has a canteen instance, then return it
|
||||
if (context.canteen) {
|
||||
return context.canteen
|
||||
}
|
||||
// if the context does not have a canteen instance, then instantiate one
|
||||
// and return it
|
||||
else {
|
||||
context.canteen = new Canteen(context);
|
||||
return context.canteen;
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
// make the Canteen namespace global so that developers can configure
|
||||
// it via Canteen.globals, or override methods if desired
|
||||
window.Canteen = Canteen;
|
||||
})();
|
||||
;/*
|
||||
* JavaScript MD5 1.0.1
|
||||
* https://github.com/blueimp/JavaScript-MD5
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*
|
||||
* Based on
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
|
||||
/*jslint bitwise: true */
|
||||
/*global unescape, define */
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y) {
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
|
||||
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bit_rol(num, cnt) {
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions implement the four basic operations the algorithm uses.
|
||||
*/
|
||||
function md5_cmn(q, a, b, x, s, t) {
|
||||
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
|
||||
}
|
||||
function md5_ff(a, b, c, d, x, s, t) {
|
||||
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
||||
}
|
||||
function md5_gg(a, b, c, d, x, s, t) {
|
||||
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
||||
}
|
||||
function md5_hh(a, b, c, d, x, s, t) {
|
||||
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
function md5_ii(a, b, c, d, x, s, t) {
|
||||
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
||||
*/
|
||||
function binl_md5(x, len) {
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << (len % 32);
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
|
||||
var i, olda, oldb, oldc, oldd,
|
||||
a = 1732584193,
|
||||
b = -271733879,
|
||||
c = -1732584194,
|
||||
d = 271733878;
|
||||
|
||||
for (i = 0; i < x.length; i += 16) {
|
||||
olda = a;
|
||||
oldb = b;
|
||||
oldc = c;
|
||||
oldd = d;
|
||||
|
||||
a = md5_ff(a, b, c, d, x[i], 7, -680876936);
|
||||
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
|
||||
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
|
||||
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
||||
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
|
||||
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
||||
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
||||
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
|
||||
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
||||
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
||||
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
|
||||
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
||||
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
||||
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
|
||||
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
||||
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
||||
|
||||
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
|
||||
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
||||
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
|
||||
b = md5_gg(b, c, d, a, x[i], 20, -373897302);
|
||||
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
|
||||
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
|
||||
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
|
||||
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
|
||||
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
|
||||
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
||||
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
|
||||
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
||||
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
||||
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
|
||||
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
||||
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
||||
|
||||
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
|
||||
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
||||
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
||||
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
|
||||
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
||||
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
||||
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
|
||||
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
||||
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
|
||||
d = md5_hh(d, a, b, c, x[i], 11, -358537222);
|
||||
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
|
||||
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
|
||||
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
|
||||
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
|
||||
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
|
||||
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
|
||||
|
||||
a = md5_ii(a, b, c, d, x[i], 6, -198630844);
|
||||
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
||||
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
||||
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
|
||||
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
||||
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
||||
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
|
||||
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
||||
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
||||
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
|
||||
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
||||
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
||||
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
|
||||
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
||||
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
|
||||
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
}
|
||||
return [a, b, c, d];
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a string
|
||||
*/
|
||||
function binl2rstr(input) {
|
||||
var i,
|
||||
output = '';
|
||||
for (i = 0; i < input.length * 32; i += 8) {
|
||||
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to an array of little-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*/
|
||||
function rstr2binl(input) {
|
||||
var i,
|
||||
output = [];
|
||||
output[(input.length >> 2) - 1] = undefined;
|
||||
for (i = 0; i < output.length; i += 1) {
|
||||
output[i] = 0;
|
||||
}
|
||||
for (i = 0; i < input.length * 8; i += 8) {
|
||||
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of a raw string
|
||||
*/
|
||||
function rstr_md5(s) {
|
||||
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-MD5, of a key and some data (raw strings)
|
||||
*/
|
||||
function rstr_hmac_md5(key, data) {
|
||||
var i,
|
||||
bkey = rstr2binl(key),
|
||||
ipad = [],
|
||||
opad = [],
|
||||
hash;
|
||||
ipad[15] = opad[15] = undefined;
|
||||
if (bkey.length > 16) {
|
||||
bkey = binl_md5(bkey, key.length * 8);
|
||||
}
|
||||
for (i = 0; i < 16; i += 1) {
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
|
||||
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to a hex string
|
||||
*/
|
||||
function rstr2hex(input) {
|
||||
var hex_tab = '0123456789abcdef',
|
||||
output = '',
|
||||
x,
|
||||
i;
|
||||
for (i = 0; i < input.length; i += 1) {
|
||||
x = input.charCodeAt(i);
|
||||
output += hex_tab.charAt((x >>> 4) & 0x0F) +
|
||||
hex_tab.charAt(x & 0x0F);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a string as utf-8
|
||||
*/
|
||||
function str2rstr_utf8(input) {
|
||||
return unescape(encodeURIComponent(input));
|
||||
}
|
||||
|
||||
/*
|
||||
* Take string arguments and return either raw or hex encoded strings
|
||||
*/
|
||||
function raw_md5(s) {
|
||||
return rstr_md5(str2rstr_utf8(s));
|
||||
}
|
||||
function hex_md5(s) {
|
||||
return rstr2hex(raw_md5(s));
|
||||
}
|
||||
function raw_hmac_md5(k, d) {
|
||||
return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d));
|
||||
}
|
||||
function hex_hmac_md5(k, d) {
|
||||
return rstr2hex(raw_hmac_md5(k, d));
|
||||
}
|
||||
|
||||
function md5(string, key, raw) {
|
||||
if (!key) {
|
||||
if (!raw) {
|
||||
return hex_md5(string);
|
||||
}
|
||||
return raw_md5(string);
|
||||
}
|
||||
if (!raw) {
|
||||
return hex_hmac_md5(key, string);
|
||||
}
|
||||
return raw_hmac_md5(key, string);
|
||||
}
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(function () {
|
||||
return md5;
|
||||
});
|
||||
} else {
|
||||
$.md5 = md5;
|
||||
}
|
||||
}(Canteen));
|
||||
392
vendors/echarts/test/ut/lib/imagediff.js
vendored
Normal file
392
vendors/echarts/test/ut/lib/imagediff.js
vendored
Normal file
@@ -0,0 +1,392 @@
|
||||
(function (name, definition) {
|
||||
var root = this;
|
||||
if (typeof module !== 'undefined') {
|
||||
var Canvas;
|
||||
try {
|
||||
Canvas = require('canvas');
|
||||
} catch (e) {}
|
||||
module.exports = definition(root, name, Canvas);
|
||||
} else if (typeof define === 'function' && typeof define.amd === 'object') {
|
||||
define(definition(root, name));
|
||||
} else {
|
||||
root[name] = definition(root, name);
|
||||
}
|
||||
})('imagediff', function (root, name, Canvas) {
|
||||
|
||||
var
|
||||
TYPE_ARRAY = /\[object Array\]/i,
|
||||
TYPE_CANVAS = /\[object (Canvas|HTMLCanvasElement)\]/i,
|
||||
TYPE_CONTEXT = /\[object CanvasRenderingContext2D\]/i,
|
||||
TYPE_IMAGE = /\[object (Image|HTMLImageElement)\]/i,
|
||||
TYPE_IMAGE_DATA = /\[object ImageData\]/i,
|
||||
|
||||
UNDEFINED = 'undefined',
|
||||
|
||||
canvas = getCanvas(),
|
||||
context = canvas.getContext('2d'),
|
||||
previous = root[name],
|
||||
imagediff, jasmine;
|
||||
|
||||
// Creation
|
||||
function getCanvas (width, height) {
|
||||
var canvas;
|
||||
if (Canvas) {
|
||||
canvas = new Canvas();
|
||||
} else if (root.document && root.document.createElement) {
|
||||
canvas = document.createElement('canvas');
|
||||
} else {
|
||||
throw new Error(
|
||||
e.message + '\n' +
|
||||
'Please see https://github.com/HumbleSoftware/js-imagediff#cannot-find-module-canvas\n'
|
||||
);
|
||||
}
|
||||
if (width) canvas.width = width;
|
||||
if (height) canvas.height = height;
|
||||
return canvas;
|
||||
}
|
||||
function getImageData (width, height) {
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
context.clearRect(0, 0, width, height);
|
||||
return context.createImageData(width, height);
|
||||
}
|
||||
|
||||
|
||||
// Type Checking
|
||||
function isImage (object) {
|
||||
return isType(object, TYPE_IMAGE);
|
||||
}
|
||||
function isCanvas (object) {
|
||||
return isType(object, TYPE_CANVAS);
|
||||
}
|
||||
function isContext (object) {
|
||||
return isType(object, TYPE_CONTEXT);
|
||||
}
|
||||
function isImageData (object) {
|
||||
return !!(object &&
|
||||
isType(object, TYPE_IMAGE_DATA) &&
|
||||
typeof(object.width) !== UNDEFINED &&
|
||||
typeof(object.height) !== UNDEFINED &&
|
||||
typeof(object.data) !== UNDEFINED);
|
||||
}
|
||||
function isImageType (object) {
|
||||
return (
|
||||
isImage(object) ||
|
||||
isCanvas(object) ||
|
||||
isContext(object) ||
|
||||
isImageData(object)
|
||||
);
|
||||
}
|
||||
function isType (object, type) {
|
||||
return typeof (object) === 'object' && !!Object.prototype.toString.apply(object).match(type);
|
||||
}
|
||||
|
||||
|
||||
// Type Conversion
|
||||
function copyImageData (imageData) {
|
||||
var
|
||||
height = imageData.height,
|
||||
width = imageData.width,
|
||||
data = imageData.data,
|
||||
newImageData, newData, i;
|
||||
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
newImageData = context.getImageData(0, 0, width, height);
|
||||
newData = newImageData.data;
|
||||
|
||||
for (i = imageData.data.length; i--;) {
|
||||
newData[i] = data[i];
|
||||
}
|
||||
|
||||
return newImageData;
|
||||
}
|
||||
function toImageData (object) {
|
||||
if (isImage(object)) { return toImageDataFromImage(object); }
|
||||
if (isCanvas(object)) { return toImageDataFromCanvas(object); }
|
||||
if (isContext(object)) { return toImageDataFromContext(object); }
|
||||
if (isImageData(object)) { return object; }
|
||||
}
|
||||
function toImageDataFromImage (image) {
|
||||
var
|
||||
height = image.height,
|
||||
width = image.width;
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
context.clearRect(0, 0, width, height);
|
||||
context.drawImage(image, 0, 0);
|
||||
return context.getImageData(0, 0, width, height);
|
||||
}
|
||||
function toImageDataFromCanvas (canvas) {
|
||||
var
|
||||
height = canvas.height,
|
||||
width = canvas.width,
|
||||
context = canvas.getContext('2d');
|
||||
return context.getImageData(0, 0, width, height);
|
||||
}
|
||||
function toImageDataFromContext (context) {
|
||||
var
|
||||
canvas = context.canvas,
|
||||
height = canvas.height,
|
||||
width = canvas.width;
|
||||
return context.getImageData(0, 0, width, height);
|
||||
}
|
||||
function toCanvas (object) {
|
||||
var
|
||||
data = toImageData(object),
|
||||
canvas = getCanvas(data.width, data.height),
|
||||
context = canvas.getContext('2d');
|
||||
|
||||
context.putImageData(data, 0, 0);
|
||||
return canvas;
|
||||
}
|
||||
|
||||
|
||||
// ImageData Equality Operators
|
||||
function equalWidth (a, b) {
|
||||
return a.width === b.width;
|
||||
}
|
||||
function equalHeight (a, b) {
|
||||
return a.height === b.height;
|
||||
}
|
||||
function equalDimensions (a, b) {
|
||||
return equalHeight(a, b) && equalWidth(a, b);
|
||||
}
|
||||
function equal (a, b, tolerance) {
|
||||
|
||||
var
|
||||
aData = a.data,
|
||||
bData = b.data,
|
||||
length = aData.length,
|
||||
i;
|
||||
|
||||
tolerance = tolerance || 0;
|
||||
|
||||
if (!equalDimensions(a, b)) return false;
|
||||
for (i = length; i--;) if (aData[i] !== bData[i] && Math.abs(aData[i] - bData[i]) > tolerance) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Diff
|
||||
function diff (a, b, options) {
|
||||
return (equalDimensions(a, b) ? diffEqual : diffUnequal)(a, b, options);
|
||||
}
|
||||
function diffEqual (a, b, options) {
|
||||
|
||||
var
|
||||
height = a.height,
|
||||
width = a.width,
|
||||
c = getImageData(width, height), // c = a - b
|
||||
aData = a.data,
|
||||
bData = b.data,
|
||||
cData = c.data,
|
||||
length = cData.length,
|
||||
row, column,
|
||||
i, j, k, v;
|
||||
|
||||
for (i = 0; i < length; i += 4) {
|
||||
cData[i] = Math.abs(aData[i] - bData[i]);
|
||||
cData[i+1] = Math.abs(aData[i+1] - bData[i+1]);
|
||||
cData[i+2] = Math.abs(aData[i+2] - bData[i+2]);
|
||||
cData[i+3] = Math.abs(255 - Math.abs(aData[i+3] - bData[i+3]));
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
function diffUnequal (a, b, options) {
|
||||
|
||||
var
|
||||
height = Math.max(a.height, b.height),
|
||||
width = Math.max(a.width, b.width),
|
||||
c = getImageData(width, height), // c = a - b
|
||||
aData = a.data,
|
||||
bData = b.data,
|
||||
cData = c.data,
|
||||
align = options && options.align,
|
||||
rowOffset,
|
||||
columnOffset,
|
||||
row, column,
|
||||
i, j, k, v;
|
||||
|
||||
|
||||
for (i = cData.length - 1; i > 0; i = i - 4) {
|
||||
cData[i] = 255;
|
||||
}
|
||||
|
||||
// Add First Image
|
||||
offsets(a);
|
||||
for (row = a.height; row--;){
|
||||
for (column = a.width; column--;) {
|
||||
i = 4 * ((row + rowOffset) * width + (column + columnOffset));
|
||||
j = 4 * (row * a.width + column);
|
||||
cData[i+0] = aData[j+0]; // r
|
||||
cData[i+1] = aData[j+1]; // g
|
||||
cData[i+2] = aData[j+2]; // b
|
||||
// cData[i+3] = aData[j+3]; // a
|
||||
}
|
||||
}
|
||||
|
||||
// Subtract Second Image
|
||||
offsets(b);
|
||||
for (row = b.height; row--;){
|
||||
for (column = b.width; column--;) {
|
||||
i = 4 * ((row + rowOffset) * width + (column + columnOffset));
|
||||
j = 4 * (row * b.width + column);
|
||||
cData[i+0] = Math.abs(cData[i+0] - bData[j+0]); // r
|
||||
cData[i+1] = Math.abs(cData[i+1] - bData[j+1]); // g
|
||||
cData[i+2] = Math.abs(cData[i+2] - bData[j+2]); // b
|
||||
}
|
||||
}
|
||||
|
||||
// Helpers
|
||||
function offsets (imageData) {
|
||||
if (align === 'top') {
|
||||
rowOffset = 0;
|
||||
columnOffset = 0;
|
||||
} else {
|
||||
rowOffset = Math.floor((height - imageData.height) / 2);
|
||||
columnOffset = Math.floor((width - imageData.width) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
// Validation
|
||||
function checkType () {
|
||||
var i;
|
||||
for (i = 0; i < arguments.length; i++) {
|
||||
if (!isImageType(arguments[i])) {
|
||||
throw {
|
||||
name : 'ImageTypeError',
|
||||
message : 'Submitted object was not an image.'
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Jasmine Matchers
|
||||
function get (element, content) {
|
||||
element = document.createElement(element);
|
||||
if (element && content) {
|
||||
element.innerHTML = content;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
jasmine = {
|
||||
|
||||
toBeImageData : function () {
|
||||
return imagediff.isImageData(this.actual);
|
||||
},
|
||||
|
||||
toImageDiffEqual : function (expected, tolerance) {
|
||||
|
||||
if (typeof (document) !== UNDEFINED) {
|
||||
this.message = function () {
|
||||
var
|
||||
div = get('div'),
|
||||
a = get('div', '<div>Actual:</div>'),
|
||||
b = get('div', '<div>Expected:</div>'),
|
||||
c = get('div', '<div>Diff:</div>'),
|
||||
diff = imagediff.diff(this.actual, expected),
|
||||
canvas = getCanvas(),
|
||||
context;
|
||||
|
||||
canvas.height = diff.height;
|
||||
canvas.width = diff.width;
|
||||
|
||||
div.style.overflow = 'hidden';
|
||||
a.style.float = 'left';
|
||||
b.style.float = 'left';
|
||||
c.style.float = 'left';
|
||||
|
||||
context = canvas.getContext('2d');
|
||||
context.putImageData(diff, 0, 0);
|
||||
|
||||
a.appendChild(toCanvas(this.actual));
|
||||
b.appendChild(toCanvas(expected));
|
||||
c.appendChild(canvas);
|
||||
|
||||
div.appendChild(a);
|
||||
div.appendChild(b);
|
||||
div.appendChild(c);
|
||||
|
||||
return [
|
||||
div,
|
||||
"Expected not to be equal."
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
return imagediff.equal(this.actual, expected, tolerance);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Image Output
|
||||
function imageDataToPNG (imageData, outputFile, callback) {
|
||||
|
||||
var
|
||||
canvas = toCanvas(imageData),
|
||||
base64Data,
|
||||
decodedImage;
|
||||
|
||||
callback = callback || Function;
|
||||
|
||||
base64Data = canvas.toDataURL().replace(/^data:image\/\w+;base64,/,"");
|
||||
decodedImage = new Buffer(base64Data, 'base64');
|
||||
require('fs').writeFile(outputFile, decodedImage, callback);
|
||||
}
|
||||
|
||||
|
||||
// Definition
|
||||
imagediff = {
|
||||
|
||||
createCanvas : getCanvas,
|
||||
createImageData : getImageData,
|
||||
|
||||
isImage : isImage,
|
||||
isCanvas : isCanvas,
|
||||
isContext : isContext,
|
||||
isImageData : isImageData,
|
||||
isImageType : isImageType,
|
||||
|
||||
toImageData : function (object) {
|
||||
checkType(object);
|
||||
if (isImageData(object)) { return copyImageData(object); }
|
||||
return toImageData(object);
|
||||
},
|
||||
|
||||
equal : function (a, b, tolerance) {
|
||||
checkType(a, b);
|
||||
a = toImageData(a);
|
||||
b = toImageData(b);
|
||||
return equal(a, b, tolerance);
|
||||
},
|
||||
diff : function (a, b, options) {
|
||||
checkType(a, b);
|
||||
a = toImageData(a);
|
||||
b = toImageData(b);
|
||||
return diff(a, b, options);
|
||||
},
|
||||
|
||||
jasmine : jasmine,
|
||||
|
||||
// Compatibility
|
||||
noConflict : function () {
|
||||
root[name] = previous;
|
||||
return imagediff;
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
imagediff.imageDataToPNG = imageDataToPNG;
|
||||
}
|
||||
|
||||
return imagediff;
|
||||
});
|
||||
121
vendors/echarts/test/ut/lib/jasmine-2.3.4/boot.js
vendored
Normal file
121
vendors/echarts/test/ut/lib/jasmine-2.3.4/boot.js
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
|
||||
|
||||
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
|
||||
|
||||
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
|
||||
|
||||
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
/**
|
||||
* ## Require & Instantiate
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
window.jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
/**
|
||||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
||||
*/
|
||||
jasmineRequire.html(jasmine);
|
||||
|
||||
/**
|
||||
* Create the Jasmine environment. This is used to run all specs in a project.
|
||||
*/
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## The Global Interface
|
||||
*
|
||||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
||||
*/
|
||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
/**
|
||||
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
extend(window, jasmineInterface);
|
||||
|
||||
/**
|
||||
* ## Runner Parameters
|
||||
*
|
||||
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
||||
*/
|
||||
|
||||
var queryString = new jasmine.QueryString({
|
||||
getWindowLocation: function() { return window.location; }
|
||||
});
|
||||
|
||||
var catchingExceptions = queryString.getParam("catch");
|
||||
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
|
||||
|
||||
var throwingExpectationFailures = queryString.getParam("throwFailures");
|
||||
env.throwOnExpectationFailure(throwingExpectationFailures);
|
||||
|
||||
/**
|
||||
* ## Reporters
|
||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||
*/
|
||||
var htmlReporter = new jasmine.HtmlReporter({
|
||||
env: env,
|
||||
onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); },
|
||||
onThrowExpectationsClick: function() { queryString.navigateWithNewParam("throwFailures", !env.throwingExpectationFailures()); },
|
||||
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
|
||||
getContainer: function() { return document.body; },
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
||||
timer: new jasmine.Timer()
|
||||
});
|
||||
|
||||
/**
|
||||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
||||
*/
|
||||
env.addReporter(jasmineInterface.jsApiReporter);
|
||||
env.addReporter(htmlReporter);
|
||||
|
||||
/**
|
||||
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
||||
*/
|
||||
var specFilter = new jasmine.HtmlSpecFilter({
|
||||
filterString: function() { return queryString.getParam("spec"); }
|
||||
});
|
||||
|
||||
env.specFilter = function(spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
/**
|
||||
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
||||
*/
|
||||
window.setTimeout = window.setTimeout;
|
||||
window.setInterval = window.setInterval;
|
||||
window.clearTimeout = window.clearTimeout;
|
||||
window.clearInterval = window.clearInterval;
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function for readability above.
|
||||
*/
|
||||
function extend(destination, source) {
|
||||
for (var property in source) destination[property] = source[property];
|
||||
return destination;
|
||||
}
|
||||
|
||||
}());
|
||||
190
vendors/echarts/test/ut/lib/jasmine-2.3.4/console.js
vendored
Normal file
190
vendors/echarts/test/ut/lib/jasmine-2.3.4/console.js
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
function getJasmineRequireObj() {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
return exports;
|
||||
} else {
|
||||
window.jasmineRequire = window.jasmineRequire || {};
|
||||
return window.jasmineRequire;
|
||||
}
|
||||
}
|
||||
|
||||
getJasmineRequireObj().console = function(jRequire, j$) {
|
||||
j$.ConsoleReporter = jRequire.ConsoleReporter();
|
||||
};
|
||||
|
||||
getJasmineRequireObj().ConsoleReporter = function() {
|
||||
|
||||
var noopTimer = {
|
||||
start: function(){},
|
||||
elapsed: function(){ return 0; }
|
||||
};
|
||||
|
||||
function ConsoleReporter(options) {
|
||||
var print = options.print,
|
||||
showColors = options.showColors || false,
|
||||
onComplete = options.onComplete || function() {},
|
||||
timer = options.timer || noopTimer,
|
||||
specCount,
|
||||
failureCount,
|
||||
failedSpecs = [],
|
||||
pendingCount,
|
||||
ansi = {
|
||||
green: '\x1B[32m',
|
||||
red: '\x1B[31m',
|
||||
yellow: '\x1B[33m',
|
||||
none: '\x1B[0m'
|
||||
},
|
||||
failedSuites = [];
|
||||
|
||||
print('ConsoleReporter is deprecated and will be removed in a future version.');
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
specCount = 0;
|
||||
failureCount = 0;
|
||||
pendingCount = 0;
|
||||
print('Started');
|
||||
printNewline();
|
||||
timer.start();
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
printNewline();
|
||||
for (var i = 0; i < failedSpecs.length; i++) {
|
||||
specFailureDetails(failedSpecs[i]);
|
||||
}
|
||||
|
||||
if(specCount > 0) {
|
||||
printNewline();
|
||||
|
||||
var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
|
||||
failureCount + ' ' + plural('failure', failureCount);
|
||||
|
||||
if (pendingCount) {
|
||||
specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
|
||||
}
|
||||
|
||||
print(specCounts);
|
||||
} else {
|
||||
print('No specs found');
|
||||
}
|
||||
|
||||
printNewline();
|
||||
var seconds = timer.elapsed() / 1000;
|
||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||
printNewline();
|
||||
|
||||
for(i = 0; i < failedSuites.length; i++) {
|
||||
suiteFailureDetails(failedSuites[i]);
|
||||
}
|
||||
|
||||
onComplete(failureCount === 0);
|
||||
};
|
||||
|
||||
this.specDone = function(result) {
|
||||
specCount++;
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingCount++;
|
||||
print(colored('yellow', '*'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'passed') {
|
||||
print(colored('green', '.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
failedSpecs.push(result);
|
||||
print(colored('red', 'F'));
|
||||
}
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||
failureCount++;
|
||||
failedSuites.push(result);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function printNewline() {
|
||||
print('\n');
|
||||
}
|
||||
|
||||
function colored(color, str) {
|
||||
return showColors ? (ansi[color] + str + ansi.none) : str;
|
||||
}
|
||||
|
||||
function plural(str, count) {
|
||||
return count == 1 ? str : str + 's';
|
||||
}
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < times; i++) {
|
||||
arr.push(thing);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function indent(str, spaces) {
|
||||
var lines = (str || '').split('\n');
|
||||
var newArr = [];
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
newArr.push(repeat(' ', spaces).join('') + lines[i]);
|
||||
}
|
||||
return newArr.join('\n');
|
||||
}
|
||||
|
||||
function specFailureDetails(result) {
|
||||
printNewline();
|
||||
print(result.fullName);
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var failedExpectation = result.failedExpectations[i];
|
||||
printNewline();
|
||||
print(indent(failedExpectation.message, 2));
|
||||
print(indent(failedExpectation.stack, 2));
|
||||
}
|
||||
|
||||
printNewline();
|
||||
}
|
||||
|
||||
function suiteFailureDetails(result) {
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
printNewline();
|
||||
print(colored('red', 'An error was thrown in an afterAll'));
|
||||
printNewline();
|
||||
print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
|
||||
|
||||
}
|
||||
printNewline();
|
||||
}
|
||||
}
|
||||
|
||||
return ConsoleReporter;
|
||||
};
|
||||
446
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine-html.js
vendored
Normal file
446
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine-html.js
vendored
Normal file
@@ -0,0 +1,446 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
jasmineRequire.html = function(j$) {
|
||||
j$.ResultsNode = jasmineRequire.ResultsNode();
|
||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||
j$.QueryString = jasmineRequire.QueryString();
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlReporter = function(j$) {
|
||||
|
||||
var noopTimer = {
|
||||
start: function() {},
|
||||
elapsed: function() { return 0; }
|
||||
};
|
||||
|
||||
function HtmlReporter(options) {
|
||||
var env = options.env || {},
|
||||
getContainer = options.getContainer,
|
||||
createElement = options.createElement,
|
||||
createTextNode = options.createTextNode,
|
||||
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
|
||||
onThrowExpectationsClick = options.onThrowExpectationsClick || function() {},
|
||||
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
|
||||
timer = options.timer || noopTimer,
|
||||
results = [],
|
||||
specsExecuted = 0,
|
||||
failureCount = 0,
|
||||
pendingSpecCount = 0,
|
||||
htmlReporterMain,
|
||||
symbols,
|
||||
failedSuites = [];
|
||||
|
||||
this.initialize = function() {
|
||||
clearPrior();
|
||||
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
|
||||
createDom('div', {className: 'banner'},
|
||||
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
|
||||
createDom('span', {className: 'version'}, j$.version)
|
||||
),
|
||||
createDom('ul', {className: 'symbol-summary'}),
|
||||
createDom('div', {className: 'alert'}),
|
||||
createDom('div', {className: 'results'},
|
||||
createDom('div', {className: 'failures'})
|
||||
)
|
||||
);
|
||||
getContainer().appendChild(htmlReporterMain);
|
||||
|
||||
symbols = find('.symbol-summary');
|
||||
};
|
||||
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var summary = createDom('div', {className: 'summary'});
|
||||
|
||||
var topResults = new j$.ResultsNode({}, '', null),
|
||||
currentParent = topResults;
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
currentParent.addChild(result, 'suite');
|
||||
currentParent = currentParent.last();
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
if (result.status == 'failed') {
|
||||
failedSuites.push(result);
|
||||
}
|
||||
|
||||
if (currentParent == topResults) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentParent = currentParent.parent;
|
||||
};
|
||||
|
||||
this.specStarted = function(result) {
|
||||
currentParent.addChild(result, 'spec');
|
||||
};
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
|
||||
console.error('Spec \'' + result.fullName + '\' has no expectations.');
|
||||
}
|
||||
|
||||
if (result.status != 'disabled') {
|
||||
specsExecuted++;
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom('li', {
|
||||
className: noExpectations(result) ? 'empty' : result.status,
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
}
|
||||
));
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
|
||||
var failure =
|
||||
createDom('div', {className: 'spec-detail failed'},
|
||||
createDom('div', {className: 'description'},
|
||||
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
|
||||
),
|
||||
createDom('div', {className: 'messages'})
|
||||
);
|
||||
var messages = failure.childNodes[1];
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var expectation = result.failedExpectations[i];
|
||||
messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message));
|
||||
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
|
||||
}
|
||||
|
||||
failures.push(failure);
|
||||
}
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingSpecCount++;
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
var banner = find('.banner');
|
||||
var alert = find('.alert');
|
||||
alert.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||
|
||||
banner.appendChild(
|
||||
createDom('div', { className: 'run-options' },
|
||||
createDom('span', { className: 'trigger' }, 'Options'),
|
||||
createDom('div', { className: 'payload' },
|
||||
createDom('div', { className: 'exceptions' },
|
||||
createDom('input', {
|
||||
className: 'raise',
|
||||
id: 'raise-exceptions',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions')),
|
||||
createDom('div', { className: 'throw-failures' },
|
||||
createDom('input', {
|
||||
className: 'throw',
|
||||
id: 'throw-failures',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'label', 'for': 'throw-failures' }, 'stop spec on expectation failure'))
|
||||
)
|
||||
));
|
||||
|
||||
var raiseCheckbox = find('#raise-exceptions');
|
||||
|
||||
raiseCheckbox.checked = !env.catchingExceptions();
|
||||
raiseCheckbox.onclick = onRaiseExceptionsClick;
|
||||
|
||||
var throwCheckbox = find('#throw-failures');
|
||||
throwCheckbox.checked = env.throwingExpectationFailures();
|
||||
throwCheckbox.onclick = onThrowExpectationsClick;
|
||||
|
||||
var optionsMenu = find('.run-options'),
|
||||
optionsTrigger = optionsMenu.querySelector('.trigger'),
|
||||
optionsPayload = optionsMenu.querySelector('.payload'),
|
||||
isOpen = /\bopen\b/;
|
||||
|
||||
optionsTrigger.onclick = function() {
|
||||
if (isOpen.test(optionsPayload.className)) {
|
||||
optionsPayload.className = optionsPayload.className.replace(isOpen, '');
|
||||
} else {
|
||||
optionsPayload.className += ' open';
|
||||
}
|
||||
};
|
||||
|
||||
if (specsExecuted < totalSpecsDefined) {
|
||||
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'bar skipped'},
|
||||
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
|
||||
)
|
||||
);
|
||||
}
|
||||
var statusBarMessage = '';
|
||||
var statusBarClassName = 'bar ';
|
||||
|
||||
if (totalSpecsDefined > 0) {
|
||||
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
||||
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
||||
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
|
||||
} else {
|
||||
statusBarClassName += 'skipped';
|
||||
statusBarMessage += 'No specs found';
|
||||
}
|
||||
|
||||
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
|
||||
|
||||
for(i = 0; i < failedSuites.length; i++) {
|
||||
var failedSuite = failedSuites[i];
|
||||
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
|
||||
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
|
||||
var errorBarClassName = 'bar errored';
|
||||
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
|
||||
}
|
||||
}
|
||||
|
||||
var results = find('.results');
|
||||
results.appendChild(summary);
|
||||
|
||||
summaryList(topResults, summary);
|
||||
|
||||
function summaryList(resultsTree, domParent) {
|
||||
var specListNode;
|
||||
for (var i = 0; i < resultsTree.children.length; i++) {
|
||||
var resultNode = resultsTree.children[i];
|
||||
if (resultNode.type == 'suite') {
|
||||
var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id},
|
||||
createDom('li', {className: 'suite-detail'},
|
||||
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
|
||||
)
|
||||
);
|
||||
|
||||
summaryList(resultNode, suiteListNode);
|
||||
domParent.appendChild(suiteListNode);
|
||||
}
|
||||
if (resultNode.type == 'spec') {
|
||||
if (domParent.getAttribute('class') != 'specs') {
|
||||
specListNode = createDom('ul', {className: 'specs'});
|
||||
domParent.appendChild(specListNode);
|
||||
}
|
||||
var specDescription = resultNode.result.description;
|
||||
if(noExpectations(resultNode.result)) {
|
||||
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
|
||||
}
|
||||
if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') {
|
||||
specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
|
||||
}
|
||||
specListNode.appendChild(
|
||||
createDom('li', {
|
||||
className: resultNode.result.status,
|
||||
id: 'spec-' + resultNode.result.id
|
||||
},
|
||||
createDom('a', {href: specHref(resultNode.result)}, specDescription)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length) {
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'menu bar spec-list'},
|
||||
createDom('span', {}, 'Spec List | '),
|
||||
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'menu bar failure-list'},
|
||||
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
|
||||
createDom('span', {}, ' | Failures ')));
|
||||
|
||||
find('.failures-menu').onclick = function() {
|
||||
setMenuModeTo('failure-list');
|
||||
};
|
||||
find('.spec-list-menu').onclick = function() {
|
||||
setMenuModeTo('spec-list');
|
||||
};
|
||||
|
||||
setMenuModeTo('failure-list');
|
||||
|
||||
var failureNode = find('.failures');
|
||||
for (var i = 0; i < failures.length; i++) {
|
||||
failureNode.appendChild(failures[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function find(selector) {
|
||||
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
||||
}
|
||||
|
||||
function clearPrior() {
|
||||
// return the reporter
|
||||
var oldReporter = find('');
|
||||
|
||||
if(oldReporter) {
|
||||
getContainer().removeChild(oldReporter);
|
||||
}
|
||||
}
|
||||
|
||||
function createDom(type, attrs, childrenVarArgs) {
|
||||
var el = createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == 'className') {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
function pluralize(singular, count) {
|
||||
var word = (count == 1 ? singular : singular + 's');
|
||||
|
||||
return '' + count + ' ' + word;
|
||||
}
|
||||
|
||||
function specHref(result) {
|
||||
return addToExistingQueryString('spec', result.fullName);
|
||||
}
|
||||
|
||||
function defaultQueryString(key, value) {
|
||||
return '?' + key + '=' + value;
|
||||
}
|
||||
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
|
||||
}
|
||||
|
||||
function noExpectations(result) {
|
||||
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
|
||||
result.status === 'passed';
|
||||
}
|
||||
}
|
||||
|
||||
return HtmlReporter;
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlSpecFilter = function() {
|
||||
function HtmlSpecFilter(options) {
|
||||
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
var filterPattern = new RegExp(filterString);
|
||||
|
||||
this.matches = function(specName) {
|
||||
return filterPattern.test(specName);
|
||||
};
|
||||
}
|
||||
|
||||
return HtmlSpecFilter;
|
||||
};
|
||||
|
||||
jasmineRequire.ResultsNode = function() {
|
||||
function ResultsNode(result, type, parent) {
|
||||
this.result = result;
|
||||
this.type = type;
|
||||
this.parent = parent;
|
||||
|
||||
this.children = [];
|
||||
|
||||
this.addChild = function(result, type) {
|
||||
this.children.push(new ResultsNode(result, type, this));
|
||||
};
|
||||
|
||||
this.last = function() {
|
||||
return this.children[this.children.length - 1];
|
||||
};
|
||||
}
|
||||
|
||||
return ResultsNode;
|
||||
};
|
||||
|
||||
jasmineRequire.QueryString = function() {
|
||||
function QueryString(options) {
|
||||
|
||||
this.navigateWithNewParam = function(key, value) {
|
||||
options.getWindowLocation().search = this.fullStringWithNewParam(key, value);
|
||||
};
|
||||
|
||||
this.fullStringWithNewParam = function(key, value) {
|
||||
var paramMap = queryStringToParamMap();
|
||||
paramMap[key] = value;
|
||||
return toQueryString(paramMap);
|
||||
};
|
||||
|
||||
this.getParam = function(key) {
|
||||
return queryStringToParamMap()[key];
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function toQueryString(paramMap) {
|
||||
var qStrPairs = [];
|
||||
for (var prop in paramMap) {
|
||||
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
|
||||
}
|
||||
return '?' + qStrPairs.join('&');
|
||||
}
|
||||
|
||||
function queryStringToParamMap() {
|
||||
var paramStr = options.getWindowLocation().search.substring(1),
|
||||
params = [],
|
||||
paramMap = {};
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
var value = decodeURIComponent(p[1]);
|
||||
if (value === 'true' || value === 'false') {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
paramMap[decodeURIComponent(p[0])] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return QueryString;
|
||||
};
|
||||
58
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine.css
vendored
Normal file
58
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine.css
vendored
Normal file
File diff suppressed because one or more lines are too long
3298
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine.js
vendored
Normal file
3298
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine_favicon.png
vendored
Normal file
BIN
vendors/echarts/test/ut/lib/jasmine-2.3.4/jasmine_favicon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
241
vendors/echarts/test/ut/spec/component/visualMap/setOption.js
vendored
Normal file
241
vendors/echarts/test/ut/spec/component/visualMap/setOption.js
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
describe('vsiaulMap_setOption', function() {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
|
||||
var testCase = utHelper.prepare([
|
||||
'echarts/component/grid',
|
||||
'echarts/chart/scatter',
|
||||
'echarts/component/visualMap'
|
||||
]);
|
||||
|
||||
testCase.createChart()('defaultTargetController', function () {
|
||||
this.chart.setOption({
|
||||
xAxis: {},
|
||||
yAxis: {},
|
||||
series: [{type: 'scatter', data: [[12, 223]]}],
|
||||
visualMap: {
|
||||
inRange: {
|
||||
color: ['red', 'blue', 'yellow']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
expect(option.visualMap.length).toEqual(1);
|
||||
expect(option.visualMap[0].inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
expect(option.visualMap[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
expect(option.visualMap[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
});
|
||||
|
||||
testCase.createChart()('ec2ColorCompatiable', function () {
|
||||
this.chart.setOption({
|
||||
xAxis: {},
|
||||
yAxis: {},
|
||||
series: [{type: 'scatter', data: [[12, 223]]}],
|
||||
visualMap: {
|
||||
color: ['yellow', 'blue', 'red']
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
expect(option.visualMap.length).toEqual(1);
|
||||
expect(option.visualMap[0].color).toEqual(['yellow', 'blue', 'red']);
|
||||
expect(option.visualMap[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
expect(option.visualMap[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
});
|
||||
|
||||
testCase.createChart()('remainVisualProp', function () {
|
||||
this.chart.setOption({
|
||||
xAxis: {},
|
||||
yAxis: {},
|
||||
series: [{type: 'scatter', data: [[12, 223]]}],
|
||||
visualMap: {
|
||||
inRange: {
|
||||
color: ['red', 'blue', 'yellow']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.chart.setOption({
|
||||
visualMap: {}
|
||||
});
|
||||
|
||||
expectTheSame(this.chart.getOption());
|
||||
|
||||
this.chart.setOption({
|
||||
series: [{data: [[44, 55]]}] // visualMap depends series
|
||||
});
|
||||
|
||||
expectTheSame(this.chart.getOption());
|
||||
|
||||
function expectTheSame(option) {
|
||||
expect(option.visualMap.length).toEqual(1);
|
||||
expect(option.visualMap[0].inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
expect(option.visualMap[0].target.inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
expect(option.visualMap[0].controller.inRange.color).toEqual(['red', 'blue', 'yellow']);
|
||||
}
|
||||
});
|
||||
|
||||
testCase.createChart()('eraseAllVisualProps_notRelative', function () {
|
||||
this.chart.setOption({
|
||||
xAxis: {},
|
||||
yAxis: {},
|
||||
series: [{type: 'scatter', data: [[12, 223]]}],
|
||||
visualMap: {
|
||||
inRange: {
|
||||
color: ['red', 'blue', 'yellow'],
|
||||
symbolSize: [0.3, 0.5]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
this.chart.setOption({
|
||||
visualMap: {
|
||||
inRange: {
|
||||
symbolSize: [0.4, 0.6]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
expect(option.visualMap.length).toEqual(1);
|
||||
expect(option.visualMap[0].inRange.hasOwnProperty('color')).toEqual(false);
|
||||
expect(option.visualMap[0].target.inRange.hasOwnProperty('color')).toEqual(false);
|
||||
expect(option.visualMap[0].controller.inRange.hasOwnProperty('color')).toEqual(false);
|
||||
expect(option.visualMap[0].inRange.symbolSize).toEqual([0.4, 0.6]);
|
||||
expect(option.visualMap[0].target.inRange.symbolSize).toEqual([0.4, 0.6]);
|
||||
// Do not compare controller.inRange.symbolSize, which will be amplified to controller size.
|
||||
// expect(option.visualMap[0].controller.inRange.symbolSize).toEqual([?, ?]);
|
||||
});
|
||||
|
||||
testCase.createChart()('eraseAllVisualProps_reletive', function () {
|
||||
this.chart.setOption({
|
||||
xAxis: {},
|
||||
yAxis: {},
|
||||
series: [{type: 'scatter', data: [[12, 223]]}],
|
||||
visualMap: {
|
||||
inRange: {
|
||||
color: ['red', 'blue', 'yellow'],
|
||||
colorAlpha: [0.3, 0.5]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.chart.setOption({
|
||||
visualMap: {
|
||||
inRange: {
|
||||
colorAlpha: [0.4, 0.6]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
expect(option.visualMap.length).toEqual(1);
|
||||
expect(option.visualMap[0].inRange.hasOwnProperty('color')).toEqual(false);
|
||||
expect(option.visualMap[0].target.inRange.hasOwnProperty('color')).toEqual(false);
|
||||
expect(option.visualMap[0].controller.inRange.hasOwnProperty('color')).toEqual(false);
|
||||
expect(option.visualMap[0].inRange.colorAlpha).toEqual([0.4, 0.6]);
|
||||
expect(option.visualMap[0].target.inRange.colorAlpha).toEqual([0.4, 0.6]);
|
||||
expect(option.visualMap[0].controller.inRange.colorAlpha).toEqual([0.4, 0.6]);
|
||||
|
||||
this.chart.setOption({
|
||||
visualMap: {
|
||||
color: ['red', 'blue', 'green']
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
expect(option.visualMap.length).toEqual(1);
|
||||
expect(option.visualMap[0].target.inRange.hasOwnProperty('colorAlpha')).toEqual(false);
|
||||
expect(option.visualMap[0].controller.inRange.hasOwnProperty('colorAlpha')).toEqual(false);
|
||||
expect(option.visualMap[0].target.inRange.color).toEqual(['green', 'blue', 'red']);
|
||||
expect(option.visualMap[0].controller.inRange.color).toEqual(['green', 'blue', 'red']);
|
||||
|
||||
this.chart.setOption({
|
||||
visualMap: {
|
||||
controller: {
|
||||
outOfRange: {
|
||||
symbol: ['diamond']
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
expect(option.visualMap.length).toEqual(1);
|
||||
expect(!option.visualMap[0].target.inRange).toEqual(true);
|
||||
expect(option.visualMap[0].controller.outOfRange.symbol).toEqual(['diamond']);
|
||||
});
|
||||
|
||||
testCase.createChart()('setOpacityWhenUseColor', function () {
|
||||
this.chart.setOption({
|
||||
xAxis: {},
|
||||
yAxis: {},
|
||||
series: [{type: 'scatter', data: [[12, 223]]}],
|
||||
visualMap: {
|
||||
inRange: {
|
||||
color: ['red', 'blue', 'yellow']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var option = this.chart.getOption();
|
||||
|
||||
expect(!!option.visualMap[0].target.outOfRange.opacity).toEqual(true);
|
||||
});
|
||||
|
||||
testCase.createChart(2)('normalizeVisualRange', function () {
|
||||
this.charts[0].setOption({
|
||||
xAxis: {},
|
||||
yAxis: {},
|
||||
series: [{type: 'scatter', data: [[12, 223]]}],
|
||||
visualMap: [
|
||||
{type: 'continuous', inRange: {color: 'red'}},
|
||||
{type: 'continuous', inRange: {opacity: 0.4}},
|
||||
{type: 'piecewise', inRange: {color: 'red'}},
|
||||
{type: 'piecewise', inRange: {opacity: 0.4}},
|
||||
{type: 'piecewise', inRange: {symbol: 'diamond'}},
|
||||
{type: 'piecewise', inRange: {color: 'red'}, categories: ['a', 'b']},
|
||||
{type: 'piecewise', inRange: {color: {a: 'red'}}, categories: ['a', 'b']},
|
||||
{type: 'piecewise', inRange: {opacity: 0.4}, categories: ['a', 'b']}
|
||||
]
|
||||
});
|
||||
|
||||
var ecModel = this.charts[0].getModel();
|
||||
|
||||
function getVisual(idx, visualType) {
|
||||
return ecModel.getComponent('visualMap', idx)
|
||||
.targetVisuals.inRange[visualType].option.visual;
|
||||
}
|
||||
|
||||
function makeCategoryVisual(val) {
|
||||
var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
|
||||
var arr = [];
|
||||
if (val != null) {
|
||||
arr[CATEGORY_DEFAULT_VISUAL_INDEX] = val;
|
||||
}
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
arr.push(arguments[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
expect(getVisual(0, 'color')).toEqual(['red']);
|
||||
expect(getVisual(1, 'opacity')).toEqual([0.4, 0.4]);
|
||||
expect(getVisual(2, 'color')).toEqual(['red']);
|
||||
expect(getVisual(3, 'opacity')).toEqual([0.4, 0.4]);
|
||||
expect(getVisual(4, 'symbol')).toEqual(['diamond']);
|
||||
expect(getVisual(5, 'color')).toEqual(makeCategoryVisual('red'));
|
||||
expect(getVisual(6, 'color')).toEqual(makeCategoryVisual(null, 'red'));
|
||||
expect(getVisual(7, 'opacity')).toEqual(makeCategoryVisual(0.4));
|
||||
});
|
||||
|
||||
});
|
||||
125
vendors/echarts/test/ut/spec/data/List.js
vendored
Normal file
125
vendors/echarts/test/ut/spec/data/List.js
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
describe('List', function () {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
|
||||
var testCase = utHelper.prepare(['echarts/data/List']);
|
||||
|
||||
describe('Data Manipulation', function () {
|
||||
|
||||
testCase('initData 1d', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([10, 20, 30]);
|
||||
expect(list.get('x', 0)).toEqual(10);
|
||||
expect(list.get('x', 1)).toEqual(20);
|
||||
expect(list.get('x', 2)).toEqual(30);
|
||||
expect(list.get('y', 1)).toEqual(20);
|
||||
});
|
||||
|
||||
testCase('initData 2d', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([[10, 15], [20, 25], [30, 35]]);
|
||||
expect(list.get('x', 1)).toEqual(20);
|
||||
expect(list.get('y', 1)).toEqual(25);
|
||||
});
|
||||
|
||||
testCase('initData 2d yx', function (List) {
|
||||
var list = new List(['y', 'x']);
|
||||
list.initData([[10, 15], [20, 25], [30, 35]]);
|
||||
expect(list.get('x', 1)).toEqual(25);
|
||||
expect(list.get('y', 1)).toEqual(20);
|
||||
});
|
||||
|
||||
testCase('Data with option 1d', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([1, {
|
||||
value: 2,
|
||||
somProp: 'foo'
|
||||
}]);
|
||||
expect(list.getItemModel(1).get('somProp')).toEqual('foo');
|
||||
expect(list.getItemModel(0).get('somProp')).toBeNull();
|
||||
});
|
||||
|
||||
testCase('Empty data', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([1, '-']);
|
||||
expect(list.get('y', 1)).toBeNaN();
|
||||
});
|
||||
|
||||
testCase('Stacked data', function (List) {
|
||||
var list1 = new List(['x', {
|
||||
name: 'y',
|
||||
stackable: true
|
||||
}]);
|
||||
var list2 = new List(['x', {
|
||||
name: 'y',
|
||||
stackable: true
|
||||
}]);
|
||||
list1.initData([1, '-', 2, -2]);
|
||||
list2.initData([1, 2, 3, 2]);
|
||||
|
||||
list2.stackedOn = list1;
|
||||
|
||||
expect(list2.get('y', 1, true)).toEqual(2);
|
||||
expect(list2.get('y', 2, true)).toEqual(5);
|
||||
expect(list2.get('y', 3, true)).toEqual(2);
|
||||
});
|
||||
|
||||
testCase('getRawValue', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
|
||||
list.initData([1, 2, 3]);
|
||||
expect(list.getItemModel(1).option).toEqual(2);
|
||||
|
||||
list.initData([[10, 15], [20, 25], [30, 35]]);
|
||||
expect(list.getItemModel(1).option).toEqual([20, 25]);
|
||||
});
|
||||
|
||||
testCase('getDataExtent', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([1, 2, 3]);
|
||||
expect(list.getDataExtent('x')).toEqual([1, 3]);
|
||||
expect(list.getDataExtent('y')).toEqual([1, 3]);
|
||||
});
|
||||
|
||||
testCase('Data types', function (List) {
|
||||
var list = new List([{
|
||||
name: 'x',
|
||||
type: 'int'
|
||||
}, {
|
||||
name: 'y',
|
||||
type: 'float'
|
||||
}]);
|
||||
list.initData([[1.1, 1.1]]);
|
||||
expect(list.get('x', 0)).toEqual(1);
|
||||
expect(list.get('y', 0)).toBeCloseTo(1.1, 5);
|
||||
});
|
||||
|
||||
testCase('map', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([[10, 15], [20, 25], [30, 35]]);
|
||||
expect(list.map(['x', 'y'], function (x, y) {
|
||||
return [x + 2, y + 2];
|
||||
}).mapArray('x', function (x) {
|
||||
return x;
|
||||
})).toEqual([12, 22, 32]);
|
||||
});
|
||||
|
||||
testCase('mapArray', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([[10, 15], [20, 25], [30, 35]]);
|
||||
expect(list.mapArray(['x', 'y'], function (x, y) {
|
||||
return [x, y];
|
||||
})).toEqual([[10, 15], [20, 25], [30, 35]]);
|
||||
});
|
||||
|
||||
testCase('filterSelf', function (List) {
|
||||
var list = new List(['x', 'y']);
|
||||
list.initData([[10, 15], [20, 25], [30, 35]]);
|
||||
expect(list.filterSelf(['x', 'y'], function (x, y) {
|
||||
return x < 30 && x > 10;
|
||||
}).mapArray('x', function (x) {
|
||||
return x;
|
||||
})).toEqual([20]);
|
||||
});
|
||||
});
|
||||
});
|
||||
136
vendors/echarts/test/ut/spec/model/Component.js
vendored
Normal file
136
vendors/echarts/test/ut/spec/model/Component.js
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
describe('Component', function() {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
|
||||
var testCase = utHelper.prepare(['echarts/model/Component']);
|
||||
|
||||
describe('topologicalTravel', function () {
|
||||
|
||||
testCase('topologicalTravel_base', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a1', 'a2']});
|
||||
ComponentModel.extend({type: 'a1'});
|
||||
ComponentModel.extend({type: 'a2'});
|
||||
var result = [];
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
ComponentModel.topologicalTravel(['m1', 'a1', 'a2'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a2', []], ['a1', []], ['m1', ['a1', 'a2']]]);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_a1IsAbsent', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a1', 'a2']});
|
||||
ComponentModel.extend({type: 'a2'});
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
var result = [];
|
||||
ComponentModel.topologicalTravel(['m1', 'a2'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a2', []], ['m1', ['a1', 'a2']]]);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_empty', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a1', 'a2']});
|
||||
ComponentModel.extend({type: 'a1'});
|
||||
ComponentModel.extend({type: 'a2'});
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
var result = [];
|
||||
ComponentModel.topologicalTravel([], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_isolate', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'a2'});
|
||||
ComponentModel.extend({type: 'a1'});
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a2']});
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
var result = [];
|
||||
ComponentModel.topologicalTravel(['a1', 'a2', 'm1'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a1', []], ['a2', []], ['m1', ['a2']]]);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_diamond', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'a1', dependencies: []});
|
||||
ComponentModel.extend({type: 'a2', dependencies: ['a1']});
|
||||
ComponentModel.extend({type: 'a3', dependencies: ['a1']});
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a2', 'a3']});
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
var result = [];
|
||||
ComponentModel.topologicalTravel(['m1', 'a1', 'a2', 'a3'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a1', []], ['a3', ['a1']], ['a2', ['a1']], ['m1', ['a2', 'a3']]]);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_loop', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a1', 'a2']});
|
||||
ComponentModel.extend({type: 'm2', dependencies: ['m1', 'a2']});
|
||||
ComponentModel.extend({type: 'a1', dependencies: ['m2', 'a2', 'a3']});
|
||||
ComponentModel.extend({type: 'a2'});
|
||||
ComponentModel.extend({type: 'a3'});
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
expect(function () {
|
||||
ComponentModel.topologicalTravel(['m1', 'm2', 'a1'], allList);
|
||||
}).toThrowError(/Circl/);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_multipleEchartsInstance', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a1', 'a2']});
|
||||
ComponentModel.extend({type: 'a1'});
|
||||
ComponentModel.extend({type: 'a2'});
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
var result = [];
|
||||
ComponentModel.topologicalTravel(['m1', 'a1', 'a2'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a2', []], ['a1', []], ['m1', ['a1', 'a2']]]);
|
||||
|
||||
result = [];
|
||||
ComponentModel.extend({type: 'm2', dependencies: ['a1', 'm1']});
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
ComponentModel.topologicalTravel(['m2', 'm1', 'a1', 'a2'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a2', []], ['a1', []], ['m1', ['a1', 'a2']], ['m2', ['a1', 'm1']]]);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_missingSomeNodeButHasDependencies', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a1', 'a2']});
|
||||
ComponentModel.extend({type: 'a2', dependencies: ['a3']});
|
||||
ComponentModel.extend({type: 'a3'});
|
||||
ComponentModel.extend({type: 'a4'});
|
||||
var result = [];
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
ComponentModel.topologicalTravel(['a3', 'm1'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a3', []], ['a2', ['a3']], ['m1', ['a1', 'a2']]]);
|
||||
var result = [];
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
ComponentModel.topologicalTravel(['m1', 'a3'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a3', []], ['a2', ['a3']], ['m1', ['a1', 'a2']]]);
|
||||
});
|
||||
|
||||
testCase('topologicalTravel_subType', function (ComponentModel) {
|
||||
ComponentModel.extend({type: 'm1', dependencies: ['a1', 'a2']});
|
||||
ComponentModel.extend({type: 'a1.aaa', dependencies: ['a2']});
|
||||
ComponentModel.extend({type: 'a1.bbb', dependencies: ['a3', 'a4']});
|
||||
ComponentModel.extend({type: 'a2'});
|
||||
ComponentModel.extend({type: 'a3'});
|
||||
ComponentModel.extend({type: 'a4'});
|
||||
var result = [];
|
||||
var allList = ComponentModel.getAllClassMainTypes();
|
||||
ComponentModel.topologicalTravel(['m1', 'a1', 'a2', 'a4'], allList, function (componentType, dependencies) {
|
||||
result.push([componentType, dependencies]);
|
||||
});
|
||||
expect(result).toEqual([['a4', []], ['a2',[]], ['a1', ['a2','a3','a4']], ['m1', ['a1', 'a2']]]);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
808
vendors/echarts/test/ut/spec/model/Global.js
vendored
Normal file
808
vendors/echarts/test/ut/spec/model/Global.js
vendored
Normal file
@@ -0,0 +1,808 @@
|
||||
describe('modelAndOptionMapping', function() {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
|
||||
var testCase = utHelper.prepare([
|
||||
'echarts/component/grid',
|
||||
'echarts/chart/line',
|
||||
'echarts/chart/pie',
|
||||
'echarts/chart/bar',
|
||||
'echarts/component/toolbox',
|
||||
'echarts/component/dataZoom'
|
||||
]);
|
||||
|
||||
function getData0(chart, seriesIndex) {
|
||||
return getSeries(chart, seriesIndex).getData().get('y', 0);
|
||||
}
|
||||
|
||||
function getSeries(chart, seriesIndex) {
|
||||
return chart.getModel().getComponent('series', seriesIndex);
|
||||
}
|
||||
|
||||
function getModel(chart, type, index) {
|
||||
return chart.getModel().getComponent(type, index);
|
||||
}
|
||||
|
||||
function countSeries(chart) {
|
||||
return countModel(chart, 'series');
|
||||
}
|
||||
|
||||
function countModel(chart, type) {
|
||||
// FIXME
|
||||
// access private
|
||||
return chart.getModel()._componentsMap[type].length;
|
||||
}
|
||||
|
||||
function getChartView(chart, series) {
|
||||
return chart._chartsMap[series.__viewId];
|
||||
}
|
||||
|
||||
function countChartViews(chart) {
|
||||
return chart._chartsViews.length;
|
||||
}
|
||||
|
||||
function saveOrigins(chart) {
|
||||
var count = countSeries(chart);
|
||||
var origins = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
var series = getSeries(chart, i);
|
||||
origins.push({
|
||||
model: series,
|
||||
view: getChartView(chart, series)
|
||||
});
|
||||
}
|
||||
return origins;
|
||||
}
|
||||
|
||||
function modelEqualsToOrigin(chart, idxList, origins, boolResult) {
|
||||
for (var i = 0; i < idxList.length; i++) {
|
||||
var idx = idxList[i];
|
||||
expect(origins[idx].model === getSeries(chart, idx)).toEqual(boolResult);
|
||||
}
|
||||
}
|
||||
|
||||
function viewEqualsToOrigin(chart, idxList, origins, boolResult) {
|
||||
for (var i = 0; i < idxList.length; i++) {
|
||||
var idx = idxList[i];
|
||||
expect(
|
||||
origins[idx].view === getChartView(chart, getSeries(chart, idx))
|
||||
).toEqual(boolResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
describe('idNoNameNo', function () {
|
||||
|
||||
testCase.createChart()('sameTypeNotMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]},
|
||||
{type: 'line', data: [33]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
// Not merge
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption(option, true);
|
||||
expect(countChartViews(chart)).toEqual(3);
|
||||
expect(countSeries(chart)).toEqual(3);
|
||||
modelEqualsToOrigin(chart, [0, 1, 2], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2], origins, true);
|
||||
});
|
||||
|
||||
testCase.createChart()('sameTypeMergeFull', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]},
|
||||
{type: 'line', data: [33]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
// Merge
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption({
|
||||
series: [
|
||||
{type: 'line', data: [111]},
|
||||
{type: 'line', data: [222]},
|
||||
{type: 'line', data: [333]}
|
||||
]
|
||||
});
|
||||
|
||||
expect(countSeries(chart)).toEqual(3);
|
||||
expect(countChartViews(chart)).toEqual(3);
|
||||
expect(getData0(chart, 0)).toEqual(111);
|
||||
expect(getData0(chart, 1)).toEqual(222);
|
||||
expect(getData0(chart, 2)).toEqual(333);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2], origins, true);
|
||||
modelEqualsToOrigin(chart, [0, 1, 2], origins, true);
|
||||
});
|
||||
|
||||
testCase.createChart()('sameTypeMergePartial', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]},
|
||||
{type: 'line', data: [33]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
// Merge
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption({
|
||||
series: [
|
||||
{type: 'line', data: [22222]}
|
||||
]
|
||||
});
|
||||
|
||||
expect(countSeries(chart)).toEqual(3);
|
||||
expect(countChartViews(chart)).toEqual(3);
|
||||
expect(getData0(chart, 0)).toEqual(22222);
|
||||
expect(getData0(chart, 1)).toEqual(22);
|
||||
expect(getData0(chart, 2)).toEqual(33);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2], origins, true);
|
||||
modelEqualsToOrigin(chart, [0, 1, 2], origins, true);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]},
|
||||
{type: 'line', data: [33]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
// Merge
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption({
|
||||
series: [
|
||||
{type: 'line', data: [111]},
|
||||
{type: 'bar', data: [222]},
|
||||
{type: 'line', data: [333]}
|
||||
]
|
||||
});
|
||||
|
||||
expect(countSeries(chart)).toEqual(3);
|
||||
expect(countChartViews(chart)).toEqual(3);
|
||||
expect(getData0(chart, 0)).toEqual(111);
|
||||
expect(getData0(chart, 1)).toEqual(222);
|
||||
expect(getData0(chart, 2)).toEqual(333);
|
||||
expect(getSeries(chart, 1).type === 'series.bar').toEqual(true);
|
||||
modelEqualsToOrigin(chart, [0, 2], origins, true);
|
||||
modelEqualsToOrigin(chart, [1], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 2], origins, true);
|
||||
viewEqualsToOrigin(chart, [1], origins, false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
describe('idSpecified', function () {
|
||||
|
||||
testCase.createChart()('sameTypeNotMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], id: 20},
|
||||
{type: 'line', data: [33], id: 30},
|
||||
{type: 'line', data: [44]},
|
||||
{type: 'line', data: [55]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(getData0(chart, 0)).toEqual(11);
|
||||
expect(getData0(chart, 1)).toEqual(22);
|
||||
expect(getData0(chart, 2)).toEqual(33);
|
||||
expect(getData0(chart, 3)).toEqual(44);
|
||||
expect(getData0(chart, 4)).toEqual(55);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption(option, true);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
|
||||
});
|
||||
|
||||
testCase.createChart()('sameTypeMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], id: 20},
|
||||
{type: 'line', data: [33], id: 30},
|
||||
{type: 'line', data: [44]},
|
||||
{type: 'line', data: [55]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption(option);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeNotMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], id: 20},
|
||||
{type: 'line', data: [33], id: 30},
|
||||
{type: 'line', data: [44]},
|
||||
{type: 'line', data: [55]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
var option2 = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'bar', data: [22], id: 20},
|
||||
{type: 'line', data: [33], id: 30},
|
||||
{type: 'bar', data: [44]},
|
||||
{type: 'line', data: [55]}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2, true);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 2, 4], origins, true);
|
||||
viewEqualsToOrigin(chart, [1, 3], origins, false);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeMergeFull', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], id: 20},
|
||||
{type: 'line', data: [33], id: 30, name: 'a'},
|
||||
{type: 'line', data: [44]},
|
||||
{type: 'line', data: [55]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
var option2 = {
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'bar', data: [22], id: 20, name: 'a'},
|
||||
{type: 'line', data: [33], id: 30},
|
||||
{type: 'bar', data: [44]},
|
||||
{type: 'line', data: [55]}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
modelEqualsToOrigin(chart, [0, 2, 4], origins, true);
|
||||
modelEqualsToOrigin(chart, [1, 3], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 2, 4], origins, true);
|
||||
viewEqualsToOrigin(chart, [1, 3], origins, false);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeMergePartial1', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], id: 20},
|
||||
{type: 'line', data: [33]},
|
||||
{type: 'line', data: [44], id: 40},
|
||||
{type: 'line', data: [55]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
var option2 = {
|
||||
series: [
|
||||
{type: 'bar', data: [444], id: 40},
|
||||
{type: 'line', data: [333]},
|
||||
{type: 'line', data: [222], id: 20}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(333);
|
||||
expect(getData0(chart, 1)).toEqual(222);
|
||||
expect(getData0(chart, 2)).toEqual(33);
|
||||
expect(getData0(chart, 3)).toEqual(444);
|
||||
expect(getData0(chart, 4)).toEqual(55);
|
||||
modelEqualsToOrigin(chart, [0, 1, 2, 4], origins, true);
|
||||
modelEqualsToOrigin(chart, [3], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2, 4], origins, true);
|
||||
viewEqualsToOrigin(chart, [3], origins, false);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeMergePartial2', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], id: 20}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var option2 = {
|
||||
series: [
|
||||
{type: 'bar', data: [444], id: 40},
|
||||
{type: 'line', data: [333]},
|
||||
{type: 'line', data: [222], id: 20},
|
||||
{type: 'line', data: [111]}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2);
|
||||
expect(countChartViews(chart)).toEqual(4);
|
||||
expect(countSeries(chart)).toEqual(4);
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(333);
|
||||
expect(getData0(chart, 1)).toEqual(222);
|
||||
expect(getData0(chart, 2)).toEqual(444);
|
||||
expect(getData0(chart, 3)).toEqual(111);
|
||||
});
|
||||
|
||||
|
||||
testCase.createChart()('mergePartialDoNotMapToOtherId', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11], id: 10},
|
||||
{type: 'line', data: [22], id: 20}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var option2 = {
|
||||
series: [
|
||||
{type: 'bar', data: [444], id: 40}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2);
|
||||
expect(countChartViews(chart)).toEqual(3);
|
||||
expect(countSeries(chart)).toEqual(3);
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(11);
|
||||
expect(getData0(chart, 1)).toEqual(22);
|
||||
expect(getData0(chart, 2)).toEqual(444);
|
||||
});
|
||||
|
||||
|
||||
testCase.createChart()('idDuplicate', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11], id: 10},
|
||||
{type: 'line', data: [22], id: 10}
|
||||
]
|
||||
};
|
||||
|
||||
var chart = this.chart;
|
||||
|
||||
expect(function () {
|
||||
chart.setOption(option);
|
||||
}).toThrowError(/duplicate/);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
describe('noIdButNameExists', function () {
|
||||
|
||||
testCase.createChart()('sameTypeNotMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], name: 'a'},
|
||||
{type: 'line', data: [33], name: 'b'},
|
||||
{type: 'line', data: [44]},
|
||||
{type: 'line', data: [55], name: 'a'}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
expect(getSeries(chart, 1)).not.toEqual(getSeries(chart, 4));
|
||||
|
||||
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(getData0(chart, 0)).toEqual(11);
|
||||
expect(getData0(chart, 1)).toEqual(22);
|
||||
expect(getData0(chart, 2)).toEqual(33);
|
||||
expect(getData0(chart, 3)).toEqual(44);
|
||||
expect(getData0(chart, 4)).toEqual(55);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption(option, true);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
|
||||
});
|
||||
|
||||
testCase.createChart()('sameTypeMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], name: 'a'},
|
||||
{type: 'line', data: [33], name: 'b'},
|
||||
{type: 'line', data: [44]},
|
||||
{type: 'line', data: [55], name: 'a'}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
chart.setOption(option);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
|
||||
viewEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, true);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeNotMerge', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], name: 'a'},
|
||||
{type: 'line', data: [33], name: 'b'},
|
||||
{type: 'line', data: [44]},
|
||||
{type: 'line', data: [55], name: 'a'}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
var option2 = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'bar', data: [22], name: 'a'},
|
||||
{type: 'line', data: [33], name: 'b'},
|
||||
{type: 'bar', data: [44]},
|
||||
{type: 'line', data: [55], name: 'a'}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2, true);
|
||||
expect(countChartViews(chart)).toEqual(5);
|
||||
expect(countSeries(chart)).toEqual(5);
|
||||
|
||||
modelEqualsToOrigin(chart, [0, 1, 2, 3, 4], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 2, 4], origins, true);
|
||||
viewEqualsToOrigin(chart, [1, 3], origins, false);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeMergePartialOneMapTwo', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], name: 'a'},
|
||||
{type: 'line', data: [33]},
|
||||
{type: 'line', data: [44], name: 'b'},
|
||||
{type: 'line', data: [55], name: 'a'}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var origins = saveOrigins(chart);
|
||||
var option2 = {
|
||||
series: [
|
||||
{type: 'bar', data: [444], id: 40},
|
||||
{type: 'line', data: [333]},
|
||||
{type: 'bar', data: [222], name: 'a'}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2);
|
||||
expect(countChartViews(chart)).toEqual(6);
|
||||
expect(countSeries(chart)).toEqual(6);
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(333);
|
||||
expect(getData0(chart, 1)).toEqual(222);
|
||||
expect(getData0(chart, 2)).toEqual(33);
|
||||
expect(getData0(chart, 3)).toEqual(44);
|
||||
expect(getData0(chart, 4)).toEqual(55);
|
||||
expect(getData0(chart, 5)).toEqual(444);
|
||||
modelEqualsToOrigin(chart, [0, 2, 3, 4], origins, true);
|
||||
modelEqualsToOrigin(chart, [1], origins, false);
|
||||
viewEqualsToOrigin(chart, [0, 2, 3, 4], origins, true);
|
||||
viewEqualsToOrigin(chart, [1], origins, false);
|
||||
});
|
||||
|
||||
testCase.createChart()('differentTypeMergePartialTwoMapOne', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22], name: 'a'}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var option2 = {
|
||||
series: [
|
||||
{type: 'bar', data: [444], name: 'a'},
|
||||
{type: 'line', data: [333]},
|
||||
{type: 'line', data: [222], name: 'a'},
|
||||
{type: 'line', data: [111]}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2);
|
||||
expect(countChartViews(chart)).toEqual(4);
|
||||
expect(countSeries(chart)).toEqual(4);
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(333);
|
||||
expect(getData0(chart, 1)).toEqual(444);
|
||||
expect(getData0(chart, 2)).toEqual(222);
|
||||
expect(getData0(chart, 3)).toEqual(111);
|
||||
});
|
||||
|
||||
testCase.createChart()('mergePartialCanMapToOtherName', function () {
|
||||
// Consider case: axis.name = 'some label', which can be overwritten.
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11], name: 10},
|
||||
{type: 'line', data: [22], name: 20}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var option2 = {
|
||||
series: [
|
||||
{type: 'bar', data: [444], name: 40},
|
||||
{type: 'bar', data: [999], name: 40},
|
||||
{type: 'bar', data: [777], id: 70}
|
||||
]
|
||||
};
|
||||
chart.setOption(option2);
|
||||
expect(countChartViews(chart)).toEqual(3);
|
||||
expect(countSeries(chart)).toEqual(3);
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(444);
|
||||
expect(getData0(chart, 1)).toEqual(999);
|
||||
expect(getData0(chart, 2)).toEqual(777);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
describe('ohters', function () {
|
||||
|
||||
testCase.createChart()('aBugCase', function () {
|
||||
var option = {
|
||||
series: [
|
||||
{
|
||||
type:'pie',
|
||||
radius: ['20%', '25%'],
|
||||
center:['20%', '20%'],
|
||||
avoidLabelOverlap: true,
|
||||
hoverAnimation :false,
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'center',
|
||||
textStyle: {
|
||||
fontSize: '30',
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
},
|
||||
emphasis: {
|
||||
show: true
|
||||
}
|
||||
},
|
||||
data:[
|
||||
{value:135, name:'视频广告'},
|
||||
{value:1548}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
chart.setOption({
|
||||
series: [
|
||||
{
|
||||
type:'pie',
|
||||
radius: ['20%', '25%'],
|
||||
center: ['20%', '20%'],
|
||||
avoidLabelOverlap: true,
|
||||
hoverAnimation: false,
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'center',
|
||||
textStyle: {
|
||||
fontSize: '30',
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
}
|
||||
},
|
||||
data: [
|
||||
{value:135, name:'视频广告'},
|
||||
{value:1548}
|
||||
]
|
||||
},
|
||||
{
|
||||
type:'pie',
|
||||
radius: ['20%', '25%'],
|
||||
center: ['60%', '20%'],
|
||||
avoidLabelOverlap: true,
|
||||
hoverAnimation: false,
|
||||
label: {
|
||||
normal: {
|
||||
show: true,
|
||||
position: 'center',
|
||||
textStyle: {
|
||||
fontSize: '30',
|
||||
fontWeight: 'bold'
|
||||
}
|
||||
}
|
||||
},
|
||||
data: [
|
||||
{value:135, name:'视频广告'},
|
||||
{value:1548}
|
||||
]
|
||||
}
|
||||
]
|
||||
}, true);
|
||||
|
||||
expect(countChartViews(chart)).toEqual(2);
|
||||
expect(countSeries(chart)).toEqual(2);
|
||||
});
|
||||
|
||||
testCase.createChart()('color', function () {
|
||||
var option = {
|
||||
backgroundColor: 'rgba(1,1,1,1)',
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]},
|
||||
{type: 'line', data: [33]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
expect(chart._model.option.backgroundColor).toEqual('rgba(1,1,1,1)');
|
||||
|
||||
// Not merge
|
||||
chart.setOption({
|
||||
backgroundColor: '#fff'
|
||||
}, true);
|
||||
|
||||
expect(chart._model.option.backgroundColor).toEqual('#fff');
|
||||
});
|
||||
|
||||
testCase.createChart()('innerId', function () {
|
||||
var option = {
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {},
|
||||
toolbox: {
|
||||
feature: {
|
||||
dataZoom: {}
|
||||
}
|
||||
},
|
||||
dataZoom: [
|
||||
{type: 'inside', id: 'a'},
|
||||
{type: 'slider', id: 'b'}
|
||||
],
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
expect(countModel(chart, 'dataZoom')).toEqual(4);
|
||||
expect(getModel(chart, 'dataZoom', 0).id).toEqual('a');
|
||||
expect(getModel(chart, 'dataZoom', 1).id).toEqual('b');
|
||||
|
||||
// Merge
|
||||
chart.setOption({
|
||||
dataZoom: [
|
||||
{type: 'slider', id: 'c'},
|
||||
{type: 'slider', name: 'x'}
|
||||
]
|
||||
});
|
||||
|
||||
expect(countModel(chart, 'dataZoom')).toEqual(5);
|
||||
expect(getModel(chart, 'dataZoom', 0).id).toEqual('a');
|
||||
expect(getModel(chart, 'dataZoom', 1).id).toEqual('b');
|
||||
expect(getModel(chart, 'dataZoom', 4).id).toEqual('c');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
161
vendors/echarts/test/ut/spec/model/timelineOptions.js
vendored
Normal file
161
vendors/echarts/test/ut/spec/model/timelineOptions.js
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
describe('timelineOptions', function() {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
|
||||
var testCase = utHelper.prepare([
|
||||
'echarts/component/grid',
|
||||
'echarts/chart/line',
|
||||
'echarts/chart/pie',
|
||||
'echarts/chart/bar',
|
||||
'echarts/component/timeline'
|
||||
]);
|
||||
|
||||
function getData0(chart, seriesIndex) {
|
||||
return getSeries(chart, seriesIndex).getData().get('y', 0);
|
||||
}
|
||||
|
||||
function getSeries(chart, seriesIndex) {
|
||||
return chart.getModel().getComponent('series', seriesIndex);
|
||||
}
|
||||
|
||||
testCase.createChart()('timeline_setOptionOnceMore_baseOption', function () {
|
||||
var option = {
|
||||
baseOption: {
|
||||
timeline: {
|
||||
axisType: 'category',
|
||||
autoPlay: false,
|
||||
playInterval: 1000
|
||||
},
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {}
|
||||
},
|
||||
options: [
|
||||
{
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]}
|
||||
]
|
||||
},
|
||||
{
|
||||
series: [
|
||||
{type: 'line', data: [111]},
|
||||
{type: 'line', data: [222]}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(11);
|
||||
expect(getData0(chart, 1)).toEqual(22);
|
||||
|
||||
chart.setOption({
|
||||
xAxis: {data: ['b']}
|
||||
});
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(11);
|
||||
expect(getData0(chart, 1)).toEqual(22);
|
||||
|
||||
chart.setOption({
|
||||
xAxis: {data: ['c']},
|
||||
timeline: {
|
||||
currentIndex: 1
|
||||
}
|
||||
});
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(111);
|
||||
expect(getData0(chart, 1)).toEqual(222);
|
||||
});
|
||||
|
||||
|
||||
|
||||
testCase.createChart()('timeline_setOptionOnceMore_substitudeTimelineOptions', function () {
|
||||
var option = {
|
||||
baseOption: {
|
||||
timeline: {
|
||||
axisType: 'category',
|
||||
autoPlay: false,
|
||||
playInterval: 1000,
|
||||
currentIndex: 2
|
||||
},
|
||||
xAxis: {data: ['a']},
|
||||
yAxis: {}
|
||||
},
|
||||
options: [
|
||||
{
|
||||
series: [
|
||||
{type: 'line', data: [11]},
|
||||
{type: 'line', data: [22]}
|
||||
]
|
||||
},
|
||||
{
|
||||
series: [
|
||||
{type: 'line', data: [111]},
|
||||
{type: 'line', data: [222]}
|
||||
]
|
||||
},
|
||||
{
|
||||
series: [
|
||||
{type: 'line', data: [1111]},
|
||||
{type: 'line', data: [2222]}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var chart = this.chart;
|
||||
chart.setOption(option);
|
||||
|
||||
var ecModel = chart.getModel();
|
||||
expect(getData0(chart, 0)).toEqual(1111);
|
||||
expect(getData0(chart, 1)).toEqual(2222);
|
||||
|
||||
chart.setOption({
|
||||
baseOption: {
|
||||
backgroundColor: '#987654',
|
||||
xAxis: {data: ['b']}
|
||||
},
|
||||
options: [
|
||||
{
|
||||
series: [
|
||||
{type: 'line', data: [55]},
|
||||
{type: 'line', data: [66]}
|
||||
]
|
||||
},
|
||||
{
|
||||
series: [
|
||||
{type: 'line', data: [555]},
|
||||
{type: 'line', data: [666]}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var ecModel = chart.getModel();
|
||||
var option = ecModel.getOption();
|
||||
expect(option.backgroundColor).toEqual('#987654');
|
||||
expect(getData0(chart, 0)).toEqual(1111);
|
||||
expect(getData0(chart, 1)).toEqual(2222);
|
||||
|
||||
chart.setOption({
|
||||
timeline: {
|
||||
currentIndex: 0
|
||||
}
|
||||
});
|
||||
|
||||
expect(getData0(chart, 0)).toEqual(55);
|
||||
expect(getData0(chart, 1)).toEqual(66);
|
||||
|
||||
chart.setOption({
|
||||
timeline: {
|
||||
currentIndex: 2
|
||||
}
|
||||
});
|
||||
|
||||
// no 1111 2222 any more, replaced totally by new timeline.
|
||||
expect(getData0(chart, 0)).toEqual(55);
|
||||
expect(getData0(chart, 1)).toEqual(66);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
6
vendors/echarts/test/ut/spec/ui/config.js
vendored
Normal file
6
vendors/echarts/test/ut/spec/ui/config.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
require.config({
|
||||
paths: {
|
||||
'oldEcharts': 'tmp/oldEcharts',
|
||||
'newEcharts': 'tmp/newEcharts'
|
||||
}
|
||||
});
|
||||
586
vendors/echarts/test/ut/spec/ui/legend.js
vendored
Normal file
586
vendors/echarts/test/ut/spec/ui/legend.js
vendored
Normal file
@@ -0,0 +1,586 @@
|
||||
describe('legend', function() {
|
||||
|
||||
var uiHelper = window.uiHelper;
|
||||
|
||||
var suites = [{
|
||||
name: 'show',
|
||||
cases: [{
|
||||
name: 'should display legend as default',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a']
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should hide legend when show set to be false',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
show: false
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'left',
|
||||
cases: [{
|
||||
name: 'should display left position',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
left: 'left'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at 20%',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
left: '20%'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at center',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
left: 'center'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at right',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
left: 'right'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'top',
|
||||
cases: [{
|
||||
name: 'should display top position',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
top: 50
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at 20%',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
top: '20%'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at middle',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
top: 'middle'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at bottom',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
top: 'bottom'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'right',
|
||||
cases: [{
|
||||
name: 'should display right position',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
right: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'bottom',
|
||||
cases: [{
|
||||
name: 'should display bottom position',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
bottom: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'left and right',
|
||||
cases: [{
|
||||
name: 'are both set',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
left: 50,
|
||||
right: 50
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
left: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'top and bottom',
|
||||
cases: [{
|
||||
name: 'are both set',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
top: 50,
|
||||
bottom: 50
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [{
|
||||
name: 'a',
|
||||
type: 'line',
|
||||
data: [1, 2, 4]
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['a'],
|
||||
top: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'width',
|
||||
cases: [{
|
||||
name: 'should display in seperate lines',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c'],
|
||||
width: 200
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c']
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'hight',
|
||||
cases: [{
|
||||
name: 'should display in seperate lines',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c'],
|
||||
height: 50,
|
||||
orient: 'vertical'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c'],
|
||||
orient: 'vertical'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'orient',
|
||||
cases: [{
|
||||
name: 'should display horizontally',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c'],
|
||||
orient: 'horizontal'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display vertically',
|
||||
option: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c'],
|
||||
orient: 'vertical'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display different with horizontal and vertical',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c'],
|
||||
orient: 'vertical'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [{
|
||||
name: 'this is a',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is b',
|
||||
type: 'line',
|
||||
data: []
|
||||
}, {
|
||||
name: 'this is c',
|
||||
type: 'line',
|
||||
data: []
|
||||
}],
|
||||
xAxis : [{
|
||||
type : 'category',
|
||||
data : ['x','y','z']
|
||||
}],
|
||||
yAxis : [{
|
||||
type : 'value'
|
||||
}],
|
||||
legend: {
|
||||
data: ['this is a', 'this is b',
|
||||
'this is c']
|
||||
}
|
||||
}
|
||||
}]
|
||||
}];
|
||||
|
||||
uiHelper.testOptionSpec('legend', suites);
|
||||
|
||||
});
|
||||
434
vendors/echarts/test/ut/spec/ui/title.js
vendored
Normal file
434
vendors/echarts/test/ut/spec/ui/title.js
vendored
Normal file
@@ -0,0 +1,434 @@
|
||||
describe('title', function() {
|
||||
|
||||
var uiHelper = window.uiHelper;
|
||||
|
||||
var suites = [{
|
||||
name: 'show',
|
||||
cases: [{
|
||||
name: 'should display given title by default',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'test title'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should hide title when show is false',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'hidden title',
|
||||
display: false
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'text',
|
||||
cases: [{
|
||||
name: 'should display title',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'here is a title'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display long title in a line',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'here is a very long long long long long long long '
|
||||
+ 'long long long long long long long long long long '
|
||||
+ 'long long long long long long long long long title'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should run into a new line with \\n',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'first line\nsecond line'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display no title by default',
|
||||
option: {
|
||||
series: []
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'subtext',
|
||||
cases: [{
|
||||
name: 'should display subtext without text',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'subtext without text'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display subtext with text',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is text',
|
||||
subtext: 'subtext without text'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'padding',
|
||||
cases: [{
|
||||
name: 'should display padding 5px as default',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title with 5px padding'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title with 5px padding',
|
||||
padding: 5
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display one-value padding',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'should display one-value padding'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'should display one-value padding',
|
||||
padding: 50
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display two-value padding',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'display two-value padding'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'display two-value padding',
|
||||
padding: [20, 50]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display four-value padding',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'compare padding with 10, 30, 50, 70'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'compare padding with 10, 30, 50, 70',
|
||||
padding: [10, 30, 50, 70]
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display four-value and two-value padding accordingly',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'compare padding with 20, 50 and 20, 50, 20, 50',
|
||||
padding: [20, 50]
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'compare padding with 20, 50 and 20, 50, 20, 50',
|
||||
padding: [20, 50, 20, 50]
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'itemGap',
|
||||
cases: [{
|
||||
name: 'should have default itemGap as 5px',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'title',
|
||||
subtext: 'subtext'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'title',
|
||||
subtext: 'subtext',
|
||||
itemGap: 5
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'left',
|
||||
cases: [{
|
||||
name: 'should display left position',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
left: 50
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at 20%',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
left: '20%'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at center',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
left: 'center'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at right',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
left: 'right'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'top',
|
||||
cases: [{
|
||||
name: 'should display top position',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
top: 50
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at 20%',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
top: '20%'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at middle',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
top: 'middle'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display at bottom',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
top: 'bottom'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'right',
|
||||
cases: [{
|
||||
name: 'should display right position',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
right: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'bottom',
|
||||
cases: [{
|
||||
name: 'should display bottom position',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
bottom: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'left and right',
|
||||
cases: [{
|
||||
name: 'are both set',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
left: 50,
|
||||
right: 50
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
left: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'top and bottom',
|
||||
cases: [{
|
||||
name: 'are both set',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
top: 50,
|
||||
bottom: 50
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
top: 50
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'backgroundColor',
|
||||
cases: [{
|
||||
name: 'should show specific background color',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
backgroundColor: 'rgba(255, 100, 0, 0.2)'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'borderColor',
|
||||
cases: [{
|
||||
name: 'should show specific border color at default border width',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
borderColor: '#f00'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
borderColor: '#f00',
|
||||
borderWidth: 1
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display larger border width',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'this is title',
|
||||
borderWidth: 15
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'shadowBlur and shadowColor',
|
||||
cases: [{
|
||||
name: 'should display shadow blur',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
backgroundColor: 'green',
|
||||
text: 'this is title',
|
||||
shadowColor: 'red',
|
||||
shadowBlur: 5
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'shadowOffsetX',
|
||||
cases: [{
|
||||
name: 'should display shadow blur',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
backgroundColor: 'green',
|
||||
text: 'this is title',
|
||||
shadowColor: 'red',
|
||||
shadowBlur: 5,
|
||||
shadowOffsetX: 10
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'shadowOffsetY',
|
||||
cases: [{
|
||||
name: 'should display shadow blur',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
backgroundColor: 'green',
|
||||
text: 'this is title',
|
||||
shadowColor: 'red',
|
||||
shadowBlur: 5,
|
||||
shadowOffsetY: 10
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'shadowOffsetX and shadowOffsetY',
|
||||
cases: [{
|
||||
name: 'should display shadow blur',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
backgroundColor: 'green',
|
||||
text: 'this is title',
|
||||
shadowColor: 'red',
|
||||
shadowBlur: 5,
|
||||
shadowOffsetX: 10,
|
||||
shadowOffsetY: 10
|
||||
}
|
||||
}
|
||||
}]
|
||||
}];
|
||||
|
||||
uiHelper.testOptionSpec('title', suites);
|
||||
|
||||
});
|
||||
353
vendors/echarts/test/ut/spec/ui/title.subtextStyle.js
vendored
Normal file
353
vendors/echarts/test/ut/spec/ui/title.subtextStyle.js
vendored
Normal file
@@ -0,0 +1,353 @@
|
||||
describe('title.subtextStyle', function() {
|
||||
|
||||
var uiHelper = window.uiHelper;
|
||||
|
||||
var suites = [{
|
||||
name: 'subtextStyle.color',
|
||||
cases: [{
|
||||
name: 'should display expected color name',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'a red subtitle',
|
||||
subtextStyle: {
|
||||
color: 'red'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color 6-digit hex',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'an orange subtitle',
|
||||
subtextStyle: {
|
||||
color: '#ff6600'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color 3-digit hex',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'an orange subtitle',
|
||||
subtextStyle: {
|
||||
color: '#f60'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color rgb',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'an orange subtitle',
|
||||
subtextStyle: {
|
||||
color: 'rgb(255, 127, 0)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color rgba',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'an orange subtitle with alpha',
|
||||
subtextStyle: {
|
||||
color: 'rgba(255, 127, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'subtextStyle.fontStyle',
|
||||
cases: [{
|
||||
name: 'should display normal font style',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display italic font style',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'italic font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'italic'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display oblique font style',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'oblique font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'oblique'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display italic not as normal',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'italic vs. normal',
|
||||
subtextStyle: {
|
||||
fontStyle: 'italic'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'italic vs. normal',
|
||||
subtextStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display oblique not as normal',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'oblique vs. normal',
|
||||
subtextStyle: {
|
||||
fontStyle: 'oblique'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'oblique vs. normal',
|
||||
subtextStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'subtextStyle.fontWeight',
|
||||
cases: [{
|
||||
name: 'should display default normal font weight',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'normal font'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'normal font',
|
||||
subtextStyle: {
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display bold font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'bold font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'bold'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'bold font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display bolder font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'bolder font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'bolder'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'bolder font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display light font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'light font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'light'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'light font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display numbering font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: '100 font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: '100'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: '100 font vs. normal font',
|
||||
subtextStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'subtextStyle.fontFamily',
|
||||
cases: [{
|
||||
name: 'should display default fontFamily as sans-serif',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'sans-serif'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'sans-serif',
|
||||
fontFamily: 'sans-serif'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display default fontFamily as Arial',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'Arial vs. sans-serif',
|
||||
subtextStyle: {
|
||||
fontFamily: 'Arial'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'Arial vs. sans-serif',
|
||||
subtextStyle: {
|
||||
fontFamily: 'sans-serif'
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'textStyle.fontSize',
|
||||
cases: [{
|
||||
name: 'should display default fontSize at 18',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'default font size, should be 18'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'default font size, should be 18',
|
||||
subtextStyle: {
|
||||
fontSize: 18
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display larger fontSize',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'larger font size, 30',
|
||||
subtextStyle: {
|
||||
fontSize: 30
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'larger font size, 30',
|
||||
subtextStyle: {
|
||||
fontSize: 18
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display smaller fontSize',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'smaller font size, 12',
|
||||
subtextStyle: {
|
||||
fontSize: 12
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
subtext: 'smaller font size, 12',
|
||||
subtextStyle: {
|
||||
fontSize: 18
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}];
|
||||
|
||||
uiHelper.testOptionSpec('title.subtextStyle', suites);
|
||||
|
||||
});
|
||||
351
vendors/echarts/test/ut/spec/ui/title.textStyle.js
vendored
Normal file
351
vendors/echarts/test/ut/spec/ui/title.textStyle.js
vendored
Normal file
@@ -0,0 +1,351 @@
|
||||
describe('title.textStyle', function() {
|
||||
|
||||
var uiHelper = window.uiHelper;
|
||||
|
||||
var suites = [{
|
||||
name: 'textStyle.color',
|
||||
cases: [{
|
||||
name: 'should display expected color name',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'a red title',
|
||||
textStyle: {
|
||||
color: 'red'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color 6-digit hex',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'an orange title',
|
||||
textStyle: {
|
||||
color: '#ff6600'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color 3-digit hex',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'an orange title',
|
||||
textStyle: {
|
||||
color: '#f60'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color rgb',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'an orange title',
|
||||
textStyle: {
|
||||
color: 'rgb(255, 127, 0)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display expected color rgba',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'an orange title with alpha',
|
||||
textStyle: {
|
||||
color: 'rgba(255, 127, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'textStyle.fontStyle',
|
||||
cases: [{
|
||||
name: 'should display normal font style',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display italic font style',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'italic font',
|
||||
textStyle: {
|
||||
fontStyle: 'italic'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display oblique font style',
|
||||
option: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'oblique font',
|
||||
textStyle: {
|
||||
fontStyle: 'oblique'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display italic not as normal',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'italic vs. normal',
|
||||
textStyle: {
|
||||
fontStyle: 'italic'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'italic vs. normal',
|
||||
textStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display oblique not as normal',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'oblique vs. normal',
|
||||
textStyle: {
|
||||
fontStyle: 'oblique'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'oblique vs. normal',
|
||||
textStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'textStyle.fontWeight',
|
||||
cases: [{
|
||||
name: 'should display default normal font weight',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'normal font'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'normal font',
|
||||
textStyle: {
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display bold font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'bold font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'bold'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'bold font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display bolder font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'bolder font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'bolder'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'bolder font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display light font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'light font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'light'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'light font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display numbering font weight',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: '100 font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: '100'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: '100 font vs. normal font',
|
||||
textStyle: {
|
||||
fontStyle: 'normal'
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'textStyle.fontFamily',
|
||||
cases: [{
|
||||
name: 'should display default fontFamily as sans-serif',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'sans-serif'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'sans-serif',
|
||||
fontFamily: 'sans-serif'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display default fontFamily as Arial',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'Arial vs. sans-serif',
|
||||
textStyle: {
|
||||
fontFamily: 'Arial'
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'Arial vs. sans-serif',
|
||||
fontFamily: 'sans-serif'
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'textStyle.fontSize',
|
||||
cases: [{
|
||||
name: 'should display default fontSize at 18',
|
||||
test: 'equalOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'default font size, should be 18'
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'default font size, should be 18',
|
||||
textStyle: {
|
||||
fontSize: 18
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display larger fontSize',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'larger font size, 30',
|
||||
textStyle: {
|
||||
fontSize: 30
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'larger font size, 30',
|
||||
textStyle: {
|
||||
fontSize: 18
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'should display smaller fontSize',
|
||||
test: 'notEqualOption',
|
||||
option1: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'smaller font size, 12',
|
||||
textStyle: {
|
||||
fontSize: 12
|
||||
}
|
||||
}
|
||||
},
|
||||
option2: {
|
||||
series: [],
|
||||
title: {
|
||||
text: 'smaller font size, 12',
|
||||
textStyle: {
|
||||
fontSize: 18
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}];
|
||||
|
||||
uiHelper.testOptionSpec('title.textStyle', suites);
|
||||
|
||||
});
|
||||
76
vendors/echarts/test/ut/spec/util/graphic.js
vendored
Normal file
76
vendors/echarts/test/ut/spec/util/graphic.js
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
describe('util/graphic', function() {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
var graphic;
|
||||
|
||||
beforeAll(function (done) { // jshint ignore:line
|
||||
utHelper.resetPackageLoader(function () {
|
||||
window.require(['echarts/util/graphic'], function (g) {
|
||||
graphic = g;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('subPixelOptimize', function () {
|
||||
|
||||
it('subPixelOptimize_base', function (done) {
|
||||
expect(graphic.subPixelOptimize(5, 1)).toEqual(4.5);
|
||||
expect(graphic.subPixelOptimize(5, 2)).toEqual(5);
|
||||
expect(graphic.subPixelOptimize(5, 43)).toEqual(4.5);
|
||||
expect(graphic.subPixelOptimize(7.5, 1)).toEqual(7.5);
|
||||
expect(graphic.subPixelOptimize(7.5, 2)).toEqual(7);
|
||||
expect(graphic.subPixelOptimize(14, 1, true)).toEqual(14.5);
|
||||
expect(graphic.subPixelOptimize(14, 2, true)).toEqual(14);
|
||||
expect(graphic.subPixelOptimize(-11, 1)).toEqual(-11.5);
|
||||
expect(graphic.subPixelOptimize(-11, 2)).toEqual(-11);
|
||||
expect(graphic.subPixelOptimize(0, 2)).toEqual(0);
|
||||
expect(graphic.subPixelOptimize(0, 1)).toEqual(-0.5);
|
||||
expect(graphic.subPixelOptimize(5, 0)).toEqual(5);
|
||||
done();
|
||||
});
|
||||
|
||||
it('subPixelOptimize_line', function (done) {
|
||||
function doSubPixelOptimizeLine(x, y, width, height, lineWidth) {
|
||||
return graphic.subPixelOptimizeLine(makeParam(x, y, width, height, lineWidth));
|
||||
}
|
||||
function makeParam(x1, y1, x2, y2, lineWidth) {
|
||||
return {
|
||||
shape: {x1: x1, y1: y1, x2: x2, y2: y2},
|
||||
style: {lineWidth: lineWidth}
|
||||
};
|
||||
}
|
||||
expect(doSubPixelOptimizeLine(5, 11, 3, 7, 1)).toEqual(makeParam(5, 11, 3, 7, 1));
|
||||
expect(doSubPixelOptimizeLine(5, 11, 5, 7, 1)).toEqual(makeParam(5.5, 11, 5.5, 7, 1));
|
||||
expect(doSubPixelOptimizeLine(5, 11, 5, 7, 2)).toEqual(makeParam(5, 11, 5, 7, 2));
|
||||
expect(doSubPixelOptimizeLine(5, 11, 15, 11, 1)).toEqual(makeParam(5, 11.5, 15, 11.5, 1));
|
||||
expect(doSubPixelOptimizeLine(5, 11, 15, 11, 2)).toEqual(makeParam(5, 11, 15, 11, 2));
|
||||
expect(doSubPixelOptimizeLine(5, 11, 15, 11, 3)).toEqual(makeParam(5, 11.5, 15, 11.5, 3));
|
||||
expect(doSubPixelOptimizeLine(5, 11, 15, 11.5, 3)).toEqual(makeParam(5, 11, 15, 11.5, 3));
|
||||
expect(doSubPixelOptimizeLine(5, 11.5, 15, 11.5, 3)).toEqual(makeParam(5, 11.5, 15, 11.5, 3));
|
||||
expect(doSubPixelOptimizeLine(5, 11.5, 15, 11.5, 4)).toEqual(makeParam(5, 12, 15, 12, 4));
|
||||
done();
|
||||
});
|
||||
|
||||
it('subPixelOptimize_rect', function (done) {
|
||||
function doSubPixelOptimizeRect(x, y, width, height, lineWidth) {
|
||||
return graphic.subPixelOptimizeRect(makeParam(x, y, width, height, lineWidth));
|
||||
}
|
||||
function makeParam(x, y, width, height, lineWidth) {
|
||||
return {
|
||||
shape: {x: x, y: y, width: width, height: height},
|
||||
style: {lineWidth: lineWidth}
|
||||
};
|
||||
}
|
||||
expect(doSubPixelOptimizeRect(5, 11, 3, 7, 1)).toEqual(makeParam(5.5, 11.5, 2, 6, 1));
|
||||
expect(doSubPixelOptimizeRect(5, 11, 3, 7, 2)).toEqual(makeParam(5, 11, 3, 7, 2));
|
||||
expect(doSubPixelOptimizeRect(5, 11, 3, 7, 3)).toEqual(makeParam(5.5, 11.5, 2, 6, 3));
|
||||
// Boundary value tests
|
||||
expect(doSubPixelOptimizeRect(5, 11, 1, 7, 1)).toEqual(makeParam(5.5, 11.5, 1, 6, 1));
|
||||
expect(doSubPixelOptimizeRect(5, 11, 1, 0, 1)).toEqual(makeParam(5.5, 11.5, 1, 0, 1));
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
100
vendors/echarts/test/ut/spec/util/model.js
vendored
Normal file
100
vendors/echarts/test/ut/spec/util/model.js
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
describe('util/model', function() {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
var modelUtil;
|
||||
|
||||
beforeAll(function (done) { // jshint ignore:line
|
||||
utHelper.resetPackageLoader(function () {
|
||||
window.require(['echarts/util/model'], function (h) {
|
||||
modelUtil = h;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function makeRecords(result) {
|
||||
var o = {};
|
||||
modelUtil.eachAxisDim(function (dimNames) {
|
||||
o[dimNames.name] = {};
|
||||
var r = result[dimNames.name] || [];
|
||||
for (var i = 0; i < r.length; i++) {
|
||||
o[dimNames.name][r[i]] = true;
|
||||
}
|
||||
});
|
||||
return o;
|
||||
}
|
||||
|
||||
describe('findLinkedNodes', function () {
|
||||
|
||||
function forEachModel(models, callback) {
|
||||
for (var i = 0; i < models.length; i++) {
|
||||
callback(models[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function axisIndicesGetter(model, dimNames) {
|
||||
return model[dimNames.axisIndex];
|
||||
}
|
||||
|
||||
it('findLinkedNodes_base', function (done) {
|
||||
var models = [
|
||||
{xAxisIndex: [1, 2], yAxisIndex: [0]},
|
||||
{xAxisIndex: [3], yAxisIndex: [1]},
|
||||
{xAxisIndex: [5], yAxisIndex: []},
|
||||
{xAxisIndex: [2, 5], yAxisIndex: []}
|
||||
];
|
||||
var result = modelUtil.createLinkedNodesFinder(
|
||||
utHelper.curry(forEachModel, models),
|
||||
modelUtil.eachAxisDim,
|
||||
axisIndicesGetter
|
||||
)(models[0]);
|
||||
expect(result).toEqual({
|
||||
nodes: [models[0], models[3], models[2]],
|
||||
records: makeRecords({x: [1, 2, 5], y: [0]})
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('findLinkedNodes_crossXY', function (done) {
|
||||
var models = [
|
||||
{xAxisIndex: [1, 2], yAxisIndex: [0]},
|
||||
{xAxisIndex: [3], yAxisIndex: [3, 0]},
|
||||
{xAxisIndex: [6, 3], yAxisIndex: [9]},
|
||||
{xAxisIndex: [5, 3], yAxisIndex: []},
|
||||
{xAxisIndex: [8], yAxisIndex: [4]}
|
||||
];
|
||||
var result = modelUtil.createLinkedNodesFinder(
|
||||
utHelper.curry(forEachModel, models),
|
||||
modelUtil.eachAxisDim,
|
||||
axisIndicesGetter
|
||||
)(models[0]);
|
||||
expect(result).toEqual({
|
||||
nodes: [models[0], models[1], models[2], models[3]],
|
||||
records: makeRecords({x: [1, 2, 3, 5, 6], y: [0, 3, 9]})
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('findLinkedNodes_emptySourceModel', function (done) {
|
||||
var models = [
|
||||
{xAxisIndex: [1, 2], yAxisIndex: [0]},
|
||||
{xAxisIndex: [3], yAxisIndex: [3, 0]},
|
||||
{xAxisIndex: [6, 3], yAxisIndex: [9]},
|
||||
{xAxisIndex: [5, 3], yAxisIndex: []},
|
||||
{xAxisIndex: [8], yAxisIndex: [4]}
|
||||
];
|
||||
var result = modelUtil.createLinkedNodesFinder(
|
||||
utHelper.curry(forEachModel, models),
|
||||
modelUtil.eachAxisDim,
|
||||
axisIndicesGetter
|
||||
)();
|
||||
expect(result).toEqual({
|
||||
nodes: [],
|
||||
records: makeRecords({x: [], y: []})
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
200
vendors/echarts/test/ut/spec/util/number.js
vendored
Normal file
200
vendors/echarts/test/ut/spec/util/number.js
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
describe('util/number', function () {
|
||||
|
||||
var utHelper = window.utHelper;
|
||||
|
||||
var testCase = utHelper.prepare(['echarts/util/number']);
|
||||
|
||||
describe('linearMap', function () {
|
||||
|
||||
testCase('accuracyError', function (numberUtil) {
|
||||
var range = [-15918.3, 17724.9];
|
||||
var result = numberUtil.linearMap(100, [0, 100], range, true);
|
||||
// Should not be 17724.899999999998.
|
||||
expect(result).toEqual(range[1]);
|
||||
|
||||
var range = [-62.83, 83.56];
|
||||
var result = numberUtil.linearMap(100, [0, 100], range, true);
|
||||
// Should not be 83.55999999999999.
|
||||
expect(result).toEqual(range[1]);
|
||||
});
|
||||
|
||||
testCase('clamp', function (numberUtil) {
|
||||
// (1) normal order.
|
||||
var range = [-15918.3, 17724.9];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(100.1, [0, 100], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-2, [0, 100], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [0, 100], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [0, 100], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
|
||||
// (2) inverse range
|
||||
var range = [17724.9, -15918.3];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(102, [0, 100], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-0.001, [0, 100], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [0, 100], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [0, 100], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
|
||||
// (2) inverse domain
|
||||
// bigger than max, inverse domain
|
||||
var range = [-15918.3, 17724.9];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(102, [100, 0], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-0.001, [100, 0], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [100, 0], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [100, 0], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
|
||||
// (3) inverse domain, inverse range
|
||||
var range = [17724.9, -15918.3];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(100.1, [100, 0], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-2, [100, 0], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [100, 0], range, true);
|
||||
expect(result).toEqual(range[0]);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [100, 0], range, true);
|
||||
expect(result).toEqual(range[1]);
|
||||
});
|
||||
|
||||
testCase('noClamp', function (numberUtil) {
|
||||
// (1) normal order.
|
||||
var range = [-15918.3, 17724.9];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(100.1, [0, 100], range, false);
|
||||
expect(result).toEqual(17758.543199999996);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-2, [0, 100], range, false);
|
||||
expect(result).toEqual(-16591.164);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [0, 100], range, false);
|
||||
expect(result).toEqual(17724.9);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [0, 100], range, false);
|
||||
expect(result).toEqual(-15918.3);
|
||||
|
||||
// (2) inverse range
|
||||
var range = [17724.9, -15918.3];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(102, [0, 100], range, false);
|
||||
expect(result).toEqual(-16591.163999999997);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-0.001, [0, 100], range, false);
|
||||
expect(result).toEqual(17725.236432);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [0, 100], range, false);
|
||||
expect(result).toEqual(-15918.3);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [0, 100], range, false);
|
||||
expect(result).toEqual(17724.9);
|
||||
|
||||
// (2) inverse domain
|
||||
// bigger than max, inverse domain
|
||||
var range = [-15918.3, 17724.9];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(102, [100, 0], range, false);
|
||||
expect(result).toEqual(-16591.164);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-0.001, [100, 0], range, false);
|
||||
expect(result).toEqual(17725.236432);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [100, 0], range, false);
|
||||
expect(result).toEqual(-15918.3);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [100, 0], range, false);
|
||||
expect(result).toEqual(17724.9);
|
||||
|
||||
// (3) inverse domain, inverse range
|
||||
var range = [17724.9, -15918.3];
|
||||
// bigger than max
|
||||
var result = numberUtil.linearMap(100.1, [100, 0], range, false);
|
||||
expect(result).toEqual(17758.5432);
|
||||
// smaller than min
|
||||
var result = numberUtil.linearMap(-2, [100, 0], range, false);
|
||||
expect(result).toEqual(-16591.163999999997);
|
||||
// equals to max
|
||||
var result = numberUtil.linearMap(100, [100, 0], range, false);
|
||||
expect(result).toEqual(17724.9);
|
||||
// equals to min
|
||||
var result = numberUtil.linearMap(0, [100, 0], range, false);
|
||||
expect(result).toEqual(-15918.3);
|
||||
});
|
||||
|
||||
testCase('normal', function (numberUtil) {
|
||||
|
||||
doTest(true);
|
||||
doTest(false);
|
||||
|
||||
function doTest(clamp) {
|
||||
// normal
|
||||
var range = [444, 555];
|
||||
var result = numberUtil.linearMap(40, [0, 100], range, clamp);
|
||||
expect(result).toEqual(488.4);
|
||||
|
||||
// inverse range
|
||||
var range = [555, 444];
|
||||
var result = numberUtil.linearMap(40, [0, 100], range, clamp);
|
||||
expect(result).toEqual(510.6);
|
||||
|
||||
// inverse domain and range
|
||||
var range = [555, 444];
|
||||
var result = numberUtil.linearMap(40, [100, 0], range, clamp);
|
||||
expect(result).toEqual(488.4);
|
||||
|
||||
// inverse domain
|
||||
var range = [444, 555];
|
||||
var result = numberUtil.linearMap(40, [100, 0], range, clamp);
|
||||
expect(result).toEqual(510.6);
|
||||
}
|
||||
});
|
||||
|
||||
testCase('zeroInterval', function (numberUtil) {
|
||||
|
||||
doTest(true);
|
||||
doTest(false);
|
||||
|
||||
function doTest(clamp) {
|
||||
// zero domain interval
|
||||
var range = [444, 555];
|
||||
var result = numberUtil.linearMap(40, [1212222223.2323232, 1212222223.2323232], range, clamp);
|
||||
expect(result).toEqual(499.5); // half of range.
|
||||
|
||||
// zero range interval
|
||||
var range = [1221212.1221372238, 1221212.1221372238];
|
||||
var result = numberUtil.linearMap(40, [0, 100], range, clamp);
|
||||
expect(result).toEqual(1221212.1221372238);
|
||||
|
||||
// zero domain interval and range interval
|
||||
var range = [1221212.1221372238, 1221212.1221372238];
|
||||
var result = numberUtil.linearMap(40, [43.55454545, 43.55454545], range, clamp);
|
||||
expect(result).toEqual(1221212.1221372238);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
43
vendors/echarts/test/ut/ui.html
vendored
Normal file
43
vendors/echarts/test/ut/ui.html
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Jasmine Spec Runner v2.3.4</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.3.4/jasmine_favicon.png">
|
||||
<link rel="stylesheet" href="lib/jasmine-2.3.4/jasmine.css">
|
||||
|
||||
<style type="text/css">
|
||||
#failed-panel {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#failed-panel img {
|
||||
width: 33.3%;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="lib/jasmine-2.3.4/jasmine.js"></script>
|
||||
<script src="lib/jasmine-2.3.4/jasmine-html.js"></script>
|
||||
<script src="lib/jasmine-2.3.4/boot.js"></script>
|
||||
|
||||
<script src="lib/canteen.js"></script>
|
||||
<script src="lib/imagediff.js"></script>
|
||||
|
||||
<script src="../esl.js"></script>
|
||||
<script src="spec/ui/config.js"></script>
|
||||
<script src="core/uiHelper.js"></script>
|
||||
|
||||
<!-- <script src="spec/ui/title.js"></script>
|
||||
<script src="spec/ui/title.subtextStyle.js"></script>
|
||||
<script src="spec/ui/title.textStyle.js"></script> -->
|
||||
|
||||
<script src="spec/ui/legend.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
19
vendors/echarts/test/ut/ut.html
vendored
Normal file
19
vendors/echarts/test/ut/ut.html
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Jasmine Spec Runner v2.3.4</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.3.4/jasmine_favicon.png">
|
||||
<link rel="stylesheet" href="lib/jasmine-2.3.4/jasmine.css">
|
||||
|
||||
<script src="lib/jasmine-2.3.4/jasmine.js"></script>
|
||||
<script src="lib/jasmine-2.3.4/jasmine-html.js"></script>
|
||||
<script src="lib/jasmine-2.3.4/boot.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="ut.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
13
vendors/echarts/test/ut/ut.js
vendored
Normal file
13
vendors/echarts/test/ut/ut.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
document.write('<script src="core/utHelper.js"><\/script>');
|
||||
|
||||
// Specs ...
|
||||
document.write('<script src="spec/util/graphic.js"><\/script>');
|
||||
document.write('<script src="spec/util/model.js"><\/script>');
|
||||
document.write('<script src="spec/util/number.js"><\/script>');
|
||||
document.write('<script src="spec/model/Component.js"><\/script>');
|
||||
document.write('<script src="spec/model/Global.js"><\/script>');
|
||||
document.write('<script src="spec/model/timelineOptions.js"><\/script>');
|
||||
|
||||
document.write('<script src="spec/data/List.js"><\/script>');
|
||||
|
||||
document.write('<script src="spec/component/visualMap/setOption.js"><\/script>');
|
||||
Reference in New Issue
Block a user