Skip to content

Commit 7b91b5e

Browse files
committed
Simplify code and fix tests
1 parent ced8d0a commit 7b91b5e

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

lib/graphgists/asciidoc-preprocessing.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function preprocessing(asciidoc) {
3636
let currentSourceBlockDefinition = {}
3737
let currentRoles = []
3838
const updateMap = {}
39-
lines
39+
return lines
4040
.map((line, index) => {
4141
if (line.startsWith('[source,cypher') && line.trim().endsWith(']')) {
4242
const blockDefintionWithRoles = addRolesInBlockDefinition(line, ['runnable', 'backend:graphgist', ...currentRoles])
@@ -68,8 +68,8 @@ function preprocessing(asciidoc) {
6868
return updateMap[index]
6969
}
7070
return line
71-
}) = lines
72-
return lines.join('\n')
71+
})
72+
.join('\n')
7373
}
7474

7575
module.exports = {

specs/graphgist-asciidoc-preprocessing.spec.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,29 @@ query
180180
181181
//setup
182182
// hide
183-
[source,cypher,role="foo bar runnable backend:graphgist instant hidden"]
183+
[source,cypher,role="foo bar runnable backend:graphgist instant single hidden"]
184+
----
185+
query
186+
----
187+
`)
188+
})
189+
it('should add single role on Cypher source block when // setup is present', async () => {
190+
const result = preprocessing(`= Title
191+
192+
== Section
193+
194+
//setup
195+
[source,cypher,role="foo bar"]
196+
----
197+
query
198+
----
199+
`)
200+
expect(result).to.equal(`= Title
201+
202+
== Section
203+
204+
//setup
205+
[source,cypher,role="foo bar runnable backend:graphgist instant single"]
184206
----
185207
query
186208
----

0 commit comments

Comments
 (0)