aboutsummaryrefslogtreecommitdiff
path: root/tests/testing.js
blob: af8ec9425a6a8ae012ce79db0c570fca6d8137d5 (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
31
32
33
34
35
36
37
var path = require("path");
var fs = require("fs");
var q = require("q");

exports.test = test;
exports.testData = testData;
exports.createFakeDocxFile = createFakeDocxFile;


function test(name, func) {
    it(name, function(done) {
        var result = func();
        q.when(result).then(function() {
            done()
        }).done();
    });
}

function testData(testDataPath) {
    var fullPath = path.join(__dirname, "test-data", testDataPath);
    return q.nfcall(fs.readFile, fullPath, "utf-8");
}

function createFakeDocxFile(files) {
    function read(path) {
        return q.when(files[path]);
    }
    
    function exists(path) {
        return !!files[path];
    }
    
    return {
        read: read,
        exists: exists
    };
}