mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
parent
9a734a36b9
commit
4bb1ffb9e6
6 changed files with 4 additions and 134 deletions
|
|
@ -45,15 +45,14 @@
|
|||
"build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export",
|
||||
"build_with_gestures": "node build.js modules=ALL exclude=accessors",
|
||||
"build_export": "npm run build:fast && npm run export_dist_to_site",
|
||||
"test": "node test.js",
|
||||
"test:visual": "node test-visual.js",
|
||||
"test": "istanbul cover ./node_modules/qunit/bin/qunit test/node_test_setup.js test/lib test/unit",
|
||||
"test:visual": "./node_modules/qunit/bin/qunit test/node_test_setup.js test/lib test/visual",
|
||||
"test:all": "npm run test && npm run test:visual",
|
||||
"lint": "eslint --config .eslintrc.json src",
|
||||
"lint_tests": "eslint test/unit --config .eslintrc_tests",
|
||||
"export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/",
|
||||
"export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit",
|
||||
"all": "npm run build && npm run test && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site",
|
||||
"test:node": "./node_modules/qunit/bin/qunit test/node_test_setup.js test/lib test/unit",
|
||||
"testem": "testem .",
|
||||
"testem:ci": "testem ci"
|
||||
},
|
||||
|
|
@ -65,7 +64,6 @@
|
|||
"devDependencies": {
|
||||
"eslint": "4.18.x",
|
||||
"istanbul": "0.4.x",
|
||||
"node-qunit": "^1.0.0",
|
||||
"onchange": "^3.x.x",
|
||||
"qunit": "^2.4.1",
|
||||
"testem": "^1.18.4",
|
||||
|
|
|
|||
64
test.js
64
test.js
|
|
@ -1,64 +0,0 @@
|
|||
var testrunner = require('node-qunit');
|
||||
|
||||
testrunner.options.log.summary = true;
|
||||
testrunner.options.log.tests = false;
|
||||
testrunner.options.log.assertions = false;
|
||||
testrunner.options.log.coverage = true;
|
||||
|
||||
testrunner.options.coverage = true;
|
||||
testrunner.options.maxBlockDuration = 120000;
|
||||
|
||||
testrunner.run({
|
||||
deps: './test/fixtures/test_script.js',
|
||||
code: './dist/fabric.js',
|
||||
tests: [
|
||||
'./test/unit/activeselection.js',
|
||||
'./test/unit/animation.js',
|
||||
'./test/unit/rect.js',
|
||||
'./test/unit/ellipse.js',
|
||||
'./test/unit/color.js',
|
||||
'./test/unit/circle.js',
|
||||
'./test/unit/line.js',
|
||||
'./test/unit/polyline.js',
|
||||
'./test/unit/polygon.js',
|
||||
'./test/unit/path.js',
|
||||
'./test/unit/observable.js',
|
||||
'./test/unit/object.js',
|
||||
'./test/unit/text.js',
|
||||
'./test/unit/util.js',
|
||||
'./test/unit/brushes.js',
|
||||
'./test/unit/image.js',
|
||||
'./test/unit/image_filters.js',
|
||||
'./test/unit/group.js',
|
||||
'./test/unit/parser.js',
|
||||
'./test/unit/canvas.js',
|
||||
'./test/unit/canvas_static.js',
|
||||
'./test/unit/gradient.js',
|
||||
'./test/unit/pattern.js',
|
||||
'./test/unit/shadow.js',
|
||||
'./test/unit/object_interactivity.js',
|
||||
'./test/unit/object_geometry.js',
|
||||
'./test/unit/object_origin.js',
|
||||
'./test/unit/itext.js',
|
||||
'./test/unit/itext_click_behaviour.js',
|
||||
'./test/unit/itext_key_behaviour.js',
|
||||
'./test/unit/collection.js',
|
||||
'./test/unit/point.js',
|
||||
'./test/unit/intersection.js',
|
||||
'./test/unit/stateful.js',
|
||||
'./test/unit/textbox.js',
|
||||
'./test/unit/canvas_events.js',
|
||||
'./test/unit/text_to_svg.js',
|
||||
],
|
||||
// tests: ['./test/unit/text.js',],
|
||||
}, function(err, report) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
}
|
||||
if(report.failed > 0){
|
||||
process.on('exit', function() {
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
});
|
||||
4
test/fixtures/test_script.js
vendored
4
test/fixtures/test_script.js
vendored
|
|
@ -1,4 +0,0 @@
|
|||
var pixelmatch = require('pixelmatch');
|
||||
var fs = require('fs');
|
||||
global.pixelmatch = pixelmatch;
|
||||
global.fs = fs;
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
(function(){
|
||||
/**
|
||||
* @private
|
||||
* @param {CanvasRenderingContext2D} ctx context to test
|
||||
* @param {Function} fn Callback, invoked with `currentValue`, `previousValue` and `index`.
|
||||
* Breaks out of the loop if callback returns `false`.
|
||||
*/
|
||||
function iterateData(ctx, fn) {
|
||||
var data = ctx.getImageData(0, 0, ctx.canvas.width, ctx.canvas.height).data;
|
||||
for (var i = data.length; i--; ) {
|
||||
if (i > 4) {
|
||||
if (fn(data[i], data[i - 4], i) === false) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} ctx context to test
|
||||
* @param {String} color color in a hex value
|
||||
* @return {Boolean | null} `true` if all canvas pixels are of a given color, `null` if wrong color is given
|
||||
* @example `assertColor(canvas._oContextContainer, 'ff5555');`
|
||||
*/
|
||||
function assertColor(ctx, color) {
|
||||
var match, r, g, b;
|
||||
if (match = String(color).match(/^#?([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i)) {
|
||||
r = parseInt(match[1], 16);
|
||||
g = parseInt(match[2], 16);
|
||||
b = parseInt(match[3], 16);
|
||||
}
|
||||
else return null;
|
||||
var result = true;
|
||||
iterateData(ctx, function(currentValue, prevValue, i) {
|
||||
if ((!(i % 4) && (currentValue !== r)) ||
|
||||
(!((i-1) % 4) && (currentValue !== g)) ||
|
||||
(!((i-2) % 4) && (currentValue !== b))) {
|
||||
return (result = false);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} ctx context to test
|
||||
* @return {Boolean} `true` if all canvas pixels are of the same color
|
||||
* @example `assertSameColor(canvas._oContextContainer);`
|
||||
*/
|
||||
function assertSameColor(ctx) {
|
||||
debugger;
|
||||
var result = true;
|
||||
iterateData(ctx, function(currentValue, prevValue, i) {
|
||||
if (currentValue !== prevValue) {
|
||||
return (result = false);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// export as global
|
||||
this.assertColor = assertColor;
|
||||
this.assertSameColor = assertSameColor;
|
||||
})();
|
||||
|
|
@ -5,3 +5,4 @@ global.fs = require('fs');
|
|||
|
||||
QUnit.config.testTimeout = 10000;
|
||||
QUnit.config.noglobals = true;
|
||||
QUnit.config.hidePassed = true;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
],
|
||||
"launchers": {
|
||||
"Node": {
|
||||
"command": "npm run test:node",
|
||||
"command": "npm run test",
|
||||
"protocol": "tap"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue