blob: ba6edc63e13aa277553d9ac375af5949de6d661d (
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
42
|
var assert = require("assert");
var documents = require("../lib/documents");
var DocumentConverter = documents.DocumentConverter;
var test = require("./testing").test;
describe('DocumentConverter', function() {
test('should convert document containing one paragraph to single p element', function() {
var document = new documents.Document([
paragraphOfText("Hello.")
]);
var converter = new DocumentConverter();
return converter.convertToHtml(document).then(function(result) {
assert.equal("<p>Hello.</p>", result.html);
});
})
});
describe('DocumentConverter', function() {
test('should convert document containing multiple paragraphs to multiple p elements', function() {
var document = new documents.Document([
paragraphOfText("Hello."),
paragraphOfText("Goodbye.")
]);
var converter = new DocumentConverter();
return converter.convertToHtml(document).then(function(result) {
assert.equal("<p>Hello.</p><p>Goodbye.</p>", result.html);
});
})
});
function paragraphOfText(text) {
var run = runOfText(text);
return new documents.Paragraph([run]);
}
function runOfText(text) {
var textElement = new documents.Text(text);
return new documents.Run([textElement]);
}
|