-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: output to stdout if input comes from stdin
- Loading branch information
1 parent
82e1834
commit 73f8e0d
Showing
6 changed files
with
95 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,47 @@ | ||
import { resolve, basename } from 'path'; | ||
import test from 'ava'; | ||
|
||
import test, { before } from 'ava'; | ||
import { readFileSync, unlinkSync } from 'fs'; | ||
import { basename, resolve } from 'path'; | ||
import { mdToPdf } from '..'; | ||
|
||
before(() => { | ||
const filesToDelete = [resolve(__dirname, 'basic', 'api-test.pdf'), resolve(__dirname, 'basic', 'api-test.html')]; | ||
|
||
for (const file of filesToDelete) { | ||
try { | ||
unlinkSync(file); | ||
} catch (error) { | ||
if (error.code !== 'ENOENT') { | ||
throw error; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
test('should compile the basic example to pdf', async t => { | ||
const pdf = await mdToPdf({ path: resolve(__dirname, 'basic', 'test.md') }); | ||
|
||
t.is(pdf.filename, ''); | ||
t.truthy(pdf.content); | ||
}); | ||
|
||
test('should compile the basic example to pdf and write to disk', async t => { | ||
const pdf = await mdToPdf( | ||
{ path: resolve(__dirname, 'basic', 'test.md') }, | ||
{ dest: resolve(__dirname, 'basic', 'api-test.pdf') }, | ||
); | ||
|
||
t.is(basename(pdf.filename), 'api-test.pdf'); | ||
|
||
t.notThrows(() => readFileSync(resolve(__dirname, 'basic', 'api-test.pdf'), 'utf-8')); | ||
}); | ||
|
||
test('should compile the basic example to html', async t => { | ||
test('should compile the basic example to html and write to disk', async t => { | ||
const pdf = await mdToPdf( | ||
{ path: resolve(__dirname, 'basic', 'test.md') }, | ||
{ dest: resolve(__dirname, 'basic', 'api-test.html'), as_html: true }, | ||
); | ||
|
||
t.is(basename(pdf.filename), 'api-test.html'); | ||
|
||
t.notThrows(() => readFileSync(resolve(__dirname, 'basic', 'api-test.html'), 'utf-8')); | ||
}); |
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