extwee 2.0.3 → 2.0.6

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.
@@ -9,12 +9,11 @@
9
9
  </head>
10
10
  <body>
11
11
  <tw-story tags></tw-story>
12
- <tw-storydata name="Title" startnode="4" creator="extwee" creator-version="2.0.3" ifid="A1EFB550-B470-44EA-816C-73683E385FF2" zoom="0" format="Snowman" format-version="2.0.0" options hidden>
12
+ <tw-storydata name="Title" startnode="4" creator="extwee" creator-version="2.0.6" ifid="1096FE8A-C8B0-4485-8628-61B25490AB7E" zoom="0" format="Snowman" format-version="2.0.0" options hidden>
13
13
  <style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>
14
14
  <script role="script" id="twine-user-script" type="text/twine-javascript"></script>
15
15
  <tw-passagedata pid="1" name="A"></tw-passagedata>
16
16
  <tw-passagedata pid="2" name="B"></tw-passagedata>
17
- <tw-passagedata pid="3" name="StoryTitle">Title</tw-passagedata>
18
17
  <tw-passagedata pid="4" name="Start">Content</tw-passagedata>
19
18
  </tw-storydata>
20
19
  <script>
@@ -9,11 +9,10 @@
9
9
  </head>
10
10
  <body>
11
11
  <tw-story tags></tw-story>
12
- <tw-storydata name="Name" startnode="3" creator="extwee" creator-version="2.0.3" ifid="16D0AFBA-80AF-4C7F-9C85-983D043624E4" zoom="0" format="Snowman" format-version="2.0.0" options hidden>
12
+ <tw-storydata name="Name" startnode="3" creator="extwee" creator-version="2.0.6" ifid="AD1FF443-CFE8-4651-99AD-FD9E1DCB0304" zoom="0" format="Snowman" format-version="2.0.0" options hidden>
13
13
  <style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>
14
14
  <script role="script" id="twine-user-script" type="text/twine-javascript"></script>
15
15
  <tw-passagedata pid="1" name="A"></tw-passagedata>
16
- <tw-passagedata pid="2" name="StoryTitle">Name</tw-passagedata>
17
16
  <tw-passagedata pid="3" name="Start">Content</tw-passagedata>
18
17
  </tw-storydata>
19
18
  <script>
@@ -38,10 +38,8 @@ describe('HTMLWriter', () => {
38
38
  // Parse HTML.
39
39
  const story2 = HTMLParser.parse(fr3);
40
40
 
41
- const s2Title = story2.getPassageByName('StoryTitle').text;
42
-
43
41
  // Test both names to be the same.
44
- expect(s1Title).toBe(s2Title);
42
+ expect(s1Title).toBe(story2.name);
45
43
  });
46
44
 
47
45
  it('Should write one and two-tag passages', () => {
@@ -2,7 +2,7 @@ import Passage from '../src/Passage.js';
2
2
 
3
3
  describe('Passage', () => {
4
4
  describe('#constructor()', () => {
5
- test('Set default values', () => {
5
+ it('Set default values', () => {
6
6
  const p = new Passage();
7
7
  expect(p.name).toBe('');
8
8
  expect(p.tags).toHaveLength(0);
@@ -13,13 +13,13 @@ describe('Passage', () => {
13
13
  });
14
14
 
15
15
  describe('name', () => {
16
- test('Set name', () => {
16
+ it('Set name', () => {
17
17
  const p = new Passage();
18
18
  p.name = 'New';
19
19
  expect(p.name).toBe('New');
20
20
  });
21
21
 
22
- test('Throw error if name is not String', () => {
22
+ it('Throw error if name is not String', () => {
23
23
  const p = new Passage();
24
24
  expect(() => {
25
25
  p.name = 1;
@@ -28,13 +28,13 @@ describe('Passage', () => {
28
28
  });
29
29
 
30
30
  describe('tags', () => {
31
- test('Set tags', () => {
31
+ it('Set tags', () => {
32
32
  const p = new Passage();
33
33
  p.tags = ['tag'];
34
34
  expect(p.tags).toHaveLength(1);
35
35
  });
36
36
 
37
- test('Throw error if tags is not Array', () => {
37
+ it('Throw error if tags is not Array', () => {
38
38
  const p = new Passage();
39
39
  expect(() => {
40
40
  p.tags = 1;
@@ -43,13 +43,13 @@ describe('Passage', () => {
43
43
  });
44
44
 
45
45
  describe('metadata', () => {
46
- test('Set metadata', () => {
46
+ it('Set metadata', () => {
47
47
  const p = new Passage();
48
48
  p.metadata = { position: '100,100' };
49
49
  expect(p.metadata).toEqual({ position: '100,100' });
50
50
  });
51
51
 
52
- test('Throw error if metadata is not an Object', () => {
52
+ it('Throw error if metadata is not an Object', () => {
53
53
  const p = new Passage();
54
54
  expect(() => {
55
55
  p.metadata = 1;
@@ -58,13 +58,13 @@ describe('Passage', () => {
58
58
  });
59
59
 
60
60
  describe('text', () => {
61
- test('Set text', () => {
61
+ it('Set text', () => {
62
62
  const p = new Passage();
63
63
  p.text = 'New';
64
64
  expect(p.text).toBe('New');
65
65
  });
66
66
 
67
- test('Throw error if text is not a String', () => {
67
+ it('Throw error if text is not a String', () => {
68
68
  const p = new Passage();
69
69
  expect(() => {
70
70
  p.text = 1;
@@ -73,13 +73,13 @@ describe('Passage', () => {
73
73
  });
74
74
 
75
75
  describe('pid', () => {
76
- test('Set PID', () => {
76
+ it('Set PID', () => {
77
77
  const p = new Passage();
78
78
  p.pid = 12;
79
79
  expect(p.pid).toBe(12);
80
80
  });
81
81
 
82
- test('Throw error if pid is not a Number', () => {
82
+ it('Throw error if pid is not a Number', () => {
83
83
  const p = new Passage();
84
84
  expect(() => {
85
85
  p.pid = [];
@@ -88,15 +88,15 @@ describe('Passage', () => {
88
88
  });
89
89
 
90
90
  describe('toString()', () => {
91
- test('Create name string', () => {
91
+ it('Create name string', () => {
92
92
  const p = new Passage('Name', 'Test');
93
93
  expect(p.toString()).toBe(':: Name\nTest\n\n');
94
94
  });
95
- test('Create tags string', () => {
95
+ it('Create tags string', () => {
96
96
  const p = new Passage('Name', 'Test', ['tags', 'another']);
97
97
  expect(p.toString()).toBe(':: Name [tags another]\nTest\n\n');
98
98
  });
99
- test('Create metadata string', () => {
99
+ it('Create metadata string', () => {
100
100
  const p = new Passage('Name', 'Test', ['tags', 'another'], { position: '100,100' });
101
101
  expect(p.toString()).toBe(':: Name [tags another] {"position":"100,100"}\nTest\n\n');
102
102
  });
@@ -0,0 +1,27 @@
1
+ :: StoryTitle
2
+ Example4
3
+
4
+ :: user[script]
5
+ console.log("Hi!");
6
+
7
+ :: user2[script]
8
+ console.log("Hi!");
9
+
10
+ :: style1[stylesheet]
11
+ body {
12
+ color: #ccc;
13
+ }
14
+
15
+ :: style2[stylesheet]
16
+ html {
17
+ color: #ccc;
18
+ }
19
+
20
+ :: Start
21
+ [[Another passage]]
22
+
23
+ :: Another passage
24
+ [[A third]]
25
+
26
+ :: A third
27
+ Double-click this passage to edit it.
@@ -11,12 +11,9 @@
11
11
 
12
12
  <tw-story></tw-story>
13
13
 
14
- <tw-storydata name="Example1" startnode="4" creator="extwee" creator-version="2.0.3" ifid="D37AFDA9-0C6C-434C-94F4-210A4E27AC4F" zoom="0" format="Harlowe" format-version="3.0.2" options hidden>
14
+ <tw-storydata name="Example1" startnode="4" creator="extwee" creator-version="2.0.6" ifid="BB4B4C20-2E2D-4283-B125-5550042AD3EB" zoom="0" format="Harlowe" format-version="3.0.2" options hidden>
15
15
  <style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>
16
16
  <script role="script" id="twine-user-script" type="text/twine-javascript"></script>
17
- <tw-passagedata pid="1" name="StoryTitle">Example1</tw-passagedata>
18
- <tw-passagedata pid="2" name="UserScript" tags="script" ></tw-passagedata>
19
- <tw-passagedata pid="3" name="UserStylesheet" tags="stylesheet" ></tw-passagedata>
20
17
  <tw-passagedata pid="4" name="Start">[[Another passage]]</tw-passagedata>
21
18
  <tw-passagedata pid="5" name="Another passage">[[A third]]</tw-passagedata>
22
19
  <tw-passagedata pid="6" name="A third">Double-click this passage to edit it.</tw-passagedata>
@@ -6,7 +6,7 @@ import StoryFormatParser from '../src/StoryFormatParser.js';
6
6
  import HTMLWriter from '../src/HTMLWriter.js';
7
7
 
8
8
  describe('Round-trip testing', () => {
9
- test('Should round-trip HTML-to-Twee', () => {
9
+ it('Should round-trip HTML-to-Twee', () => {
10
10
  // Read HTML
11
11
  const fr = FileReader.read('test/Roundtrip/Example1.html');
12
12
  // Parse HTML
@@ -23,7 +23,7 @@ describe('Round-trip testing', () => {
23
23
  expect(s.ifid).toBe(s2.ifid);
24
24
  });
25
25
 
26
- test('Should round-trip Twee-to-HTML', () => {
26
+ it('Should round-trip Twee-to-HTML', () => {
27
27
  // Read StoryFormat
28
28
  const storyFormat = FileReader.read('test/Roundtrip/harlowe.js');
29
29
  // Parse StoryFormat
@@ -7,7 +7,7 @@ import FileReader from '../src/FileReader.js';
7
7
  const { name, version } = JSON.parse(FileReader.read('package.json'));
8
8
 
9
9
  describe('Story', () => {
10
- describe('#constructor()', () => {
10
+ describe('#constructor()', () => {
11
11
  let s = null;
12
12
 
13
13
  beforeEach(() => {
@@ -23,7 +23,7 @@ describe('Story', () => {
23
23
  });
24
24
  });
25
25
 
26
- describe('creator', () => {
26
+ describe('creator', () => {
27
27
  let s = null;
28
28
 
29
29
  beforeEach(() => {
@@ -42,7 +42,7 @@ describe('Story', () => {
42
42
  });
43
43
  });
44
44
 
45
- describe('creatorVersion', () => {
45
+ describe('creatorVersion', () => {
46
46
  let s = null;
47
47
 
48
48
  beforeEach(() => {
@@ -61,7 +61,7 @@ describe('Story', () => {
61
61
  });
62
62
  });
63
63
 
64
- describe('IFID', () => {
64
+ describe('IFID', () => {
65
65
  let s = null;
66
66
 
67
67
  beforeEach(() => {
@@ -80,7 +80,7 @@ describe('Story', () => {
80
80
  });
81
81
  });
82
82
 
83
- describe('format', () => {
83
+ describe('format', () => {
84
84
  let s = null;
85
85
 
86
86
  beforeEach(() => {
@@ -99,7 +99,7 @@ describe('Story', () => {
99
99
  });
100
100
  });
101
101
 
102
- describe('formatVersion', () => {
102
+ describe('formatVersion', () => {
103
103
  let s = null;
104
104
 
105
105
  beforeEach(() => {
@@ -118,7 +118,7 @@ describe('Story', () => {
118
118
  });
119
119
  });
120
120
 
121
- describe('name', () => {
121
+ describe('name', () => {
122
122
  let s = null;
123
123
 
124
124
  beforeEach(() => {
@@ -137,7 +137,7 @@ describe('Story', () => {
137
137
  });
138
138
  });
139
139
 
140
- describe('zoom', () => {
140
+ describe('zoom', () => {
141
141
  let s = null;
142
142
 
143
143
  beforeEach(() => {
@@ -156,7 +156,7 @@ describe('Story', () => {
156
156
  });
157
157
  });
158
158
 
159
- describe('metadata', () => {
159
+ describe('metadata', () => {
160
160
  let s = null;
161
161
 
162
162
  beforeEach(() => {
@@ -175,7 +175,7 @@ describe('Story', () => {
175
175
  });
176
176
  });
177
177
 
178
- describe('start', () => {
178
+ describe('start', () => {
179
179
  let s = null;
180
180
 
181
181
  beforeEach(() => {
@@ -194,7 +194,7 @@ describe('Story', () => {
194
194
  });
195
195
  });
196
196
 
197
- describe('tagColors', () => {
197
+ describe('tagColors', () => {
198
198
  let s = null;
199
199
 
200
200
  beforeEach(() => {
@@ -216,7 +216,7 @@ describe('Story', () => {
216
216
  });
217
217
  });
218
218
 
219
- describe('addPassage()', () => {
219
+ describe('addPassage()', () => {
220
220
  let s = null;
221
221
 
222
222
  beforeEach(() => {
@@ -244,22 +244,22 @@ describe('Story', () => {
244
244
  });
245
245
  });
246
246
 
247
- describe('removePassage()', () => {
247
+ describe('removePassageByName()', () => {
248
248
  let s = null;
249
249
 
250
250
  beforeEach(() => {
251
251
  s = new Story();
252
252
  });
253
253
 
254
- it('removePassage() - should decrease size', () => {
254
+ it('removePassageByName() - should decrease size', () => {
255
255
  s.addPassage(new Passage('Find'));
256
256
  s.addPassage(new Passage('Find2'));
257
- s.removePassage('Find');
257
+ s.removePassageByName('Find');
258
258
  expect(s.size()).toBe(1);
259
259
  });
260
260
  });
261
261
 
262
- describe('getPassagesByTag()', () => {
262
+ describe('getPassagesByTag()', () => {
263
263
  let s = null;
264
264
 
265
265
  beforeEach(() => {
@@ -290,7 +290,7 @@ describe('Story', () => {
290
290
  });
291
291
  });
292
292
 
293
- describe('getPassageByName()', () => {
293
+ describe('getPassageByName()', () => {
294
294
  let s = null;
295
295
 
296
296
  beforeEach(() => {
@@ -305,7 +305,7 @@ describe('Story', () => {
305
305
  });
306
306
  });
307
307
 
308
- describe('getPassageByPID()', () => {
308
+ describe('getPassageByPID()', () => {
309
309
  let s = null;
310
310
 
311
311
  beforeEach(() => {
@@ -324,7 +324,7 @@ describe('Story', () => {
324
324
  });
325
325
  });
326
326
 
327
- describe('forEach()', () => {
327
+ describe('forEach()', () => {
328
328
  let s = null;
329
329
 
330
330
  beforeEach(() => {
@@ -346,9 +346,30 @@ describe('Story', () => {
346
346
  s.forEach(null);
347
347
  }).toThrow();
348
348
  });
349
+
350
+ it('forEach() - should ignore StoryTitle', () => {
351
+ let count = 0;
352
+ s.addPassage(new Passage('StoryTitle', 'Test'));
353
+ s.forEach(() => {count++});
354
+ expect(count).toBe(0);
355
+ });
356
+
357
+ it('forEach() - should ignore "script" tags', () => {
358
+ let count = 0;
359
+ s.addPassage(new Passage('Test', 'Test', ['script']));
360
+ s.forEach(() => {count++});
361
+ expect(count).toBe(0);
362
+ });
363
+
364
+ it('forEach() - should ignore "stylesheet" tags', () => {
365
+ let count = 0;
366
+ s.addPassage(new Passage('Test', 'Test', ['stylesheet']));
367
+ s.forEach(() => {count++});
368
+ expect(count).toBe(0);
369
+ });
349
370
  });
350
371
 
351
- describe('size()', () => {
372
+ describe('size()', () => {
352
373
  let s = null;
353
374
 
354
375
  beforeEach(() => {
@@ -365,5 +386,38 @@ describe('Story', () => {
365
386
  // Test size after adding one
366
387
  expect(s.size()).toBe(1);
367
388
  });
389
+
390
+ it('size() - should not count StoryTitle', () => {
391
+ // Create a Passage
392
+ const p = new Passage('StoryTitle', 'Test');
393
+ // Test initial size
394
+ expect(s.size()).toBe(0);
395
+ // Add a passage
396
+ s.addPassage(p);
397
+ // Test size after adding one
398
+ expect(s.size()).toBe(0);
399
+ });
400
+
401
+ it('size() - should not count script tags', () => {
402
+ // Create a Passage
403
+ const p = new Passage('Test', 'Test', ['script']);
404
+ // Test initial size
405
+ expect(s.size()).toBe(0);
406
+ // Add a passage
407
+ s.addPassage(p);
408
+ // Test size after adding one
409
+ expect(s.size()).toBe(0);
410
+ });
411
+
412
+ it('size() - should not count script tags', () => {
413
+ // Create a Passage
414
+ const p = new Passage('Test', 'Test', ['stylesheet']);
415
+ // Test initial size
416
+ expect(s.size()).toBe(0);
417
+ // Add a passage
418
+ s.addPassage(p);
419
+ // Test size after adding one
420
+ expect(s.size()).toBe(0);
421
+ });
368
422
  });
369
423
  });
@@ -1,8 +1,8 @@
1
1
  import StoryFormat from '../src/StoryFormat.js';
2
2
 
3
- describe('StoryFormat', function () {
4
- describe('#constructor()', function () {
5
- test('Should create default values', function () {
3
+ describe('StoryFormat', () => {
4
+ describe('#constructor()', () => {
5
+ it('Should create default values', () => {
6
6
  const sf = new StoryFormat();
7
7
  expect(sf.name).toBe('');
8
8
  expect(sf.version).toBe('');
@@ -15,14 +15,14 @@ describe('StoryFormat', function () {
15
15
  });
16
16
  });
17
17
 
18
- describe('name', function () {
19
- test('Set new String', function () {
18
+ describe('name', () => {
19
+ it('Set new String', () => {
20
20
  const sf = new StoryFormat();
21
21
  sf.name = 'New';
22
22
  expect(sf.name).toBe('New');
23
23
  });
24
24
 
25
- test('Throw error if non-String', function () {
25
+ it('Throw error if non-String', () => {
26
26
  const sf = new StoryFormat();
27
27
  expect(() => {
28
28
  sf.name = 1;
@@ -30,14 +30,14 @@ describe('StoryFormat', function () {
30
30
  });
31
31
  });
32
32
 
33
- describe('version', function () {
34
- test('Set new String', function () {
33
+ describe('version', () => {
34
+ it('Set new String', () => {
35
35
  const sf = new StoryFormat();
36
36
  sf.version = 'New';
37
37
  expect(sf.version).toBe('New');
38
38
  });
39
39
 
40
- test('Throw error if non-String', function () {
40
+ it('Throw error if non-String', () => {
41
41
  const sf = new StoryFormat();
42
42
  expect(() => {
43
43
  sf.version = 1;
@@ -45,14 +45,14 @@ describe('StoryFormat', function () {
45
45
  });
46
46
  });
47
47
 
48
- describe('author', function () {
49
- test('Set new String', function () {
48
+ describe('author', () => {
49
+ it('Set new String', () => {
50
50
  const sf = new StoryFormat();
51
51
  sf.author = 'New';
52
52
  expect(sf.author).toBe('New');
53
53
  });
54
54
 
55
- test('Throw error if non-String', function () {
55
+ it('Throw error if non-String', () => {
56
56
  const sf = new StoryFormat();
57
57
  expect(() => {
58
58
  sf.author = 1;
@@ -60,14 +60,14 @@ describe('StoryFormat', function () {
60
60
  });
61
61
  });
62
62
 
63
- describe('image', function () {
64
- test('Set new String', function () {
63
+ describe('image', () => {
64
+ it('Set new String', () => {
65
65
  const sf = new StoryFormat();
66
66
  sf.image = 'New';
67
67
  expect(sf.image).toBe('New');
68
68
  });
69
69
 
70
- test('Throw error if non-String', function () {
70
+ it('Throw error if non-String', () => {
71
71
  const sf = new StoryFormat();
72
72
  expect(() => {
73
73
  sf.image = 1;
@@ -75,14 +75,14 @@ describe('StoryFormat', function () {
75
75
  });
76
76
  });
77
77
 
78
- describe('url', function () {
79
- test('Set new String', function () {
78
+ describe('url', () => {
79
+ it('Set new String', () => {
80
80
  const sf = new StoryFormat();
81
81
  sf.url = 'New';
82
82
  expect(sf.url).toBe('New');
83
83
  });
84
84
 
85
- test('Throw error if non-String', function () {
85
+ it('Throw error if non-String', () => {
86
86
  const sf = new StoryFormat();
87
87
  expect(() => {
88
88
  sf.url = 1;
@@ -90,14 +90,14 @@ describe('StoryFormat', function () {
90
90
  });
91
91
  });
92
92
 
93
- describe('license', function () {
94
- test('Set new String', function () {
93
+ describe('license', () => {
94
+ it('Set new String', () => {
95
95
  const sf = new StoryFormat();
96
96
  sf.license = 'New';
97
97
  expect(sf.license).toBe('New');
98
98
  });
99
99
 
100
- test('Throw error if non-String', function () {
100
+ it('Throw error if non-String', () => {
101
101
  const sf = new StoryFormat();
102
102
  expect(() => {
103
103
  sf.license = 1;
@@ -105,14 +105,14 @@ describe('StoryFormat', function () {
105
105
  });
106
106
  });
107
107
 
108
- describe('proofing', function () {
109
- test('Set new String', function () {
108
+ describe('proofing', () => {
109
+ it('Set new String', () => {
110
110
  const sf = new StoryFormat();
111
111
  sf.proofing = true;
112
112
  expect(sf.proofing).toBe(true);
113
113
  });
114
114
 
115
- test('Throw error if non-String', function () {
115
+ it('Throw error if non-String', () => {
116
116
  const sf = new StoryFormat();
117
117
  expect(() => {
118
118
  sf.proofing = 1;
@@ -120,14 +120,14 @@ describe('StoryFormat', function () {
120
120
  });
121
121
  });
122
122
 
123
- describe('source', function () {
124
- test('Set new String', function () {
123
+ describe('source', () => {
124
+ it('Set new String', () => {
125
125
  const sf = new StoryFormat();
126
126
  sf.source = 'New';
127
127
  expect(sf.source).toBe('New');
128
128
  });
129
129
 
130
- test('Throw error if non-String', function () {
130
+ it('Throw error if non-String', () => {
131
131
  const sf = new StoryFormat();
132
132
  expect(() => {
133
133
  sf.source = 1;
@@ -135,14 +135,14 @@ describe('StoryFormat', function () {
135
135
  });
136
136
  });
137
137
 
138
- describe('description', function () {
139
- test('Set new String', function () {
138
+ describe('description', () => {
139
+ it('Set new String', () => {
140
140
  const sf = new StoryFormat();
141
141
  sf.description = 'New';
142
142
  expect(sf.description).toBe('New');
143
143
  });
144
144
 
145
- test('Throw error if non-String', function () {
145
+ it('Throw error if non-String', () => {
146
146
  const sf = new StoryFormat();
147
147
  expect(() => {
148
148
  sf.description = 1;