extwee 2.0.0 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/extwee.js +1 -1
- package/package.json +4 -5
- package/src/HTMLWriter.js +40 -5
- package/src/Story.js +31 -2
- package/src/TweeParser.js +2 -7
- package/test/CLI/test2.html +2 -2
- package/test/HTMLWriter/creator.html +2 -2
- package/test/HTMLWriter/test11.html +3 -3
- package/test/HTMLWriter/test2.html +1 -1
- package/test/HTMLWriter/test3.html +1 -1
- package/test/HTMLWriter/test4.html +2 -2
- package/test/HTMLWriter/test6.html +2 -2
- package/test/HTMLWriter.test.js +24 -14
- package/test/Passage.test.js +22 -22
- package/test/Roundtrip/round.html +2 -2
- package/test/Story.test.js +172 -85
- package/test/TweeParser.test.js +14 -14
- package/test/TweeWriter/test1.twee +1 -1
- package/test/TweeWriter/test5.twee +1 -1
- package/test/TweeWriter.test.js +15 -12
package/test/Story.test.js
CHANGED
|
@@ -6,142 +6,202 @@ import FileReader from '../src/FileReader.js';
|
|
|
6
6
|
// These are used as the 'creator' and 'creator-version'.
|
|
7
7
|
const { name, version } = JSON.parse(FileReader.read('package.json'));
|
|
8
8
|
|
|
9
|
-
describe('Story',
|
|
10
|
-
describe('#constructor()',
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
describe('Story', () => {
|
|
10
|
+
describe('#constructor()', () => {
|
|
11
|
+
let s = null;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
s = new Story();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('Should have extwee name', () => {
|
|
13
18
|
expect(s.creator).toBe(name);
|
|
14
19
|
});
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
const s = new Story();
|
|
21
|
+
it('Should have extwee version', () => {
|
|
18
22
|
expect(s.creatorVersion).toBe(version);
|
|
19
23
|
});
|
|
20
24
|
});
|
|
21
25
|
|
|
22
|
-
describe('creator',
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
describe('creator', () => {
|
|
27
|
+
let s = null;
|
|
28
|
+
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
s = new Story();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('Set using String', () => {
|
|
25
34
|
s.creator = 'New';
|
|
26
35
|
expect(s.creator).toBe('New');
|
|
27
36
|
});
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
const s = new Story();
|
|
38
|
+
it('Should throw error if not String', () => {
|
|
31
39
|
expect(() => {
|
|
32
40
|
s.creator = 1;
|
|
33
41
|
}).toThrow();
|
|
34
42
|
});
|
|
35
43
|
});
|
|
36
44
|
|
|
37
|
-
describe('creatorVersion',
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
describe('creatorVersion', () => {
|
|
46
|
+
let s = null;
|
|
47
|
+
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
s = new Story();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('Set using String', () => {
|
|
40
53
|
s.creatorVersion = 'New';
|
|
41
54
|
expect(s.creatorVersion).toBe('New');
|
|
42
55
|
});
|
|
43
56
|
|
|
44
|
-
|
|
45
|
-
const s = new Story();
|
|
57
|
+
it('Should throw error if not String', () => {
|
|
46
58
|
expect(() => {
|
|
47
59
|
s.creatorVersion = 1;
|
|
48
60
|
}).toThrow();
|
|
49
61
|
});
|
|
50
62
|
});
|
|
51
63
|
|
|
52
|
-
describe('IFID',
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
describe('IFID', () => {
|
|
65
|
+
let s = null;
|
|
66
|
+
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
s = new Story();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('Set using String', () => {
|
|
55
72
|
s.IFID = 'New';
|
|
56
73
|
expect(s.IFID).toBe('New');
|
|
57
74
|
});
|
|
58
75
|
|
|
59
|
-
|
|
60
|
-
const s = new Story();
|
|
76
|
+
it('Should throw error if not String', () => {
|
|
61
77
|
expect(() => {
|
|
62
78
|
s.IFID = 1;
|
|
63
79
|
}).toThrow();
|
|
64
80
|
});
|
|
65
81
|
});
|
|
66
82
|
|
|
67
|
-
describe('format',
|
|
68
|
-
|
|
69
|
-
|
|
83
|
+
describe('format', () => {
|
|
84
|
+
let s = null;
|
|
85
|
+
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
s = new Story();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('Set using String', () => {
|
|
70
91
|
s.format = 'New';
|
|
71
92
|
expect(s.format).toBe('New');
|
|
72
93
|
});
|
|
73
94
|
|
|
74
|
-
|
|
75
|
-
const s = new Story();
|
|
95
|
+
it('Should throw error if not String', () => {
|
|
76
96
|
expect(() => {
|
|
77
97
|
s.format = 1;
|
|
78
98
|
}).toThrow();
|
|
79
99
|
});
|
|
80
100
|
});
|
|
81
101
|
|
|
82
|
-
describe('formatVersion',
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
describe('formatVersion', () => {
|
|
103
|
+
let s = null;
|
|
104
|
+
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
s = new Story();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('Set using String', () => {
|
|
85
110
|
s.formatVersion = 'New';
|
|
86
111
|
expect(s.formatVersion).toBe('New');
|
|
87
112
|
});
|
|
88
113
|
|
|
89
|
-
|
|
90
|
-
const s = new Story();
|
|
114
|
+
it('Should throw error if not String', () => {
|
|
91
115
|
expect(() => {
|
|
92
116
|
s.formatVersion = 1;
|
|
93
117
|
}).toThrow();
|
|
94
118
|
});
|
|
95
119
|
});
|
|
96
120
|
|
|
97
|
-
describe('
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
describe('name', () => {
|
|
122
|
+
let s = null;
|
|
123
|
+
|
|
124
|
+
beforeEach(() => {
|
|
125
|
+
s = new Story();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('Set using String', () => {
|
|
129
|
+
s.name = 'New';
|
|
130
|
+
expect(s.name).toBe('New');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('Should throw error if not String', () => {
|
|
134
|
+
expect(() => {
|
|
135
|
+
s.name = 1;
|
|
136
|
+
}).toThrow();
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe('zoom', () => {
|
|
141
|
+
let s = null;
|
|
142
|
+
|
|
143
|
+
beforeEach(() => {
|
|
144
|
+
s = new Story();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('Set using Number', () => {
|
|
100
148
|
s.zoom = 1.0;
|
|
101
149
|
expect(s.zoom).not.toBe(0);
|
|
102
150
|
});
|
|
103
151
|
|
|
104
|
-
|
|
105
|
-
const s = new Story();
|
|
152
|
+
it('Should throw error if not String', () => {
|
|
106
153
|
expect(() => {
|
|
107
154
|
s.zoom = null;
|
|
108
155
|
}).toThrow();
|
|
109
156
|
});
|
|
110
157
|
});
|
|
111
158
|
|
|
112
|
-
describe('metadata',
|
|
113
|
-
|
|
114
|
-
|
|
159
|
+
describe('metadata', () => {
|
|
160
|
+
let s = null;
|
|
161
|
+
|
|
162
|
+
beforeEach(() => {
|
|
163
|
+
s = new Story();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('Set metadata', () => {
|
|
115
167
|
s.metadata = {};
|
|
116
168
|
expect(s.metadata).not.toBe(null);
|
|
117
169
|
});
|
|
118
170
|
|
|
119
|
-
|
|
120
|
-
const s = new Story();
|
|
171
|
+
it('Should throw error if not object', () => {
|
|
121
172
|
expect(() => {
|
|
122
173
|
s.metadata = 1;
|
|
123
174
|
}).toThrow();
|
|
124
175
|
});
|
|
125
176
|
});
|
|
126
177
|
|
|
127
|
-
describe('start',
|
|
128
|
-
|
|
129
|
-
|
|
178
|
+
describe('start', () => {
|
|
179
|
+
let s = null;
|
|
180
|
+
|
|
181
|
+
beforeEach(() => {
|
|
182
|
+
s = new Story();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('Set start', () => {
|
|
130
186
|
s.start = 'Start';
|
|
131
187
|
expect(s.start).not.toBe('');
|
|
132
188
|
});
|
|
133
189
|
|
|
134
|
-
|
|
135
|
-
const s = new Story();
|
|
190
|
+
it('Should throw error if not String', () => {
|
|
136
191
|
expect(() => {
|
|
137
192
|
s.start = 1;
|
|
138
193
|
}).toThrow();
|
|
139
194
|
});
|
|
140
195
|
});
|
|
141
196
|
|
|
142
|
-
describe('tagColors',
|
|
143
|
-
|
|
144
|
-
|
|
197
|
+
describe('tagColors', () => {
|
|
198
|
+
let s = null;
|
|
199
|
+
|
|
200
|
+
beforeEach(() => {
|
|
201
|
+
s = new Story();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('Set tagColors', () => {
|
|
145
205
|
s.tagColors = {
|
|
146
206
|
bar: 'green'
|
|
147
207
|
};
|
|
@@ -149,31 +209,33 @@ describe('Story', function () {
|
|
|
149
209
|
expect(count).toBe(1);
|
|
150
210
|
});
|
|
151
211
|
|
|
152
|
-
|
|
153
|
-
const s = new Story();
|
|
212
|
+
it('Should throw error if not object', () => {
|
|
154
213
|
expect(() => {
|
|
155
214
|
s.tagColors = null;
|
|
156
215
|
}).toThrow();
|
|
157
216
|
});
|
|
158
217
|
});
|
|
159
218
|
|
|
160
|
-
describe('addPassage()',
|
|
161
|
-
|
|
162
|
-
|
|
219
|
+
describe('addPassage()', () => {
|
|
220
|
+
let s = null;
|
|
221
|
+
|
|
222
|
+
beforeEach(() => {
|
|
223
|
+
s = new Story();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('addPassage() - should increase size', () => {
|
|
163
227
|
const p = new Passage();
|
|
164
228
|
s.addPassage(p);
|
|
165
229
|
expect(s.size()).toBe(1);
|
|
166
230
|
});
|
|
167
231
|
|
|
168
|
-
|
|
169
|
-
const s = new Story();
|
|
232
|
+
it('addPassage() - should throw error if non-Passage', () => {
|
|
170
233
|
expect(() => {
|
|
171
234
|
s.addPassage(null);
|
|
172
235
|
}).toThrow();
|
|
173
236
|
});
|
|
174
237
|
|
|
175
|
-
|
|
176
|
-
const s = new Story();
|
|
238
|
+
it('addPassage() - should prevent passages with same name being added', () => {
|
|
177
239
|
const p = new Passage('A');
|
|
178
240
|
const p2 = new Passage('A');
|
|
179
241
|
s.addPassage(p);
|
|
@@ -182,9 +244,14 @@ describe('Story', function () {
|
|
|
182
244
|
});
|
|
183
245
|
});
|
|
184
246
|
|
|
185
|
-
describe('removePassage()',
|
|
186
|
-
|
|
187
|
-
|
|
247
|
+
describe('removePassage()', () => {
|
|
248
|
+
let s = null;
|
|
249
|
+
|
|
250
|
+
beforeEach(() => {
|
|
251
|
+
s = new Story();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('removePassage() - should decrease size', () => {
|
|
188
255
|
s.addPassage(new Passage('Find'));
|
|
189
256
|
s.addPassage(new Passage('Find2'));
|
|
190
257
|
s.removePassage('Find');
|
|
@@ -192,9 +259,14 @@ describe('Story', function () {
|
|
|
192
259
|
});
|
|
193
260
|
});
|
|
194
261
|
|
|
195
|
-
describe('getPassagesByTag()',
|
|
196
|
-
|
|
197
|
-
|
|
262
|
+
describe('getPassagesByTag()', () => {
|
|
263
|
+
let s = null;
|
|
264
|
+
|
|
265
|
+
beforeEach(() => {
|
|
266
|
+
s = new Story();
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('getPassagesByTag() - should find passages', () => {
|
|
198
270
|
const p = new Passage('Find', '', ['one']);
|
|
199
271
|
const p2 = new Passage('Find2', '', ['one']);
|
|
200
272
|
s.addPassage(p);
|
|
@@ -203,14 +275,12 @@ describe('Story', function () {
|
|
|
203
275
|
expect(ps).toHaveLength(2);
|
|
204
276
|
});
|
|
205
277
|
|
|
206
|
-
|
|
207
|
-
const s = new Story();
|
|
278
|
+
it('getPassagesByTag() - should find none if none in collection', () => {
|
|
208
279
|
const ps = s.getPassagesByTag('one');
|
|
209
280
|
expect(ps).toHaveLength(0);
|
|
210
281
|
});
|
|
211
282
|
|
|
212
|
-
|
|
213
|
-
const s = new Story();
|
|
283
|
+
it('getPassagesByTag() - should find none if no tags match search', () => {
|
|
214
284
|
const p = new Passage('Find', '', ['one']);
|
|
215
285
|
const p2 = new Passage('Find2', '', ['one']);
|
|
216
286
|
s.addPassage(p);
|
|
@@ -220,9 +290,14 @@ describe('Story', function () {
|
|
|
220
290
|
});
|
|
221
291
|
});
|
|
222
292
|
|
|
223
|
-
describe('getPassageByName()',
|
|
224
|
-
|
|
225
|
-
|
|
293
|
+
describe('getPassageByName()', () => {
|
|
294
|
+
let s = null;
|
|
295
|
+
|
|
296
|
+
beforeEach(() => {
|
|
297
|
+
s = new Story();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it('getPassageByName() - should get passage by name', () => {
|
|
226
301
|
const p = new Passage('Find');
|
|
227
302
|
s.addPassage(p);
|
|
228
303
|
const passage = s.getPassageByName('Find');
|
|
@@ -230,24 +305,33 @@ describe('Story', function () {
|
|
|
230
305
|
});
|
|
231
306
|
});
|
|
232
307
|
|
|
233
|
-
describe('getPassageByPID()',
|
|
234
|
-
|
|
235
|
-
|
|
308
|
+
describe('getPassageByPID()', () => {
|
|
309
|
+
let s = null;
|
|
310
|
+
|
|
311
|
+
beforeEach(() => {
|
|
312
|
+
s = new Story();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('getPassageByPID() - should get passage by PID', () => {
|
|
236
316
|
const p = new Passage('Find', '', [], {}, 12);
|
|
237
317
|
s.addPassage(p);
|
|
238
318
|
const passage = s.getPassageByPID(12);
|
|
239
319
|
expect(passage.name).toBe('Find');
|
|
240
320
|
});
|
|
241
321
|
|
|
242
|
-
|
|
243
|
-
const s = new Story();
|
|
322
|
+
it('getPassageByPID() - should return null if not found', () => {
|
|
244
323
|
expect(s.getPassageByPID(12)).toBe(null);
|
|
245
324
|
});
|
|
246
325
|
});
|
|
247
326
|
|
|
248
|
-
describe('forEach()',
|
|
249
|
-
|
|
250
|
-
|
|
327
|
+
describe('forEach()', () => {
|
|
328
|
+
let s = null;
|
|
329
|
+
|
|
330
|
+
beforeEach(() => {
|
|
331
|
+
s = new Story();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it('forEach() - should return if non-function', () => {
|
|
251
335
|
s.addPassage(new Passage('A'));
|
|
252
336
|
s.addPassage(new Passage('B'));
|
|
253
337
|
let passageNames = '';
|
|
@@ -257,18 +341,21 @@ describe('Story', function () {
|
|
|
257
341
|
expect(passageNames).toBe('AB');
|
|
258
342
|
});
|
|
259
343
|
|
|
260
|
-
|
|
261
|
-
const s = new Story();
|
|
344
|
+
it('forEach() - should throw error if non-function', () => {
|
|
262
345
|
expect(() => {
|
|
263
346
|
s.forEach(null);
|
|
264
347
|
}).toThrow();
|
|
265
348
|
});
|
|
266
349
|
});
|
|
267
350
|
|
|
268
|
-
describe('size()',
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
351
|
+
describe('size()', () => {
|
|
352
|
+
let s = null;
|
|
353
|
+
|
|
354
|
+
beforeEach(() => {
|
|
355
|
+
s = new Story();
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('size() - should report number of passages', () => {
|
|
272
359
|
// Create a Passage
|
|
273
360
|
const p = new Passage('');
|
|
274
361
|
// Test initial size
|
package/test/TweeParser.test.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import FileReader from '../src/FileReader.js';
|
|
2
2
|
import TweeParser from '../src/TweeParser.js';
|
|
3
3
|
|
|
4
|
-
describe('TweeParser',
|
|
5
|
-
describe('#parse()',
|
|
6
|
-
|
|
4
|
+
describe('TweeParser', () => {
|
|
5
|
+
describe('#parse()', () => {
|
|
6
|
+
it('Should throw error if non-string is used', () => {
|
|
7
7
|
expect(() => { TweeParser.parse(1); }).toThrow();
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
it('Should throw error if empty string is used', () => {
|
|
11
11
|
expect(() => { TweeParser.parse(); }).toThrow();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
it('Should throw error if no passages are present', () => {
|
|
15
15
|
expect(() => { TweeParser.parse('()()'); }).toThrow();
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
it('Should throw error if it detects malformed passage headers', () => {
|
|
19
19
|
expect(() => { TweeParser.parse('::{}[]\nNo name'); }).toThrow();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
it('Should cut notes before passages', () => {
|
|
23
23
|
const fr = FileReader.read('test/TweeParser/notes.twee');
|
|
24
24
|
const story = TweeParser.parse(fr);
|
|
25
25
|
const p = story.getPassageByName('StoryTitle');
|
|
26
26
|
expect(p.text).toBe('twineExample');
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
it('Should be able to parse Twee file for Story Name', () => {
|
|
30
30
|
const fr = FileReader.read('test/TweeParser/example.twee');
|
|
31
31
|
const story = TweeParser.parse(fr);
|
|
32
32
|
const p = story.getPassageByName('StoryTitle');
|
|
33
33
|
expect(p.text).toBe('twineExample');
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
it('Should parse single tag on Start passage', () => {
|
|
37
37
|
const fr = FileReader.read('test/TweeParser/singletag.twee');
|
|
38
38
|
const story = TweeParser.parse(fr);
|
|
39
39
|
const start = story.getPassageByName('Start');
|
|
40
40
|
expect(start.tags).toHaveLength(1);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
it('Should parse multiple tag', () => {
|
|
44
44
|
const fr = FileReader.read('test/TweeParser/multipletags.twee');
|
|
45
45
|
const story = TweeParser.parse(fr);
|
|
46
46
|
const start = story.getPassageByName('Start');
|
|
47
47
|
expect(start.tags).toHaveLength(2);
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
it('Should parse single script passage', () => {
|
|
51
51
|
const fr = FileReader.read('test/TweeParser/scriptPassage.twee');
|
|
52
52
|
const story = TweeParser.parse(fr);
|
|
53
53
|
const p = story.getPassageByName('UserScript');
|
|
54
54
|
expect(p.tags).toHaveLength(1);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
it('Should parse single stylesheet passage', () => {
|
|
58
58
|
const fr = FileReader.read('test/TweeParser/stylePassage.twee');
|
|
59
59
|
const story = TweeParser.parse(fr);
|
|
60
60
|
const p = story.getPassageByName('UserStylesheet');
|
|
@@ -62,14 +62,14 @@ describe('TweeParser', function () {
|
|
|
62
62
|
expect(p.name).toBe('UserStylesheet');
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
it('Should parse StoryTitle', () => {
|
|
66
66
|
const fr = FileReader.read('test/TweeParser/test.twee');
|
|
67
67
|
const story = TweeParser.parse(fr);
|
|
68
68
|
const p = story.getPassageByName('StoryTitle');
|
|
69
69
|
expect(p).not.toBe(null);
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
it('Should parse StoryAuthor', () => {
|
|
73
73
|
const fr = FileReader.read('test/TweeParser/example.twee');
|
|
74
74
|
const story = TweeParser.parse(fr);
|
|
75
75
|
const p = story.getPassageByName('StoryAuthor');
|
package/test/TweeWriter.test.js
CHANGED
|
@@ -4,18 +4,23 @@ import Passage from '../src/Passage.js';
|
|
|
4
4
|
import TweeWriter from '../src/TweeWriter.js';
|
|
5
5
|
import TweeParser from '../src/TweeParser.js';
|
|
6
6
|
|
|
7
|
-
describe('TweeWriter',
|
|
8
|
-
describe('#write()',
|
|
9
|
-
|
|
7
|
+
describe('TweeWriter', () => {
|
|
8
|
+
describe('#write()', () => {
|
|
9
|
+
let s = null;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
s = new Story();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('Should throw error if object passed is not instanceof Story', () => {
|
|
10
16
|
expect(() => { TweeWriter.write({}); }).toThrow();
|
|
11
17
|
});
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
it('Should throw error if output file invalid', () => {
|
|
14
20
|
expect(() => { TweeWriter.write(new Story(), ''); }).toThrow();
|
|
15
21
|
});
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
const s = new Story();
|
|
23
|
+
it('Should write Twee file', () => {
|
|
19
24
|
s.addPassage(new Passage('StoryData', '{}'));
|
|
20
25
|
s.addPassage(new Passage('StoryTitle', 'Title'));
|
|
21
26
|
s.addPassage(new Passage('Start', 'Content'));
|
|
@@ -26,8 +31,7 @@ describe('TweeWriter', function () {
|
|
|
26
31
|
expect(p.text).toBe('Title');
|
|
27
32
|
});
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
const s = new Story();
|
|
34
|
+
it('Should correctly write Twee file with passage tags', () => {
|
|
31
35
|
s.addPassage(new Passage('Start', '', ['tag', 'tags']));
|
|
32
36
|
s.addPassage(new Passage('StoryTitle', 'Title'));
|
|
33
37
|
// Verify only one passage.
|
|
@@ -46,8 +50,7 @@ describe('TweeWriter', function () {
|
|
|
46
50
|
expect(tp.size()).toBe(2);
|
|
47
51
|
});
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
const s = new Story();
|
|
53
|
+
it('Should write format, formatVersion, zoom, and start', () => {
|
|
51
54
|
s.addPassage(new Passage('StoryTitle', 'Title'));
|
|
52
55
|
s.addPassage(new Passage('Start', 'Content'));
|
|
53
56
|
s.addPassage(new Passage('Untitled', 'Some stuff'));
|
|
@@ -60,11 +63,11 @@ describe('TweeWriter', function () {
|
|
|
60
63
|
TweeWriter.write(s, 'test/TweeWriter/test1.twee');
|
|
61
64
|
const fr = FileReader.read('test/TweeWriter/test1.twee');
|
|
62
65
|
const story2 = TweeParser.parse(fr);
|
|
66
|
+
console.log(story2);
|
|
63
67
|
expect(story2.format).toBe('Test');
|
|
64
68
|
});
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
const s = new Story();
|
|
70
|
+
it('Should write tag colors', () => {
|
|
68
71
|
s.addPassage(new Passage('StoryTitle', 'Title'));
|
|
69
72
|
s.addPassage(new Passage('Start', 'Content'));
|
|
70
73
|
s.addPassage(new Passage('Untitled', 'Some stuff'));
|