This repository has been archived by the owner on Nov 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
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 #180 from jamesramsay/optional-args
Fix: sync API incorrectly required `relativePath` option (fixes #178)
- Loading branch information
Showing
9 changed files
with
254 additions
and
103 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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import test from 'ava'; | ||
import path from 'path'; | ||
|
||
import { transcludeFile } from '../../lib/hercule'; | ||
|
||
test.cb(`should transclude with only required arguments`, (t) => { | ||
const input = path.join(__dirname, '../fixtures/no-link/index.md'); | ||
const expected = 'The quick brown fox jumps over the lazy dog.\n'; | ||
transcludeFile(input, (output) => { | ||
t.same(output, expected); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test.cb(`should transclude with optional relativePath argument`, (t) => { | ||
const input = path.join(__dirname, '../fixtures/no-link/index.md'); | ||
const expected = 'The quick brown fox jumps over the lazy dog.\n'; | ||
transcludeFile(input, { relativePath: 'test' }, (output) => { | ||
t.same(output, expected); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test.cb(`should transclude with optional log handler`, (t) => { | ||
const input = path.join(__dirname, '../fixtures/no-link/index.md'); | ||
const expected = 'The quick brown fox jumps over the lazy dog.\n'; | ||
const logger = { | ||
error: () => t.fail(), | ||
warn: () => t.fail(), | ||
}; | ||
transcludeFile(input, null, logger, (output) => { | ||
t.same(output, expected); | ||
t.end(); | ||
}); | ||
}); |
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,40 @@ | ||
import test from 'ava'; | ||
import path from 'path'; | ||
|
||
import { transcludeFileSync } from '../../lib/hercule'; | ||
|
||
let major; | ||
let minor; | ||
|
||
[major, minor] = process.versions.node.split('.'); | ||
|
||
if (major < 1 && minor < 12) { | ||
test.only(`synchronous support not available < 0.12`, (t) => { | ||
t.pass(); | ||
}); | ||
} | ||
|
||
test(`should transclude with only required arguments`, (t) => { | ||
const input = path.join(__dirname, '../fixtures/no-link/index.md'); | ||
const expected = 'The quick brown fox jumps over the lazy dog.\n'; | ||
const output = transcludeFileSync(input); | ||
t.same(output, expected); | ||
}); | ||
|
||
test(`should transclude with optional relativePath argument`, (t) => { | ||
const input = path.join(__dirname, '../fixtures/no-link/index.md'); | ||
const expected = 'The quick brown fox jumps over the lazy dog.\n'; | ||
const output = transcludeFileSync(input, { relativePath: 'test' }); | ||
t.same(output, expected); | ||
}); | ||
|
||
test(`should transclude with optional log handler`, (t) => { | ||
const input = path.join(__dirname, '../fixtures/no-link/index.md'); | ||
const expected = 'The quick brown fox jumps over the lazy dog.\n'; | ||
const logger = { | ||
error: () => t.fail(), | ||
warn: () => t.fail(), | ||
}; | ||
const output = transcludeFileSync(input, null, logger); | ||
t.same(output, expected); | ||
}); |
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,34 @@ | ||
import test from 'ava'; | ||
|
||
import { transcludeString } from '../../lib/hercule'; | ||
|
||
test.cb(`should transclude with only required arguments`, (t) => { | ||
const input = 'The quick brown fox jumps over the lazy dog.'; | ||
const expected = 'The quick brown fox jumps over the lazy dog.'; | ||
transcludeString(input, (output) => { | ||
t.same(output, expected); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test.cb(`should transclude with optional relativePath argument`, (t) => { | ||
const input = 'The quick brown fox jumps over the lazy dog.'; | ||
const expected = 'The quick brown fox jumps over the lazy dog.'; | ||
transcludeString(input, { relativePath: 'test' }, (output) => { | ||
t.same(output, expected); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
test.cb(`should transclude with optional log handler`, (t) => { | ||
const input = 'The quick brown fox jumps over the lazy dog.'; | ||
const expected = 'The quick brown fox jumps over the lazy dog.'; | ||
const logger = { | ||
error: () => t.fail(), | ||
warn: () => t.fail(), | ||
}; | ||
transcludeString(input, null, logger, (output) => { | ||
t.same(output, expected); | ||
t.end(); | ||
}); | ||
}); |
Oops, something went wrong.