summaryrefslogtreecommitdiffstats
path: root/test/helper.js
blob: f29b3c7c77cdcecf9fceb4d8269ae8796554f7e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var path = require('path');
var Q = require('q');
var Book = require('../').Book;

// Nicety for mocha / Q
global.qdone = function qdone(promise, done) {
    return promise.then(function() {
        return done();
    }, function(err) {
        return done(err);
    }).done();
};

// Init before doing tests
before(function(done) {
    global.book1 = new Book(path.join(__dirname, './fixtures/test1'));
    global.book2 = new Book(path.join(__dirname, './fixtures/test2'));
    global.book3 = new Book(path.join(__dirname, './fixtures/test3'));

    qdone(
	    global.book1.parse()
	    .then(function() {
	    	return global.book2.parse();
	    })
        .then(function() {
            return global.book3.parse();
        }),
	    done
	);
});