From eec42569d06e7d8af3c8b8e5ad43cb6149804dd9 Mon Sep 17 00:00:00 2001 From: Colin Marshall Date: Sat, 26 Mar 2016 18:43:03 -0600 Subject: [PATCH 1/6] Added ES6/babel to JS tests, exported babel reporting --- gulp/babel-error.js | 16 ++++++++++++++++ gulp/javascript.js | 17 +---------------- gulp/test.js | 18 +++++++++++++++++- package.json | 2 +- 4 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 gulp/babel-error.js diff --git a/gulp/babel-error.js b/gulp/babel-error.js new file mode 100644 index 0000000000..9e0a3f0f91 --- /dev/null +++ b/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 + ); +} \ No newline at end of file diff --git a/gulp/javascript.js b/gulp/javascript.js index f350f0a2f9..fbbd9403ca 100644 --- a/gulp/javascript.js +++ b/gulp/javascript.js @@ -2,6 +2,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', @@ -30,7 +31,6 @@ gulp.task('javascript:foundation', function() { return gulp.src(FOUNDATION) .pipe(babel() .on('error', onBabelError)) - .pipe(gulp.dest('_build/assets/js/plugins')) .pipe(concat('foundation.js')) .pipe(gulp.dest('_build/assets/js')); }); @@ -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 - ); -} diff --git a/gulp/test.js b/gulp/test.js index 10ce500c93..4b67dd6a04 100644 --- a/gulp/test.js +++ b/gulp/test.js @@ -2,9 +2,17 @@ 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 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 @@ -16,3 +24,11 @@ gulp.task('test:reload', function(done) { browser.reload(); done(); }); + +gulp.task('test:transpile-js', ['javascript:foundation'], function() { + return gulp.src(JSTESTS) + .pipe(babel() + .on('error', onBabelError)) + .pipe(concat('js-tests.js')) + .pipe(gulp.dest('test/javascript')); +}); diff --git a/package.json b/package.json index 2c92e16ad4..46a8a1750c 100644 --- a/package.json +++ b/package.json @@ -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" From c55e768dbcb93f3946e422611f8ee597389c61d2 Mon Sep 17 00:00:00 2001 From: Colin Marshall Date: Sat, 26 Mar 2016 19:05:00 -0600 Subject: [PATCH 2/6] Added transpiled js tests file to gitignore --- .gitignore | 1 + gulp/javascript.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6a26f24557..3d341f5c10 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ test/tmp test/version_tmp tmp testing/_build +test/javascript/js-tests.js pizza/ data.json diff --git a/gulp/javascript.js b/gulp/javascript.js index fbbd9403ca..51e0891554 100644 --- a/gulp/javascript.js +++ b/gulp/javascript.js @@ -1,5 +1,4 @@ var gulp = require('gulp'); -var chalk = require('chalk'); var concat = require('gulp-concat'); var babel = require('gulp-babel'); var onBabelError = require('./babel-error.js'); @@ -31,6 +30,7 @@ gulp.task('javascript:foundation', function() { return gulp.src(FOUNDATION) .pipe(babel() .on('error', onBabelError)) + .pipe(gulp.dest('_build/assets/js/plugins')) .pipe(concat('foundation.js')) .pipe(gulp.dest('_build/assets/js')); }); From a68e1c493ebd51c1d94b32838dfe5773a65dae3f Mon Sep 17 00:00:00 2001 From: Colin Marshall Date: Sun, 27 Mar 2016 16:38:59 -0600 Subject: [PATCH 3/6] Link concatenated js unit tests in index.html --- test/javascript/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/javascript/index.html b/test/javascript/index.html index 77a1975d6d..0c6e7fded7 100644 --- a/test/javascript/index.html +++ b/test/javascript/index.html @@ -20,8 +20,7 @@ mocha.setup('bdd'); chai.should(); - - + From a7de5b0d4cd1787c2f507467a0433cf5902980de Mon Sep 17 00:00:00 2001 From: Colin Marshall Date: Sun, 27 Mar 2016 16:39:43 -0600 Subject: [PATCH 4/6] Added clean step prior to transpiling js unit tests --- gulp/test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gulp/test.js b/gulp/test.js index 4b67dd6a04..d5becaebeb 100644 --- a/gulp/test.js +++ b/gulp/test.js @@ -4,7 +4,8 @@ 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 onBabelError = require('./babel-error.js'); +var rimraf = require('rimraf').sync; var JSTESTS = [ 'test/javascript/components/**/*.js', @@ -26,6 +27,8 @@ gulp.task('test:reload', function(done) { }); gulp.task('test:transpile-js', ['javascript:foundation'], function() { + rimraf('test/javascript/js-tests.js'); + return gulp.src(JSTESTS) .pipe(babel() .on('error', onBabelError)) From 9f4cf9dd4e69410c9feda728fc477bd4429ed3cd Mon Sep 17 00:00:00 2001 From: Colin Marshall Date: Sun, 27 Mar 2016 16:41:07 -0600 Subject: [PATCH 5/6] Added multiline string to Toggler unit tests --- test/javascript/components/toggler.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/javascript/components/toggler.js b/test/javascript/components/toggler.js index 5aa5626ad9..12538c17e1 100644 --- a/test/javascript/components/toggler.js +++ b/test/javascript/components/toggler.js @@ -42,7 +42,11 @@ describe('Toggler', function() { it('adds Aria attributes to click triggers', function() { $html = $('
').appendTo('body'); - var $triggers = $('OpenCloseToggle').appendTo('body'); + var $triggers = $(` + Open + Close + Toggle + `).appendTo('body'); plugin = new Foundation.Toggler($html, {}); $('[data-open]').should.have.attr('aria-controls', 'toggler'); From a789e52dc57c2c9e61d41729139f27dff0302b02 Mon Sep 17 00:00:00 2001 From: Colin Marshall Date: Sun, 27 Mar 2016 20:36:15 -0600 Subject: [PATCH 6/6] Added starter templates for js component unit tests --- test/javascript/components/abide.js | 20 +++++++++++++++++++ test/javascript/components/accordion.js | 20 +++++++++++++++++++ test/javascript/components/accordionMenu.js | 20 +++++++++++++++++++ test/javascript/components/drilldown.js | 20 +++++++++++++++++++ test/javascript/components/dropdown.js | 20 +++++++++++++++++++ test/javascript/components/dropdownMenu.js | 20 +++++++++++++++++++ test/javascript/components/equalizer.js | 20 +++++++++++++++++++ test/javascript/components/interchange.js | 20 +++++++++++++++++++ test/javascript/components/magellan.js | 20 +++++++++++++++++++ test/javascript/components/offcanvas.js | 20 +++++++++++++++++++ test/javascript/components/orbit.js | 20 +++++++++++++++++++ test/javascript/components/responsiveMenu.js | 20 +++++++++++++++++++ .../javascript/components/responsiveToggle.js | 20 +++++++++++++++++++ test/javascript/components/reveal.js | 20 +++++++++++++++++++ test/javascript/components/slider.js | 20 +++++++++++++++++++ test/javascript/components/sticky.js | 20 +++++++++++++++++++ test/javascript/components/tabs.js | 20 +++++++++++++++++++ test/javascript/components/tooltip.js | 20 +++++++++++++++++++ 18 files changed, 360 insertions(+) create mode 100644 test/javascript/components/abide.js create mode 100644 test/javascript/components/accordion.js create mode 100644 test/javascript/components/accordionMenu.js create mode 100644 test/javascript/components/drilldown.js create mode 100644 test/javascript/components/dropdown.js create mode 100644 test/javascript/components/dropdownMenu.js create mode 100644 test/javascript/components/equalizer.js create mode 100644 test/javascript/components/interchange.js create mode 100644 test/javascript/components/magellan.js create mode 100644 test/javascript/components/offcanvas.js create mode 100644 test/javascript/components/orbit.js create mode 100644 test/javascript/components/responsiveMenu.js create mode 100644 test/javascript/components/responsiveToggle.js create mode 100644 test/javascript/components/reveal.js create mode 100644 test/javascript/components/slider.js create mode 100644 test/javascript/components/sticky.js create mode 100644 test/javascript/components/tabs.js create mode 100644 test/javascript/components/tooltip.js diff --git a/test/javascript/components/abide.js b/test/javascript/components/abide.js new file mode 100644 index 0000000000..78be9efd83 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/accordion.js b/test/javascript/components/accordion.js new file mode 100644 index 0000000000..302031bfb7 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/accordionMenu.js b/test/javascript/components/accordionMenu.js new file mode 100644 index 0000000000..7a3c8df3c5 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/drilldown.js b/test/javascript/components/drilldown.js new file mode 100644 index 0000000000..915dee4be9 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/dropdown.js b/test/javascript/components/dropdown.js new file mode 100644 index 0000000000..18c62daa5e --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/dropdownMenu.js b/test/javascript/components/dropdownMenu.js new file mode 100644 index 0000000000..b8967f38e5 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/equalizer.js b/test/javascript/components/equalizer.js new file mode 100644 index 0000000000..85508a26ee --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/interchange.js b/test/javascript/components/interchange.js new file mode 100644 index 0000000000..945b7465b5 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/magellan.js b/test/javascript/components/magellan.js new file mode 100644 index 0000000000..26678f2c50 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/offcanvas.js b/test/javascript/components/offcanvas.js new file mode 100644 index 0000000000..3935a14088 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/orbit.js b/test/javascript/components/orbit.js new file mode 100644 index 0000000000..84d0b403aa --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/responsiveMenu.js b/test/javascript/components/responsiveMenu.js new file mode 100644 index 0000000000..bdfc487558 --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/responsiveToggle.js b/test/javascript/components/responsiveToggle.js new file mode 100644 index 0000000000..0065c29c4c --- /dev/null +++ b/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'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/reveal.js b/test/javascript/components/reveal.js new file mode 100644 index 0000000000..01a25ea240 --- /dev/null +++ b/test/javascript/components/reveal.js @@ -0,0 +1,20 @@ +describe('Reveal', function() { + var plugin; + var $html; + + // afterEach(function() { + // plugin.destroy(); + // $html.remove(); + // }); + + describe('constructor()', function() { + // it('', function() { + // $html = $('').appendTo('body'); + // plugin = new Foundation.Reveal($html, {}); + + // plugin.$element.should.be.an('object'); + // plugin.options.should.be.an('object'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/slider.js b/test/javascript/components/slider.js new file mode 100644 index 0000000000..4198733159 --- /dev/null +++ b/test/javascript/components/slider.js @@ -0,0 +1,20 @@ +describe('Slider', function() { + var plugin; + var $html; + + // afterEach(function() { + // plugin.destroy(); + // $html.remove(); + // }); + + describe('constructor()', function() { + // it('', function() { + // $html = $('').appendTo('body'); + // plugin = new Foundation.Slider($html, {}); + + // plugin.$element.should.be.an('object'); + // plugin.options.should.be.an('object'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/sticky.js b/test/javascript/components/sticky.js new file mode 100644 index 0000000000..b332c75ad5 --- /dev/null +++ b/test/javascript/components/sticky.js @@ -0,0 +1,20 @@ +describe('Sticky', function() { + var plugin; + var $html; + + // afterEach(function() { + // plugin.destroy(); + // $html.remove(); + // }); + + describe('constructor()', function() { + // it('', function() { + // $html = $('').appendTo('body'); + // plugin = new Foundation.Sticky($html, {}); + + // plugin.$element.should.be.an('object'); + // plugin.options.should.be.an('object'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/tabs.js b/test/javascript/components/tabs.js new file mode 100644 index 0000000000..0dab0cee1c --- /dev/null +++ b/test/javascript/components/tabs.js @@ -0,0 +1,20 @@ +describe('Tabs', function() { + var plugin; + var $html; + + // afterEach(function() { + // plugin.destroy(); + // $html.remove(); + // }); + + describe('constructor()', function() { + // it('', function() { + // $html = $('').appendTo('body'); + // plugin = new Foundation.Tabs($html, {}); + + // plugin.$element.should.be.an('object'); + // plugin.options.should.be.an('object'); + // }); + }); + +}); \ No newline at end of file diff --git a/test/javascript/components/tooltip.js b/test/javascript/components/tooltip.js new file mode 100644 index 0000000000..d680367a8e --- /dev/null +++ b/test/javascript/components/tooltip.js @@ -0,0 +1,20 @@ +describe('Tooltip', function() { + var plugin; + var $html; + + // afterEach(function() { + // plugin.destroy(); + // $html.remove(); + // }); + + describe('constructor()', function() { + // it('', function() { + // $html = $('').appendTo('body'); + // plugin = new Foundation.Tooltip($html, {}); + + // plugin.$element.should.be.an('object'); + // plugin.options.should.be.an('object'); + // }); + }); + +}); \ No newline at end of file