Skip to content

Commit

Permalink
Merge pull request #8472 from colin-marshall/babel-tests
Browse files Browse the repository at this point in the history
ES6/Babel in JS unit tests
  • Loading branch information
colin-marshall committed Mar 28, 2016
2 parents 207a1b3 + a789e52 commit c42fa9d
Show file tree
Hide file tree
Showing 25 changed files with 405 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -47,6 +47,7 @@ test/tmp
test/version_tmp
tmp
testing/_build
test/javascript/js-tests.js

pizza/
data.json
Expand Down
16 changes: 16 additions & 0 deletions gulp/babel-error.js
@@ -0,0 +1,16 @@
var chalk = require('chalk');

module.exports = function(err) {
console.log(
chalk.red(
err.fileName +
(
err.loc ?
'(' + err.loc.line + ',' + err.loc.column + '): ' :
': '
)
) +
'error Babel: ' + err.message + '\n' +
err.codeFrame
);
}
17 changes: 1 addition & 16 deletions gulp/javascript.js
@@ -1,7 +1,7 @@
var gulp = require('gulp');
var chalk = require('chalk');
var concat = require('gulp-concat');
var babel = require('gulp-babel');
var onBabelError = require('./babel-error.js');

var FOUNDATION = [
'js/foundation.core.js',
Expand Down Expand Up @@ -46,18 +46,3 @@ gulp.task('javascript:docs', function() {
.pipe(concat('docs.js'))
.pipe(gulp.dest('_build/assets/js'));
});

function onBabelError(err) {
console.log(
chalk.red(
err.fileName +
(
err.loc ?
'(' + err.loc.line + ',' + err.loc.column + '): ' :
': '
)
) +
'error Babel: ' + err.message + '\n' +
err.codeFrame
);
}
21 changes: 20 additions & 1 deletion gulp/test.js
Expand Up @@ -2,9 +2,18 @@ var gulp = require('gulp');
var opener = require('opener');
var mocha = require('gulp-mocha');
var browser = require('browser-sync');
var concat = require('gulp-concat');
var babel = require('gulp-babel');
var onBabelError = require('./babel-error.js');
var rimraf = require('rimraf').sync;

var JSTESTS = [
'test/javascript/components/**/*.js',
'test/javascript/util/**/*.js'
];

// Runs unit tests
gulp.task('test', ['sass:foundation', 'javascript:foundation', 'watch'], function() {
gulp.task('test', ['sass:foundation', 'test:transpile-js', 'watch'], function() {
browser.init({
server: 'test/visual',
directory: true
Expand All @@ -16,3 +25,13 @@ gulp.task('test:reload', function(done) {
browser.reload();
done();
});

gulp.task('test:transpile-js', ['javascript:foundation'], function() {
rimraf('test/javascript/js-tests.js');

return gulp.src(JSTESTS)
.pipe(babel()
.on('error', onBabelError))
.pipe(concat('js-tests.js'))
.pipe(gulp.dest('test/javascript'));
});
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
"start": "gulp",
"test": "npm run test:sass && npm run test:javascript",
"test:sass": "mocha test/sass/test_sass.js",
"test:javascript": "gulp sass:foundation && gulp javascript:foundation && mocha-phantomjs test/javascript/index.html",
"test:javascript": "gulp sass:foundation && gulp test:transpile-js && mocha-phantomjs test/javascript/index.html",
"test:visual": "gulp test",
"deploy": "gulp deploy",
"deploy:docs": "gulp deploy:docs"
Expand Down
20 changes: 20 additions & 0 deletions test/javascript/components/abide.js
@@ -0,0 +1,20 @@
describe('Abide', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Abide($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/accordion.js
@@ -0,0 +1,20 @@
describe('Accordion', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Accordion($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/accordionMenu.js
@@ -0,0 +1,20 @@
describe('Accordion Menu', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.AccordionMenu($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/drilldown.js
@@ -0,0 +1,20 @@
describe('Drilldown Menu', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Drilldown($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/dropdown.js
@@ -0,0 +1,20 @@
describe('Dropdown', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Dropdown($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/dropdownMenu.js
@@ -0,0 +1,20 @@
describe('Dropdown Menu', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.DropdownMenu($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/equalizer.js
@@ -0,0 +1,20 @@
describe('Equalizer', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Equalizer($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/interchange.js
@@ -0,0 +1,20 @@
describe('Interchange', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Interchange($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/magellan.js
@@ -0,0 +1,20 @@
describe('Magellan', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Magellan($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/offcanvas.js
@@ -0,0 +1,20 @@
describe('Off Canvas', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.OffCanvas($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/orbit.js
@@ -0,0 +1,20 @@
describe('Orbit', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.Orbit($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/responsiveMenu.js
@@ -0,0 +1,20 @@
describe('Responsive Menu', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.ResponsiveMenu($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});
20 changes: 20 additions & 0 deletions test/javascript/components/responsiveToggle.js
@@ -0,0 +1,20 @@
describe('Responsive Toggle', function() {
var plugin;
var $html;

// afterEach(function() {
// plugin.destroy();
// $html.remove();
// });

describe('constructor()', function() {
// it('', function() {
// $html = $('').appendTo('body');
// plugin = new Foundation.ResponsiveToggle($html, {});

// plugin.$element.should.be.an('object');
// plugin.options.should.be.an('object');
// });
});

});

0 comments on commit c42fa9d

Please sign in to comment.