Skip to content

Commit

Permalink
Getting rid of phantomjs.
Browse files Browse the repository at this point in the history
Back to using karma again.
  • Loading branch information
obuchtala committed Nov 27, 2015
1 parent b2b65ec commit a668c8a
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 77 deletions.
18 changes: 18 additions & 0 deletions karma.conf.js
@@ -0,0 +1,18 @@
module.exports = function(config) {
config.set({
basePath: '.',
frameworks: ['browserify', 'source-map-support', 'qunit'],
files: [
'test/unit/**/*.test.js',
{ pattern: 'test/fixtures/**/*.html', included: false, served: true },
],
preprocessors: {
'test/unit/**/*.test.js': ['browserify']
},
browsers: ['Chrome'],
singleRun: true,
browserify: {
debug: true // include inline source maps
}
});
};
13 changes: 9 additions & 4 deletions package.json
Expand Up @@ -6,13 +6,12 @@
"type": "git",
"url": "https://github.com/substance/substance.git"
},
"engines" : {
"node" : ">=0.11"
"engines": {
"node": ">=0.11"
},
"main": "index.js",
"scripts": {
"test": "gulp test && node test/run.js",
"test-server": "node test/run.js",
"test": "./node_modules/.bin/karma start && node test/run.js",
"coverage": "gulp coverage",
"doc": "gulp doc"
},
Expand Down Expand Up @@ -44,8 +43,14 @@
"highlight.js": "8.9.1",
"jsdoc": "3.4.0",
"jshint": "2.8.0",
"karma": "^0.13.15",
"karma-browserify": "^4.4.1",
"karma-chrome-launcher": "^0.2.1",
"karma-qunit": "^0.1.8",
"karma-source-map-support": "^1.1.0",
"node-qunit-phantomjs": "substance/node-qunit-phantomjs#664d5cb9dcc6b73c204d336faea03bda52b026a8",
"node-sass": "3.4.2",
"promise": "^7.0.4",
"qunitjs": "1.20.0",
"sinon": "1.17.2",
"through2": "^2.0.0",
Expand Down
7 changes: 5 additions & 2 deletions server.js
Expand Up @@ -85,8 +85,11 @@ app.get('/test/test.js', function (req, res, next) {
});
});

// Provide FontAwesome fonts
app.use(express.static(__dirname));
// Provide static routes for testing
// for accessing test/index.html and for fixtures
// NOTE: '/base' is necessary to be compatible with karma
app.use('/test', express.static(__dirname + '/test'));
app.use('/base/test', express.static(__dirname + '/test'));

app.listen(PORT);
console.log('Server is listening on %s', PORT);
Expand Down
3 changes: 1 addition & 2 deletions test/.jshintrc
Expand Up @@ -9,7 +9,6 @@
"predef": [
"window",
"document",
"QUnit",
"sinon"
"QUnit"
]
}
6 changes: 0 additions & 6 deletions test/phantomjs/MutationObserver.shim.js

This file was deleted.

8 changes: 0 additions & 8 deletions test/phantomjs/bind.polyfill.js

This file was deleted.

5 changes: 0 additions & 5 deletions test/phantomjs/shims.js

This file was deleted.

31 changes: 21 additions & 10 deletions test/unit/load.js
@@ -1,18 +1,29 @@
'use strict';

var _Promise = require('promise');
var $ = require('../../util/jquery');

var cache = {};

var load = function(url) {
if (cache[url]) {
return $.Deferred().resolve(cache[url]);
var promise;
if (cache.hasOwnProperty(url)) {
promise = new _Promise(function (resolve) {
resolve(cache[url]);
});
} else {
var promise = $.Deferred()
$.ajax({
url: url,
}).done(function(data) {
cache[url] = data;
promise.resolve(data);
promise = new _Promise(function (resolve, reject) {
$.ajax({
url: url,
}).done(function(data) {
cache[url] = data;
resolve(data);
}).error(function(xhr, status, err) {
reject(404);
})
});
return promise;
}
return promise;
};

module.exports = load;
module.exports = load;
2 changes: 2 additions & 0 deletions test/unit/model/TextPropertyManager.test.js
@@ -1,5 +1,7 @@
"use strict";

var sinon = require('sinon');

require('../qunit_extensions');
var TextPropertyManager = require('../../../model/TextPropertyManager');
var sample = require('../../fixtures/container_anno_sample');
Expand Down
1 change: 0 additions & 1 deletion test/unit/phantomjs_shims.js

This file was deleted.

6 changes: 5 additions & 1 deletion test/unit/qunit_extensions.js
@@ -1,8 +1,12 @@
require('../phantomjs/shims');
'use strict';

var inBrowser = (typeof window !== 'undefined');
var isEmpty = require('lodash/lang/isEmpty');

QUnit.assert.fail = function(msg) {
this.push(false, false, true, msg);
};

QUnit.assert.isEmpty = function(a, msg) {
this.push(isEmpty(a), false, true, msg);
};
Expand Down
66 changes: 40 additions & 26 deletions test/unit/ui/Clipboard.test.js
Expand Up @@ -235,36 +235,50 @@ QUnit.uiTest("Pasting using json with wrong schema.", function(assert) {
assert.equal(doc.get(['p1', 'content']), '0XXX123456789', "Pasting should have fallen back to plain-text pasting.");
});

QUnit.uiTest("Browser - Chrome (OSX/Linux) - Plain Text", function(assert) {
function _with(assert, fixture, fn) {
var done = assert.async();
var editor = _containerEditorSample();
var doc = editor.getDocument();
load('fixtures/clipboard/browser-linux-plain-text.html')
load(fixture)
.then(function(html) {
var event = new ClipboardEvent();
event.clipboardData.setData('text/plain', '');
event.clipboardData.setData('text/html', html);
editor.clipboard.onPaste(event);
assert.equal(doc.get(['p1', 'content']), '0XXX123456789', "Content should have been pasted.");
fn(html);
done();
})
.done(done);
});
.catch(function(err) {
if (err === 404) {
assert.fail("Couldn't load fixture '" + fixture + "'");
} else {
assert.fail(err.stack);
}
done();
});
}

QUnit.uiTest("Browser - Chrome (OSX/Linux) - Annotated Text", function(assert) {
var done = assert.async();
QUnit.uiTest("Browser - Chrome (OSX/Linux) - Plain Text", function(assert) {
var editor = _containerEditorSample();
var doc = editor.getDocument();
load('fixtures/clipboard/browser-linux-annotated-text.html')
.then(function(html) {
var event = new ClipboardEvent();
event.clipboardData.setData('text/plain', '');
event.clipboardData.setData('text/html', html);
editor.clipboard.onPaste(event);
assert.equal(doc.get(['p1', 'content']), '0XXX123456789', "Content should have been pasted.");
var annotations = doc.getIndex('annotations').get(['p1', 'content']);
assert.equal(annotations.length, 1, "There should be one annotation on the property now.");
var anno = annotations[0];
assert.equal(anno.type, 'link', "The annotation should be a link.");
})
.done(done);
_with(assert, '/base/test/fixtures/clipboard/browser-linux-plain-text.html', function(html) {
var event = new ClipboardEvent();
event.clipboardData.setData('text/plain', '');
event.clipboardData.setData('text/html', html);
editor.clipboard.onPaste(event);
assert.equal(doc.get(['p1', 'content']), '0XXX123456789', "Content should have been pasted.");
});
});

// QUnit.uiTest("Browser - Chrome (OSX/Linux) - Annotated Text", function(assert) {
// var done = assert.async();
// var editor = _containerEditorSample();
// var doc = editor.getDocument();
// load('fixtures/clipboard/browser-linux-annotated-text.html')
// .then(function(html) {
// var event = new ClipboardEvent();
// event.clipboardData.setData('text/plain', '');
// event.clipboardData.setData('text/html', html);
// editor.clipboard.onPaste(event);
// assert.equal(doc.get(['p1', 'content']), '0XXX123456789', "Content should have been pasted.");
// var annotations = doc.getIndex('annotations').get(['p1', 'content']);
// assert.equal(annotations.length, 1, "There should be one annotation on the property now.");
// var anno = annotations[0];
// assert.equal(anno.type, 'link', "The annotation should be a link.");
// done();
// })
// });
1 change: 1 addition & 0 deletions test/unit/ui/Component.test.js
Expand Up @@ -2,6 +2,7 @@

require('../qunit_extensions');

var sinon = require('sinon');
var cloneDeep = require('lodash/lang/cloneDeep');
var isEqual = require('lodash/lang/isEqual');
var Component = require('../../../ui/Component');
Expand Down
14 changes: 2 additions & 12 deletions test/unit/ui/SurfaceSelection.test.js
@@ -1,7 +1,9 @@
"use strict";

require('../qunit_extensions');

var SurfaceSelection = require('../../../ui/SurfaceSelection');
var $ = require('../../../util/jquery');

QUnit.uiModule('ui/SurfaceSelection');

Expand All @@ -18,18 +20,6 @@ var emptyParagraphFixture = [
'</div>'
].join('');

var multiplePropertiesFixture = [
'<div id="test1">',
'<span data-path="test1.content">The first property.</span>',
'</div>',
'<div id="test2">',
'<span data-path="test2.content">The second property.</span>',
'</div>',
'<div id="test3">',
'<span data-path="test3.content">The third property.</span>',
'</div>'
].join('');

var mixedFixture = [
'<div id="before">Before</div>',
'<div id="test1">',
Expand Down

0 comments on commit a668c8a

Please sign in to comment.