-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
35 lines (28 loc) · 1.33 KB
/
test.js
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
var expect = require('expect.js');
var storydata = require('./src/storydata');
describe("Fusion", function() {
it("can extract story data", function() {
var sourceFile = __dirname + '/test-data/Story1.html';
expect(storydata.extractStoryData(sourceFile)).to.match(/<tw-storydata(.|\n)*<\/tw-storydata>/m);
});
it("can merge storydatas", function() {
var story1 = '<tw-storydata>' +
'<tw-passagedata pid="1" name="passage1">text1</tw-passagedata>' +
'</tw-storydata>';
var story2 = '<tw-storydata>' +
'<tw-passagedata pid="2" name="passage2">text2</tw-passagedata>' +
'<tw-passagedata pid="3" name="passage3">text3</tw-passagedata>' +
'</tw-storydata>';
expect(storydata.mergeStoryDatas(story1, story2)).to.be(
'<tw-storydata>' +
'<tw-passagedata pid="1" name="passage1">text1</tw-passagedata>' +
'<tw-passagedata pid="2" name="passage2">text2</tw-passagedata>' +
'<tw-passagedata pid="3" name="passage3">text3</tw-passagedata>' +
'</tw-storydata>'
);
});
it("throws if story data is not found", function() {
var sourceFile = __dirname + '/test-data/noStoryData.html';
expect(storydata.extractStoryData.bind(null, sourceFile)).to.throwException(/No tw-storydata element found/);
});
});