Skip to content
Permalink
Browse files

Added the test framework

  • Loading branch information...
LaurentGoderre committed Sep 25, 2013
1 parent 6ced332 commit 4ca04d4804c5b730695500eaae8aa88f997ad614
Showing with 42 additions and 6 deletions.
  1. +7 −4 Gruntfile.coffee
  2. +3 −1 package.json
  3. +18 −0 site/includes/test.hbs
  4. +2 −1 site/layouts/default.hbs
  5. +12 −0 src/plugins/carousel/test.js
@@ -22,6 +22,7 @@ module.exports = (grunt) ->
src: [
"dist/js/wet-boew.js",
"src/plugins/**/*.js"
"!src/plugins/**/test.js"
]
dest: "dist/js/wet-boew.js"

@@ -63,6 +64,7 @@ module.exports = (grunt) ->
layout: "default.hbs"
environment:
suffix: "<%= environment.suffix %>"
test: if grunt.cli.tasks.indexOf('test') then true else false
expand: true
cwd: "src/plugins"
src: ["**/*.hbs"]
@@ -244,7 +246,7 @@ module.exports = (grunt) ->

misc:
cwd: "src/plugins"
src: ["**/*.*", "!**/*.js", "!**/*.coffee", "!**/*.scss", "!**/*.hbs", "!**/assets/*"]
src: ["**/*.*", "!**/*.js", "!**/*.coffee", "!**/*.scss", "!**/*.hbs", "!**/assets/*"].concat(if grunt.cli.tasks.indexOf('test') > -1 then ["**/test.js"] else [])
dest: "dist/demo"
expand: true

@@ -330,6 +332,7 @@ module.exports = (grunt) ->
options:
port: 8000
base: "."
keepalive: true

i18n:
options:
@@ -379,10 +382,10 @@ module.exports = (grunt) ->
@registerTask "dist-js", ["js", "uglify", "clean:jsUncompressed"]
@registerTask "dist-css", ["css", "cssmin", "clean:cssUncompressed"]

@registerTask "dist", ["clean:dist", "copy", "dist-js", "dist-css", "test", "html"]
@registerTask "debug", ["clean:dist", "copy", "js", "css", "test", "html"]
@registerTask "dist", ["clean:dist", "copy", "dist-js", "dist-css", "html"]
@registerTask "debug", ["clean:dist", "copy", "js", "css", "html"]
@registerTask "test", ["dist", "jshint", "connect"]

@registerTask "test", ["jshint"]
@registerTask "html", ["assemble"]
@registerTask "server", ["connect", "watch:source"]
@registerTask "init", ["modernizr"]
@@ -43,6 +43,8 @@
"assemble": "~0.4.7",
"grunt-contrib-cssmin": "~0.6.1",
"grunt-gh-pages": "~0.7.2",
"grunt-autoprefixer": "~0.3.0"
"grunt-autoprefixer": "~0.3.0",
"mocha": "~1.13.0",
"chai": "~1.8.0"
}
}
@@ -0,0 +1,18 @@
<div id="mocha"></div>

<!-- Mocha -->
<link rel="stylesheet" href="{{assets}}/../node_modules/mocha/mocha.css" >
<script src="{{assets}}/../node_modules/mocha/mocha.js"></script>
<!-- Chai -->
<script src="{{assets}}/../node_modules/chai/chai.js"></script>

<script>
var expect = chai.expect;
mocha.setup('bdd');
$(document).on('ready', function(){

This comment has been minimized.

Copy link
@patheard

patheard Sep 26, 2013

Member

This should work. If we still run into trouble testing before a plugin is ready, we could do something like the following:

$(document).on( "initialized.wb-plugin-name", mocha.run );

and in the plugin:

init: function() {
  /* init magic goes here */
  vapour.doc.trigger( "initialized.wb-plugin-name" );
}

Or just increase the timeout 😁

This comment has been minimized.

Copy link
@LaurentGoderre

LaurentGoderre Sep 26, 2013

Author Member

Sounds good!

setTimeout(mocha.run, 2000);
});
</script>

<!-- Test -->
<script src="test.js"></script>
@@ -28,7 +28,7 @@
<script src="{{assets}}/js/vapour{{environment.suffix}}.js"></script>

</head>
<body>
<body>{{#if test}}{{>test}}{{/if}}
<div id="wb-skip">
<ul id="wb-tphp">
<li id="wb-skip1">
@@ -84,5 +84,6 @@
</footer>

<script src="{{assets}}/js/wet-boew{{environment.suffix}}.js"></script>
<script src="{{assets}}/js/theme.js"></script>
</body>
</html>
@@ -0,0 +1,12 @@

/* global jQuery:false, describe: false, it: false, expect: false*/
/*jshint unused:vars */
(function($) {

describe('Sample test', function () {
it('should pass', function () {
expect(true).to.equal(true);
});
});

}) (jQuery);

0 comments on commit 4ca04d4

Please sign in to comment.
You can’t perform that action at this time.