This repository has been archived by the owner on Nov 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests, update mos to v1
- Loading branch information
Showing
12 changed files
with
132 additions
and
20 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 |
---|---|---|
@@ -1 +1,33 @@ | ||
require('.') | ||
'use strict' | ||
const describe = require('mocha').describe | ||
const it = require('mocha').it | ||
const expect = require('chai').expect | ||
const path = require('path') | ||
const fs = require('fs') | ||
const ROOT = path.join(__dirname, 'test/fixtures') | ||
const fixtures = fs.readdirSync(ROOT).filter(filepath => filepath.indexOf('.') !== 0) | ||
|
||
const mos = require('mos-processor') | ||
const ejs = require('mos-plugin-ejs') | ||
const license = require('.') | ||
|
||
describe('mos-plugin-toc', () => { | ||
fixtures.forEach(fixture => { | ||
const filepath = path.join(ROOT, fixture) | ||
const output = fs.readFileSync(path.join(filepath, 'output.md'), 'utf-8') | ||
const inputPath = path.join(filepath, 'input.md') | ||
const input = fs.readFileSync(inputPath, 'utf-8') | ||
const configPath = path.join(filepath, 'config.json') | ||
const config = fs.existsSync(configPath) ? JSON.parse(fs.readFileSync(configPath, 'utf-8')) : {} | ||
|
||
it('should pass fixture in dir ' + filepath, done => { | ||
mos({ content: input, filePath: inputPath }, [ejs, { register: license, options: config }]) | ||
.then(processor => processor.process()) | ||
.then(result => { | ||
expect(result).to.eq(output) | ||
done() | ||
}) | ||
.catch(done) | ||
}) | ||
}) | ||
}) |
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 @@ | ||
!node_modules |
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,5 @@ | ||
<!--@dependencies()--> | ||
<!--/@--> | ||
|
||
<!--@devDependencies()--> | ||
<!--/@--> |
8 changes: 8 additions & 0 deletions
8
test/fixtures/dependencies-with-no-shields/node_modules/foo/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
<!--@dependencies()--> | ||
## <a name="dependencies">Dependencies</a> | ||
|
||
- [foo](https://github.com/zkochan/foo): foo descr | ||
|
||
<!--/@--> | ||
|
||
<!--@devDependencies()--> | ||
## <a name="dev-dependencies">Dev Dependencies</a> | ||
|
||
- [foo](https://github.com/zkochan/foo): foo descr | ||
|
||
<!--/@--> |
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,13 @@ | ||
{ | ||
"name": "test-pkg", | ||
"dependencies": { | ||
"foo": "*" | ||
}, | ||
"devDependencies": { | ||
"foo": "*" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/zkochan/test-pkg" | ||
} | ||
} |
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,5 @@ | ||
<!--@dependencies({ shield: 'flat-square' })--> | ||
<!--/@--> | ||
|
||
<!--@devDependencies({ shield: 'flat-square' })--> | ||
<!--/@--> |
8 changes: 8 additions & 0 deletions
8
test/fixtures/dependencies-with-shields/node_modules/foo/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
<!--@dependencies({ shield: 'flat-square' })--> | ||
## <a name="dependencies">Dependencies</a> [![dependency status](https://img.shields.io/david/zkochan/test-pkg/master.svg?style=flat-square)](https://david-dm.org/zkochan/test-pkg/master) | ||
|
||
- [foo](https://github.com/zkochan/foo): foo descr | ||
|
||
<!--/@--> | ||
|
||
<!--@devDependencies({ shield: 'flat-square' })--> | ||
## <a name="dev-dependencies">Dev Dependencies</a> [![devDependency status](https://img.shields.io/david/dev/zkochan/test-pkg/master.svg?style=flat-square)](https://david-dm.org/zkochan/test-pkg/master#info=devDependencies) | ||
|
||
- [foo](https://github.com/zkochan/foo): foo descr | ||
|
||
<!--/@--> |
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,13 @@ | ||
{ | ||
"name": "test-pkg", | ||
"dependencies": { | ||
"foo": "*" | ||
}, | ||
"devDependencies": { | ||
"foo": "*" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/zkochan/test-pkg" | ||
} | ||
} |