-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c448ee
commit 532ab83
Showing
39 changed files
with
668 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
text: true, | ||
inlineCode: true, | ||
link: true, | ||
image: true, | ||
imageReference: true, | ||
definition: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
|
||
const defaults = require("./defaults"); | ||
|
||
module.exports = (options) => { | ||
let mixed = Object.assign({}, defaults); | ||
for (const key in options) { | ||
if (typeof options[key] === "boolean") mixed[key] = options[key]; | ||
} | ||
|
||
return mixed; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
'use strict' | ||
"use strict"; | ||
|
||
const fs = require('fs') | ||
const { extname } = require('path') | ||
const unified = require('unified') | ||
const parse = require('remark-parse') | ||
const stringify = require('remark-stringify') | ||
const frontmatter = require('remark-frontmatter') | ||
const footnotes = require('remark-footnotes') | ||
const pangu = require('../index') | ||
const fs = require("fs"); | ||
const { extname } = require("path"); | ||
const unified = require("unified"); | ||
const parse = require("remark-parse"); | ||
const stringify = require("remark-stringify"); | ||
const frontmatter = require("remark-frontmatter"); | ||
const footnotes = require("remark-footnotes"); | ||
const pangu = require("../index"); | ||
|
||
const processor = unified() | ||
.use(parse, { footnotes: true }) | ||
.use(stringify) | ||
.use(frontmatter) | ||
.use(footnotes, {inlineNotes: true}) | ||
.use(pangu) | ||
.freeze() | ||
|
||
function formatAsync(source) { | ||
return processor.process(source) | ||
} | ||
const createProcessor = function (options) { | ||
return unified() | ||
.use(parse, { footnotes: true }) | ||
.use(stringify) | ||
.use(frontmatter) | ||
.use(footnotes, { inlineNotes: true }) | ||
.use(pangu, options) | ||
.freeze(); | ||
}; | ||
|
||
function raw(string) { | ||
if (typeof string !== 'string') { | ||
throw new Error('Raw snapshots have to be strings.') | ||
if (typeof string !== "string") { | ||
throw new Error("Raw snapshots have to be strings."); | ||
} | ||
return { [Symbol.for('raw')]: string } | ||
return { [Symbol.for("raw")]: string }; | ||
} | ||
|
||
function runSpec(dirname) { | ||
fs.readdirSync(dirname).forEach(filename => { | ||
const path = dirname + '/' + filename | ||
function runSpec(dirname, options) { | ||
fs.readdirSync(dirname).forEach((filename) => { | ||
const path = dirname + "/" + filename; | ||
if ( | ||
extname(filename) !== '.snap' && | ||
extname(filename) !== ".snap" && | ||
fs.lstatSync(path).isFile() && | ||
filename !== 'run.spec.js' | ||
filename !== "run.spec.js" | ||
) { | ||
const source = fs.readFileSync(path) | ||
test(`${filename}`, () => { | ||
return formatAsync(source).then(vfile => { | ||
const output = String(vfile) | ||
return expect( | ||
raw(source + '~'.repeat(80) + '\n' + output), | ||
).toMatchSnapshot(filename) | ||
}) | ||
}) | ||
const source = fs.readFileSync(path); | ||
test(`${filename} with options: ${JSON.stringify(options)}`, () => { | ||
return createProcessor(options) | ||
.process(source) | ||
.then((vfile) => { | ||
const output = String(vfile); | ||
return expect( | ||
raw(source + "~".repeat(80) + "\n" + output) | ||
).toMatchSnapshot(filename); | ||
}); | ||
}); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
global.runSpec = runSpec | ||
global.runSpec = runSpec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
runSpec(__dirname) | ||
runSpec(__dirname, { | ||
text: false | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
runSpec(__dirname) | ||
runSpec(__dirname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
runSpec(__dirname) | ||
runSpec(__dirname, { | ||
definition: false | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
runSpec(__dirname) | ||
runSpec(__dirname, { | ||
text: false | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
runSpec(__dirname) | ||
runSpec(__dirname) | ||
runSpec(__dirname, { | ||
text: false | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
runSpec(__dirname) | ||
runSpec(__dirname, { | ||
text: false | ||
}) |
Oops, something went wrong.