Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: e55b5d0fb1

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
features
fixtures
h5bp @ c264d91
helpers
tasks
index.html
mocha.opts
readme.md

readme.md

Tests


done:

  • ✔ default
  • ✔ build:minify

  • ✔ css.js

  • ✔ img.js
  • ✔ tar.js
  • ✔ usemin.js
  • ✔ docs.js
  • ✔ html.js
  • ✔ init.js
  • ✔ rjs.js

to be done

  • dom.js
  • h5bp.js
  • misc.js
  • rev.js
  • serve.js

TOC

Default task

As a build script user I want to be able to run the default task So that I can see the whole tasks in action

Default task

Given I run the 'default' task.

helpers.run('default', done);

When the build script ends

Then the outcome should be 'test/fixtures/default'.

helpers.assertFile('.test/publish/index.html', 'test/fixtures/default/expected.html');

build:minify task

As a build script user I want to run the build:minify task

build:minify task

Given I run the 'build:minify' task.

helpers.run('build:minify', done);

When the build script ends

Then the outcome should be 'test/fixtures/default/build.minify.html'.

helpers.copyFile('.test/publish/index.html', 'test/fixtures/default/build.minify.html');

CSS task

As a build script user I want to be able to run the css task So that I can see the css task in action

css task

Given I run the 'css' task.

// runt the css task
helpers.run('css', done);

When the script ends.

// not doing particularly usefull in this step
// but the hook is here is we need to
done();

Then './test/css/style.css' should be the same as 'test/fixtures/css/expected.css'.

helpers.assertFile('.test/css/style.css', 'test/fixtures/css/expected.css');
done();

DOCS task

As a build script user I want to be able to run the docs task So that I can see the docs task in action

docs task

Given I run the 'docs' task.

// runt the docs task
helpers.run('docs', done);

When the script ends.

// not doing anything particularly usefull in this step but the hook is here
// if we need to
done();

Then it should not fail miserably

(and you should see the documention in a web browser by now..).

assert.ok(true);

HTML task

As a build script user I want to be able to run the html task So that I can see the html task in action

html task

Given I run the 'html' task.

// runt the html task
helpers.run('html', done);

When the script ends.

// not doing anything particularly usefull in this step but the hook is here
// if we need to
done();

Then './test/index.html' should be the same as 'test/fixtures/html/index.html'.

helpers.assertFile('.test/index.html', 'test/fixtures/html/index.html');
done();

IMG task

As a build script user I want to be able to run the img task So that I can see the img task in action

img task

Given I run the 'img' task.

// run the img task
//
// note: try commenting out this and execute done callback right away
// to see mocha generate diff output on base64 encoded value in its
// full glory
helpers.run('img', done);

When the script ends.

// not doing particularly usefull in this step
// but the hook is here is we need to
done();

Then '.test/img' dir should be the same as 'test/fixtures/img/expected/'.

helpers.assertDir('.test/img', 'test/fixtures/img/expected/');
done();

INIT task

As a build script user I want to be able to run the init task So that I can see this in action

init task default template

Given I run the 'init' task with default template.

// runt the init task
var grunt = helpers.run('init --template defaults', {
  bin: path.join(__dirname, '../../bin/h5bp')
}, done);

When the script ends.

// not doing anything particularly usefull in this step but the hook is here
// if we need to
done();

Then '.test/' should be the same as 'test/fixtures/init/expected/'.

helpers.assertDir('.test/', 'test/fixtures/init/expected/');
done();

init task rjs template

Given I run the 'init' task with rjs template.

// runt the init task
var grunt = helpers.run('init --template rjs --force', {
  bin: path.join(__dirname, '../../bin/h5bp')
}, done);

When the script ends

Then '.test/gruntfile.js' should be the same as 'test/fixtures/init/rjs.gruntfile.js'.

helpers.assertFile('.test/grunt.js', 'test/fixtures/init/rjs.gruntfile.js');
done();

RJS task

As a build script user I want to be able to run the rjs task So that I can see the rjs task in action

rjs task

Given I run the 'rjs' task.

// runt the rjs task
helpers.run('rjs', done);

When the script ends.

// not doing anything particularly usefull in this step but the hook is here
// if we need to
done();

Then '.test/js' should be the same as 'test/fixtures/rjs/expected/'.

helpers.assertDir('.test/js', 'test/fixtures/rjs/expected/');
done();

TAR task

As a build script user I want to be able to run the tar task So that I can see the tar task in action

tar task

Given I run the 'tar' task.

// runs the tar task
// we gonna pack the whole '.test' dir in '.test/test.tar.gz'
// curious to see how the task handle output within input..
helpers.run('tar --input ./ --output ./test.tgz', done);

When the script ends.

// not doing particularly usefull in this step
// but the hook is here is we need to
done();

Then '.test/test.tgz' should be the same as 'test/fixtures/tar/test.tgz'.

helpers.assertLength('.test/test.tgz', 'test/fixtures/tar/test.tgz', done);

USEMIN task

As a build script user I want to be able to run the usemin task So that I can see the usemin task in action

usemin task

Given I run the 'usemin' task.

// runt the usemin task
helpers.run("usemin", done);

When the script ends.

// not doing anything particularly usefull in this step
// but the hook is here if we need to
done();

Then '.test/usemin.html' should be the same as 'test/fixtures/usemin/index.html'.

// todo: task log output doesn"t return things that were changed between
// <!-- build:<target> path/to/foo.js --> directives
helpers.assertFile(".test/usemin.html", "test/fixtures/usemin/index.html");
done();

usemin task with reved imgs

Given I run the 'rev usemin' task.

// runt the usemin task
helpers.run("css rev usemin", done);

When the script ends.

// not doing anything particularly usefull in this step
// but the hook is here if we need to
done();

Then '.test/usemin.html' should be the same as 'test/fixtures/usemin/index.html'.

// todo: task log output doesn"t return things that were changed between
// <!-- build:<target> path/to/foo.js --> directives
helpers.copyFile(".test/usemin.html", "test/fixtures/usemin/reved.html");
helpers.assertFile(".test/usemin.html", "test/fixtures/usemin/reved.html");
done();

And I should see 'img/59928801.1.png' in '.test/usemin.html'.

var test = new RegExp("img/59928801.1.png");
fs.readFile(".test/usemin.html", function(err, body) {
  if(err) return done(err);
  assert.ok(test.test(body));
  done();
});

And I should see 'img/f67f4a27.6.jpg' in '.test/css/style.css'.

var test = new RegExp("img/f67f4a27.6.jpg");
fs.readFile(".test/css/e1823e1a.style.css", function(err, body) {
  if(err) return done(err);
  assert.ok(test.test(body), 'Missing reved img in style.css');
  done();
});

And I should see 'img/f67f4a27.6.jpg' in '.test/css/style.css'.

var test = new RegExp("img/f67f4a27.6.jpg");
fs.readFile(".test/css/e1823e1a.style.css", function(err, body) {
  if(err) return done(err);
  assert.ok(test.test(body), 'Missing reved img in style.css');
  done();
});
Something went wrong with that request. Please try again.