blob: ac1e193ea6e7547fb01f1912e67057a98c493ac5 (
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
38
39
40
41
|
var tmp = require('tmp');
var Book = require('../models/book');
var createMockFS = require('../fs/mock');
var parseBook = require('../parse/parseBook');
var generateBook = require('./generateBook');
/**
Generate a book using JSON generator
And returns the path to the output dir.
FOR TESTING PURPOSE ONLY
@param {Generator}
@param {Map<String:String|Map>} files
@return {Promise<String>}
*/
function generateMock(Generator, files) {
var fs = createMockFS(files);
var book = Book.createForFS(fs);
var dir;
try {
dir = tmp.dirSync();
} catch(err) {
throw err;
}
book = book.setLogLevel('disabled');
return parseBook(book)
.then(function(resultBook) {
return generateBook(Generator, resultBook, {
root: dir.name
});
})
.thenResolve(dir.name);
}
module.exports = generateMock;
|