squiffy-runtime 6.0.0-alpha.1 → 6.0.0-alpha.10
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/dist/squiffy.runtime.d.ts +51 -0
- package/dist/squiffy.runtime.js +685 -0
- package/dist/squiffy.runtime.test.d.ts +1 -0
- package/dist/squiffy.runtime.test.js +308 -0
- package/package.json +20 -6
- package/src/__snapshots__/squiffy.runtime.test.ts.snap +114 -0
- package/src/squiffy.runtime.test.ts +391 -0
- package/src/squiffy.runtime.ts +217 -90
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { expect, test, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import globalJsdom from 'global-jsdom';
|
|
4
|
+
import { init } from './squiffy.runtime.js';
|
|
5
|
+
import { compile as squiffyCompile } from 'squiffy-compiler';
|
|
6
|
+
const html = `
|
|
7
|
+
<!DOCTYPE html>
|
|
8
|
+
<html>
|
|
9
|
+
<head>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="squiffy">
|
|
13
|
+
</div>
|
|
14
|
+
<div id="test">
|
|
15
|
+
</div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
18
|
+
`;
|
|
19
|
+
const compile = async (script) => {
|
|
20
|
+
const compileResult = await squiffyCompile({
|
|
21
|
+
scriptBaseFilename: "filename.squiffy", // TODO: This shouldn't be required
|
|
22
|
+
script: script,
|
|
23
|
+
});
|
|
24
|
+
if (!compileResult.success) {
|
|
25
|
+
throw new Error('Compile failed');
|
|
26
|
+
}
|
|
27
|
+
const story = compileResult.output.story;
|
|
28
|
+
const js = compileResult.output.js.map(jsLines => new Function('squiffy', 'get', 'set', jsLines.join('\n')));
|
|
29
|
+
return {
|
|
30
|
+
story: {
|
|
31
|
+
js: js,
|
|
32
|
+
...story,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const initScript = async (script) => {
|
|
37
|
+
globalJsdom(html);
|
|
38
|
+
const element = document.getElementById('squiffy');
|
|
39
|
+
if (!element) {
|
|
40
|
+
throw new Error('Element not found');
|
|
41
|
+
}
|
|
42
|
+
const compileResult = await compile(script);
|
|
43
|
+
const squiffyApi = init({
|
|
44
|
+
element: element,
|
|
45
|
+
story: compileResult.story,
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
squiffyApi,
|
|
49
|
+
element
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const findLink = (element, linkType, linkText, onlyEnabled = false) => {
|
|
53
|
+
const links = onlyEnabled
|
|
54
|
+
? element.querySelectorAll(`.squiffy-output-section:last-child a.squiffy-link.link-${linkType}`)
|
|
55
|
+
: element.querySelectorAll(`a.squiffy-link.link-${linkType}`);
|
|
56
|
+
return Array.from(links).find(link => link.textContent === linkText && (onlyEnabled ? !link.classList.contains("disabled") : true));
|
|
57
|
+
};
|
|
58
|
+
const getTestOutput = () => {
|
|
59
|
+
const testElement = document.getElementById('test');
|
|
60
|
+
if (!testElement) {
|
|
61
|
+
throw new Error('Test element not found');
|
|
62
|
+
}
|
|
63
|
+
return testElement.innerText;
|
|
64
|
+
};
|
|
65
|
+
let cleanup;
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
cleanup = globalJsdom();
|
|
68
|
+
});
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
cleanup();
|
|
71
|
+
});
|
|
72
|
+
test('"Hello world" script should run', async () => {
|
|
73
|
+
const { element } = await initScript("Hello world");
|
|
74
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
test('Click a section link', async () => {
|
|
77
|
+
const script = await fs.readFile('../examples/test/example.squiffy', 'utf-8');
|
|
78
|
+
const { squiffyApi, element } = await initScript(script);
|
|
79
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
80
|
+
expect(element.querySelectorAll('a.squiffy-link').length).toBe(10);
|
|
81
|
+
const linkToPassage = findLink(element, 'passage', 'a link to a passage');
|
|
82
|
+
const section3Link = findLink(element, 'section', 'section 3');
|
|
83
|
+
expect(linkToPassage).not.toBeNull();
|
|
84
|
+
expect(section3Link).not.toBeNull();
|
|
85
|
+
expect(linkToPassage.classList).not.toContain('disabled');
|
|
86
|
+
const handled = squiffyApi.clickLink(section3Link);
|
|
87
|
+
expect(handled).toBe(true);
|
|
88
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
89
|
+
// passage link is from the previous section, so should be unclickable
|
|
90
|
+
expect(squiffyApi.clickLink(linkToPassage)).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
test('Click a passage link', async () => {
|
|
93
|
+
const script = await fs.readFile('../examples/test/example.squiffy', 'utf-8');
|
|
94
|
+
const { squiffyApi, element } = await initScript(script);
|
|
95
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
96
|
+
expect(element.querySelectorAll('a.squiffy-link').length).toBe(10);
|
|
97
|
+
const linkToPassage = findLink(element, 'passage', 'a link to a passage');
|
|
98
|
+
const section3Link = findLink(element, 'section', 'section 3');
|
|
99
|
+
expect(linkToPassage).not.toBeNull();
|
|
100
|
+
expect(section3Link).not.toBeNull();
|
|
101
|
+
expect(linkToPassage.classList).not.toContain('disabled');
|
|
102
|
+
const handled = squiffyApi.clickLink(linkToPassage);
|
|
103
|
+
expect(handled).toBe(true);
|
|
104
|
+
expect(linkToPassage.classList).toContain('disabled');
|
|
105
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
106
|
+
// shouldn't be able to click it again
|
|
107
|
+
expect(squiffyApi.clickLink(linkToPassage)).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
test('Run JavaScript functions', async () => {
|
|
110
|
+
const script = `
|
|
111
|
+
document.getElementById('test').innerText = 'Initial JavaScript';
|
|
112
|
+
@set some_string = some_value
|
|
113
|
+
@set some_number = 5
|
|
114
|
+
|
|
115
|
+
+++Continue...
|
|
116
|
+
document.getElementById('test').innerText = "Value: " + get("some_number");
|
|
117
|
+
+++Continue...
|
|
118
|
+
document.getElementById('test').innerText = "Value: " + get("some_string");
|
|
119
|
+
set("some_number", 10);
|
|
120
|
+
+++Continue...
|
|
121
|
+
document.getElementById('test').innerText = "Value: " + get("some_number");
|
|
122
|
+
+++Continue...
|
|
123
|
+
@inc some_number
|
|
124
|
+
+++Continue...
|
|
125
|
+
document.getElementById('test').innerText = "Value: " + get("some_number");
|
|
126
|
+
+++Continue...
|
|
127
|
+
squiffy.story.go("other section");
|
|
128
|
+
[[other section]]:
|
|
129
|
+
document.getElementById('test').innerText = "In other section";
|
|
130
|
+
`;
|
|
131
|
+
const clickContinue = () => {
|
|
132
|
+
const continueLink = findLink(element, 'section', 'Continue...', true);
|
|
133
|
+
expect(continueLink).not.toBeNull();
|
|
134
|
+
const handled = squiffyApi.clickLink(continueLink);
|
|
135
|
+
expect(handled).toBe(true);
|
|
136
|
+
};
|
|
137
|
+
const { squiffyApi, element } = await initScript(script);
|
|
138
|
+
expect(getTestOutput()).toBe('Initial JavaScript');
|
|
139
|
+
clickContinue();
|
|
140
|
+
expect(getTestOutput()).toBe('Value: 5');
|
|
141
|
+
clickContinue();
|
|
142
|
+
expect(getTestOutput()).toBe('Value: some_value');
|
|
143
|
+
clickContinue();
|
|
144
|
+
expect(getTestOutput()).toBe('Value: 10');
|
|
145
|
+
clickContinue();
|
|
146
|
+
clickContinue();
|
|
147
|
+
expect(getTestOutput()).toBe('Value: 11');
|
|
148
|
+
clickContinue();
|
|
149
|
+
expect(getTestOutput()).toBe('In other section');
|
|
150
|
+
});
|
|
151
|
+
function safeQuerySelector(name) {
|
|
152
|
+
return name.replace(/'/g, "\\'");
|
|
153
|
+
}
|
|
154
|
+
function getSectionContent(element, section) {
|
|
155
|
+
return element.querySelector(`[data-source='[[${safeQuerySelector(section)}]]'] p`)?.textContent || null;
|
|
156
|
+
}
|
|
157
|
+
function getPassageContent(element, section, passage) {
|
|
158
|
+
return element.querySelector(`[data-source='[[${safeQuerySelector(section)}]][${safeQuerySelector(passage)}]'] p`)?.textContent || null;
|
|
159
|
+
}
|
|
160
|
+
test('Update default section output', async () => {
|
|
161
|
+
const { squiffyApi, element } = await initScript("Hello world");
|
|
162
|
+
let defaultOutput = getSectionContent(element, '_default');
|
|
163
|
+
expect(defaultOutput).toBe('Hello world');
|
|
164
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
165
|
+
const updated = await compile("Updated content");
|
|
166
|
+
squiffyApi.update(updated.story);
|
|
167
|
+
defaultOutput = getSectionContent(element, '_default');
|
|
168
|
+
expect(defaultOutput).toBe('Updated content');
|
|
169
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
170
|
+
});
|
|
171
|
+
test.each(['a', 'a\'1'])('Update passage output - passage name "%s"', async (name) => {
|
|
172
|
+
const { squiffyApi, element } = await initScript(`Click this: [${name}]
|
|
173
|
+
|
|
174
|
+
[${name}]:
|
|
175
|
+
Passage a content`);
|
|
176
|
+
const link = findLink(element, 'passage', name);
|
|
177
|
+
const handled = squiffyApi.clickLink(link);
|
|
178
|
+
expect(handled).toBe(true);
|
|
179
|
+
let defaultOutput = getSectionContent(element, '_default');
|
|
180
|
+
expect(defaultOutput).toBe(`Click this: ${name}`);
|
|
181
|
+
let passageOutput = getPassageContent(element, '_default', name);
|
|
182
|
+
expect(passageOutput).toBe('Passage a content');
|
|
183
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
184
|
+
const updated = await compile(`Click this: [${name}]
|
|
185
|
+
|
|
186
|
+
[${name}]:
|
|
187
|
+
Updated passage content`);
|
|
188
|
+
squiffyApi.update(updated.story);
|
|
189
|
+
defaultOutput = getSectionContent(element, '_default');
|
|
190
|
+
expect(defaultOutput).toBe(`Click this: ${name}`);
|
|
191
|
+
passageOutput = getPassageContent(element, '_default', name);
|
|
192
|
+
expect(passageOutput).toBe('Updated passage content');
|
|
193
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
194
|
+
});
|
|
195
|
+
test('Delete section', async () => {
|
|
196
|
+
const { squiffyApi, element } = await initScript(`Click this: [[a]]
|
|
197
|
+
|
|
198
|
+
[[a]]:
|
|
199
|
+
New section`);
|
|
200
|
+
const link = findLink(element, 'section', 'a');
|
|
201
|
+
const handled = squiffyApi.clickLink(link);
|
|
202
|
+
expect(handled).toBe(true);
|
|
203
|
+
let defaultOutput = getSectionContent(element, '_default');
|
|
204
|
+
expect(defaultOutput).toBe('Click this: a');
|
|
205
|
+
let sectionOutput = getSectionContent(element, 'a');
|
|
206
|
+
expect(sectionOutput).toBe('New section');
|
|
207
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
208
|
+
const updated = await compile(`Click this: [[a]]`);
|
|
209
|
+
squiffyApi.update(updated.story);
|
|
210
|
+
defaultOutput = getSectionContent(element, '_default');
|
|
211
|
+
expect(defaultOutput).toBe('Click this: a');
|
|
212
|
+
sectionOutput = getSectionContent(element, 'a');
|
|
213
|
+
expect(sectionOutput).toBeNull();
|
|
214
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
215
|
+
});
|
|
216
|
+
test('Delete passage', async () => {
|
|
217
|
+
const { squiffyApi, element } = await initScript(`Click this: [a]
|
|
218
|
+
|
|
219
|
+
[a]:
|
|
220
|
+
New passage`);
|
|
221
|
+
const link = findLink(element, 'passage', 'a');
|
|
222
|
+
const handled = squiffyApi.clickLink(link);
|
|
223
|
+
expect(handled).toBe(true);
|
|
224
|
+
let defaultOutput = getSectionContent(element, '_default');
|
|
225
|
+
expect(defaultOutput).toBe('Click this: a');
|
|
226
|
+
let passageOutput = getPassageContent(element, '_default', 'a');
|
|
227
|
+
expect(passageOutput).toBe('New passage');
|
|
228
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
229
|
+
const updated = await compile(`Click this: [a]`);
|
|
230
|
+
squiffyApi.update(updated.story);
|
|
231
|
+
defaultOutput = getSectionContent(element, '_default');
|
|
232
|
+
expect(defaultOutput).toBe('Click this: a');
|
|
233
|
+
passageOutput = getPassageContent(element, '_default', 'a');
|
|
234
|
+
expect(passageOutput).toBeNull();
|
|
235
|
+
expect(element.innerHTML).toMatchSnapshot();
|
|
236
|
+
});
|
|
237
|
+
test('Clicked passage links remain disabled after an update', async () => {
|
|
238
|
+
const { squiffyApi, element } = await initScript(`Click one of these: [a] [b]
|
|
239
|
+
|
|
240
|
+
[a]:
|
|
241
|
+
Output for passage A.
|
|
242
|
+
|
|
243
|
+
[b]:
|
|
244
|
+
Output for passage B.`);
|
|
245
|
+
// click linkA
|
|
246
|
+
let linkA = findLink(element, 'passage', 'a');
|
|
247
|
+
expect(linkA.classList).not.toContain('disabled');
|
|
248
|
+
expect(squiffyApi.clickLink(linkA)).toBe(true);
|
|
249
|
+
const updated = await compile(`Click one of these (updated): [a] [b]
|
|
250
|
+
|
|
251
|
+
[a]:
|
|
252
|
+
Output for passage A.
|
|
253
|
+
|
|
254
|
+
[b]:
|
|
255
|
+
Output for passage B.`);
|
|
256
|
+
squiffyApi.update(updated.story);
|
|
257
|
+
// linkA should still be disabled
|
|
258
|
+
linkA = findLink(element, 'passage', 'a');
|
|
259
|
+
expect(linkA.classList).toContain('disabled');
|
|
260
|
+
expect(squiffyApi.clickLink(linkA)).toBe(false);
|
|
261
|
+
// linkB should still be enabled
|
|
262
|
+
let linkB = findLink(element, 'passage', 'b');
|
|
263
|
+
expect(linkB.classList).not.toContain('disabled');
|
|
264
|
+
expect(squiffyApi.clickLink(linkB)).toBe(true);
|
|
265
|
+
});
|
|
266
|
+
test('Deleting the current section activates the previous section', async () => {
|
|
267
|
+
const { squiffyApi, element } = await initScript(`Choose a section: [[a]] [[b]], or passage [start1].
|
|
268
|
+
|
|
269
|
+
[start1]:
|
|
270
|
+
Output for passage start1.
|
|
271
|
+
|
|
272
|
+
[[a]]:
|
|
273
|
+
Output for section A.
|
|
274
|
+
|
|
275
|
+
[[b]]:
|
|
276
|
+
Output for section B.`);
|
|
277
|
+
// click linkA
|
|
278
|
+
let linkA = findLink(element, 'section', 'a');
|
|
279
|
+
let linkB = findLink(element, 'section', 'b');
|
|
280
|
+
expect(linkA.classList).not.toContain('disabled');
|
|
281
|
+
expect(squiffyApi.clickLink(linkA)).toBe(true);
|
|
282
|
+
// can't click start1 passage as we're in section [[a]] now
|
|
283
|
+
let linkStart1 = findLink(element, 'passage', 'start1');
|
|
284
|
+
expect(squiffyApi.clickLink(linkStart1)).toBe(false);
|
|
285
|
+
// can't click linkB as we're in section [[a]] now
|
|
286
|
+
expect(squiffyApi.clickLink(linkB)).toBe(false);
|
|
287
|
+
// now we delete section [[a]]
|
|
288
|
+
const updated = await compile(`Choose a section: [[a]] [[b]], or passage [start1].
|
|
289
|
+
|
|
290
|
+
[start1]:
|
|
291
|
+
Output for passage start1.
|
|
292
|
+
|
|
293
|
+
[[b]]:
|
|
294
|
+
Output for section B. Here's a passage: [b1].
|
|
295
|
+
|
|
296
|
+
[b1]:
|
|
297
|
+
Passage in section B.`);
|
|
298
|
+
squiffyApi.update(updated.story);
|
|
299
|
+
// We're in the first section, so the start1 passage should be clickable now
|
|
300
|
+
linkStart1 = findLink(element, 'passage', 'start1');
|
|
301
|
+
expect(squiffyApi.clickLink(linkStart1)).toBe(true);
|
|
302
|
+
// We're in the first section, so linkB should be clickable now
|
|
303
|
+
linkB = findLink(element, 'section', 'b');
|
|
304
|
+
expect(squiffyApi.clickLink(linkB)).toBe(true);
|
|
305
|
+
// and the passage [b1] within it should be clickable
|
|
306
|
+
const linkB1 = findLink(element, 'passage', 'b1');
|
|
307
|
+
expect(squiffyApi.clickLink(linkB1)).toBe(true);
|
|
308
|
+
});
|
package/package.json
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squiffy-runtime",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
4
|
-
"
|
|
3
|
+
"version": "6.0.0-alpha.10",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/squiffy.runtime.js",
|
|
6
|
+
"types": "dist/squiffy.runtime.d.ts",
|
|
5
7
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
+
"dev": "vitest",
|
|
9
|
+
"test": "vitest --run",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"prepublishOnly": "npm run build && npm run test"
|
|
8
12
|
},
|
|
9
13
|
"author": "Alex Warren",
|
|
14
|
+
"contributors": [
|
|
15
|
+
"CrisisSDK",
|
|
16
|
+
"mrangel",
|
|
17
|
+
"Luis Felipe Morales"
|
|
18
|
+
],
|
|
10
19
|
"license": "MIT",
|
|
11
20
|
"description": "",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/jsdom": "^21.1.7",
|
|
23
|
+
"global-jsdom": "^25.0.0",
|
|
24
|
+
"jsdom": "^25.0.0",
|
|
25
|
+
"squiffy-compiler": "^6.0.0-alpha.2",
|
|
26
|
+
"typescript": "^5.6.2",
|
|
27
|
+
"vitest": "^2.1.1"
|
|
14
28
|
}
|
|
15
29
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`"Hello world" script should run 1`] = `
|
|
4
|
+
"
|
|
5
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div>"
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
exports[`Click a passage link 1`] = `
|
|
9
|
+
"
|
|
10
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="Introduction"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
11
|
+
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
12
|
+
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
13
|
+
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
14
|
+
<p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
|
|
15
|
+
<p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
|
|
16
|
+
<p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
|
|
17
|
+
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div></div>"
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`Click a passage link 2`] = `
|
|
21
|
+
"
|
|
22
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="Introduction"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
23
|
+
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
24
|
+
<p>This should be <a class="squiffy-link link-passage disabled" data-passage="passage" role="link" tabindex="-1">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
25
|
+
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
26
|
+
<p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
|
|
27
|
+
<p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
|
|
28
|
+
<p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
|
|
29
|
+
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div><div class="squiffy-output-block"><div data-source="[[Introduction]][passage]"><p>Here's some text for the passage.</p></div></div></div>"
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
exports[`Click a section link 1`] = `
|
|
33
|
+
"
|
|
34
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="Introduction"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
35
|
+
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
36
|
+
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
37
|
+
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
38
|
+
<p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
|
|
39
|
+
<p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
|
|
40
|
+
<p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
|
|
41
|
+
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div></div>"
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
exports[`Click a section link 2`] = `
|
|
45
|
+
"
|
|
46
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="Introduction"><div class="squiffy-output-block"><div data-source="[[Introduction]]"><h1>Squiffy Test</h1>
|
|
47
|
+
<p>This is <a href="http://textadventures.co.uk">a website link</a>.</p>
|
|
48
|
+
<p>This should be <a class="squiffy-link link-passage" data-passage="passage" role="link" tabindex="0">a link to a passage</a>. Here's <a class="squiffy-link link-passage" data-passage="passage2" role="link" tabindex="0">another one</a>.</p>
|
|
49
|
+
<p>You don't need to specify a name - for example, this <a class="squiffy-link link-passage" data-passage="link" role="link" tabindex="0">link</a> and this <a class="squiffy-link link-section" data-section="section" role="link" tabindex="0">section</a>.</p>
|
|
50
|
+
<p>And this goes to the <a class="squiffy-link link-section" data-section="section2" role="link" tabindex="0">next section</a>.</p>
|
|
51
|
+
<p>This line has links to <a class="squiffy-link link-section" data-section="section 3" role="link" tabindex="0">section 3</a> and <a class="squiffy-link link-section" data-section="section four" role="link" tabindex="0">section 4</a>.</p>
|
|
52
|
+
<p>This line has links to <a class="squiffy-link link-passage" data-passage="passage 3" role="link" tabindex="0">passage 3</a> and <a class="squiffy-link link-passage" data-passage="passage four" role="link" tabindex="0">passage 4</a>.</p>
|
|
53
|
+
<p>Oh look - <a class="squiffy-link link-passage" data-passage="it's a passage with an apostrophe" role="link" tabindex="0">it's a passage with an apostrophe</a>.</p></div></div></div><div class="squiffy-output-section" id="squiffy-section-2" data-section="section 3"><div class="squiffy-output-block"><div data-source="[[section 3]]"><p>Another section is here, with passages <a class="squiffy-link link-passage" data-passage="a" role="link" tabindex="0">a</a> and <a class="squiffy-link link-passage" data-passage="b" role="link" tabindex="0">b</a>.</p></div></div></div>"
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
exports[`Delete passage 1`] = `
|
|
57
|
+
"
|
|
58
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>New passage</p></div></div></div>"
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
exports[`Delete passage 2`] = `
|
|
62
|
+
"
|
|
63
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div></div>"
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
exports[`Delete section 1`] = `
|
|
67
|
+
"
|
|
68
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div><div class="squiffy-output-section" id="squiffy-section-2" data-section="a"><div class="squiffy-output-block"><div data-source="[[a]]"><p>New section</p></div></div></div>"
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
exports[`Delete section 2`] = `
|
|
72
|
+
"
|
|
73
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-section" data-section="a" role="link" tabindex="0">a</a></p></div></div></div>"
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
exports[`Update default section output 1`] = `
|
|
77
|
+
"
|
|
78
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Hello world</p></div></div></div>"
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
exports[`Update default section output 2`] = `
|
|
82
|
+
"
|
|
83
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Updated content</p></div></div></div>"
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`Update passage output - passage name "a" 1`] = `
|
|
87
|
+
"
|
|
88
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Passage a content</p></div></div></div>"
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
exports[`Update passage output - passage name "a" 2`] = `
|
|
92
|
+
"
|
|
93
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Updated passage content</p></div></div></div>"
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
exports[`Update passage output - passage name "a'1" 1`] = `
|
|
97
|
+
"
|
|
98
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Passage a content</p></div></div></div>"
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
exports[`Update passage output - passage name "a'1" 2`] = `
|
|
102
|
+
"
|
|
103
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a'1" role="link" tabindex="-1">a'1</a></p></div></div><div class="squiffy-output-block"><div data-source="[[_default]][a'1]"><p>Updated passage content</p></div></div></div>"
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
exports[`Update passage output 1`] = `
|
|
107
|
+
"
|
|
108
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Passage a content</p></div></div></div>"
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
exports[`Update passage output 2`] = `
|
|
112
|
+
"
|
|
113
|
+
<div class="squiffy-output-section" id="squiffy-section-1" data-section="_default"><div class="squiffy-output-block"><div data-source="[[_default]]"><p>Click this: <a class="squiffy-link link-passage disabled" data-passage="a" role="link" tabindex="-1">a</a></p></div></div><div class="squiffy-output-block"><div data-source="[[_default]][a]"><p>Updated passage content</p></div></div></div>"
|
|
114
|
+
`;
|