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/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..51e0891554 100644 --- a/gulp/javascript.js +++ b/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', @@ -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..d5becaebeb 100644 --- a/gulp/test.js +++ b/gulp/test.js @@ -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 @@ -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')); +}); 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" 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/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'); 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 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(); - - +