-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from iamstarkov/docs/cli
Readme-driven development.
- Loading branch information
Showing
3 changed files
with
64 additions
and
69 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
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,46 +1,27 @@ | ||
import { equal } from 'assert'; | ||
import mdast from 'mdast'; | ||
import mdastTextr from './index'; | ||
import base from 'typographic-base'; | ||
|
||
const t = (text, mdastOptions) => | ||
mdast() | ||
.use(mdastTextr, mdastOptions) | ||
.process(text) | ||
.trim(); | ||
// textr plugin — just function to replace triple dots to ellipses | ||
const ellipses = input => input.replace(/\.{3}/gim, '…'); | ||
|
||
describe('mdast-textr', () => { | ||
const text = ` | ||
## spread operator... | ||
it('should return original text', () => | ||
equal(t(`Hello, "world"...`), `Hello, "world"...`) | ||
); | ||
function(...args) { return args; } | ||
`; | ||
|
||
it('should return transformed text', () => | ||
equal( | ||
t(`Hello, "world"...`, { | ||
plugins: [ base ] | ||
}), | ||
`Hello, “world”…` | ||
) | ||
); | ||
it('should mdastTextr in node', () => | ||
equal( | ||
mdast.use(mdastTextr, { plugins: [ ellipses ] }).process(text), | ||
`## spread operator… | ||
it('should require strings', () => | ||
equal( | ||
t(`Hello, "world"...`, { | ||
plugins: [ 'typographic-ellipses' ] | ||
}), | ||
`Hello, "world"…` | ||
) | ||
); | ||
function(...args) { return args; } | ||
`)); | ||
|
||
it('should load options', () => | ||
equal( | ||
t(`"quotes"`, { | ||
plugins: [ base ], | ||
options: { locale: 'uk' } | ||
}), | ||
`«quotes»` | ||
) | ||
); | ||
|
||
}); | ||
it('should mdastTextr in CLI (with options)', () => | ||
equal(mdast.use(mdastTextr, { | ||
plugins: [ 'typographic-ellipses', 'typographic-quotes' ], | ||
options: { locale: 'ru' } | ||
}).process('yo "there" ...\n'), 'yo «there» …\n') | ||
); |