Skip to content

Commit

Permalink
test(all): make tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
martingust committed Aug 22, 2016
1 parent 7604759 commit 3f87c1b
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 15 deletions.
13 changes: 11 additions & 2 deletions build/babel-options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var path = require('path');
var paths = require('./paths');

exports.base = function() {
exports.base = function(isTest) {
var config = {
filename: '',
filenameRelative: '',
Expand All @@ -18,7 +18,7 @@ exports.base = function() {
'transform-decorators-legacy',
]
};
if (!paths.useTypeScriptForDTS) {
if (!paths.useTypeScriptForDTS && !isTest) {
config.plugins.push(
['babel-dts-generator', {
packageName: paths.packageName,
Expand Down Expand Up @@ -63,3 +63,12 @@ exports['native-modules'] = function() {
options.presets[0] = 'es2015-loose-native-modules';
return options;
}

exports.test = function() {
var baseOptions = exports.base(true);
var options = {
presets: baseOptions.presets,
plugins: baseOptions.plugins
};
return options;
}
4 changes: 3 additions & 1 deletion build/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = {
doc:'./doc',
e2eSpecsSrc: 'test/e2e/src/*.js',
e2eSpecsDist: 'test/e2e/dist/',
packageName: pkg.name
packageName: pkg.name,
specsSrc: 'test/**/*.spec.js'
};var path = require('path');
var fs = require('fs');

Expand All @@ -34,6 +35,7 @@ var paths = {
e2eSpecsSrc: 'test/e2e/src/*.js',
e2eSpecsDist: 'test/e2e/dist/',
packageName: pkg.name,
specsSrc: 'test/**/*.spec.js',
ignore: [],
useTypeScriptForDTS: false,
importsToAdd: [],
Expand Down
14 changes: 10 additions & 4 deletions build/tasks/test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
require("babel-register")(require('../babel-options').test());
var gulp = require('gulp');
var jasmine = require('gulp-jasmine');
var paths = require('../paths');

/**
* Run test once and exit
*/
gulp.task('test', function (done) {
// TODO
gulp.task('test', () => {
gulp.src([paths.source, paths.specsSrc])
.pipe(jasmine({
includeStackTrace: true
}));
});

/**
* Watch for file changes and re-run tests on each change
*/
gulp.task('tdd', function (done) {
gulp.task('tdd', () => {
// TODO
});

/**
* Run test once with code coverage and exit
*/
gulp.task('cover', function (done) {
gulp.task('cover', () => {
// TODO
});

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-es2015-loose-native-modules": "^1.0.0",
"babel-preset-stage-1": "^6.5.0",
"babel-register": "^6.11.6",
"del": "^2.2.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/nodejs-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class NodeJsDom implements IDom {
mutationEmulator: NodeJsMutationEmulator;

constructor(global: IGlobal) {

this.global = global;
this.Element = global.Element;
this.SVGElement = global.SVGElement;
this.mutationEmulator = new NodeJsMutationEmulator();
Expand Down
5 changes: 3 additions & 2 deletions src/nodejs-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {IGlobal} from './global';

export class NodeJsFeature implements IFeature{
constructor(global: IGlobal){
this.shadowDOM = (this.global.window).HTMLElement.prototype.attachShadow != undefined;
this.scopedCSS = 'scoped' in this.global.document.createElement('style');
this.gloabl = global;
this.shadowDOM = (global.window).HTMLElement.prototype.attachShadow != undefined;
this.scopedCSS = 'scoped' in global.document.createElement('style');
this.htmlTemplateElement = true;
this.mutationObserver = true; // partial
}
Expand Down
2 changes: 1 addition & 1 deletion src/nodejs-mutation-emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class NodeJsMutationEmulator {

let old = attrOld.item(i);

if (!this.findAttr(attrNew, old.name)) {
if (!this._findAttr(attrNew, old.name)) {
let mutation = {
target: target,
type: "attributes",
Expand Down
9 changes: 5 additions & 4 deletions src/nodejs-platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {IGlobal} from './global';
export class NodeJsPlatform implements IPlatform {

constructor(global: IGlobal) {
this.performance = this.global.performance;
this.location = this.global.location;
this.history = this.global.history;
this.XMLHttpRequest = this.global.XMLHttpRequest;
this.global = global;
this.performance = global.performance;
this.location = global.location;
this.history = global.history;
this.XMLHttpRequest = global.XMLHttpRequest;
}

/**
Expand Down

0 comments on commit 3f87c1b

Please sign in to comment.