From 185b830daf59c385be312e8b2b40ffb3a93c28cb Mon Sep 17 00:00:00 2001 From: Bala Clark Date: Fri, 10 May 2013 00:03:53 +0200 Subject: [PATCH] split tests into modules --- lib/tests/unit/ComicBook.js | 39 +++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/tests/unit/ComicBook.js b/lib/tests/unit/ComicBook.js index fb59104..fc93ddd 100644 --- a/lib/tests/unit/ComicBook.js +++ b/lib/tests/unit/ComicBook.js @@ -7,29 +7,38 @@ $(function () { var $fixture; var book; - module('ComicBook', { + function initBook() { + + $fixture = $('#qunit-fixture'); + $fixture.append(''); + + book = new ComicBook( + 'comic', + ['img/1.png','img/2.png','img/3.png','img/4.png','img/5.png','img/6.png'], + { libPath: '../vendor/' } + ); + } + + module('not yet rendered comic', { + setup: initBook + }); + + test('controls shouldn\'t be renderd yet', function () { + equal($('.cb-control, .toolbar').length, 0, 'book not drawn yet, nothing should be rendered'); + }); + + module('rendered comic', { setup: function () { - - $fixture = $('#qunit-fixture'); - $fixture.append(''); - - book = new ComicBook( - 'comic', - ['img/1.png','img/2.png','img/3.png','img/4.png','img/5.png','img/6.png'], - { libPath: '../vendor/' } - ); - - // book.draw(); + initBook(); + book.draw(); }, teardown: function () { } }); - test('render all controls on draw', function () { - equal($('.cb-control, .toolbar').length, 0, 'book not drawn yet, nothing should be rendered'); - book.draw(); + test('all controls should be rendered', function () { equal($('.cb-control, .toolbar').length, 5, 'All toolbar elements should have rendered after book.draw'); });