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
Showing
8 changed files
with
219 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>馃弫 serve markdown as html (GitHub style), index directories, and live-reload as you edit</p> |
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,60 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import request from 'request' | ||
import test from 'ava' | ||
import getPort from 'get-port' | ||
import readme from '../lib/readme' | ||
|
||
test.cb('start markserv via "readme" command', t => { | ||
t.plan(3) | ||
|
||
const expected = String( | ||
fs.readFileSync( | ||
path.join(__dirname, 'markserv-cli-readme-dir-down.expected.html') | ||
) | ||
) | ||
|
||
const dir = path.join(__dirname, '..') | ||
|
||
getPort().then(port => { | ||
const flags = { | ||
dir, | ||
port, | ||
livereloadport: false, | ||
address: 'localhost', | ||
silent: true, | ||
browser: false | ||
} | ||
|
||
const done = () => { | ||
t.end() | ||
} | ||
|
||
readme.run(flags).then(service => { | ||
const closeServer = () => { | ||
service.httpServer.close(done) | ||
} | ||
|
||
const opts = { | ||
url: service.launchUrl, | ||
timeout: 1000 * 2 | ||
} | ||
|
||
request(opts, (err, res, body) => { | ||
if (err) { | ||
t.fail(err) | ||
closeServer() | ||
} | ||
|
||
t.true(body.includes(expected)) | ||
|
||
t.is(res.statusCode, 200) | ||
t.pass() | ||
closeServer() | ||
}) | ||
}).catch(err => { | ||
t.fail(err) | ||
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 @@ | ||
<h1 id="pass">PASS</h1> |
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,62 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import request from 'request' | ||
import test from 'ava' | ||
import getPort from 'get-port' | ||
import readme from '../lib/readme' | ||
|
||
test.cb('start markserv via "readme" command', t => { | ||
t.plan(3) | ||
|
||
const expected = String( | ||
fs.readFileSync( | ||
path.join(__dirname, 'markserv-cli-readme.expected.html') | ||
) | ||
) | ||
|
||
const dir = path.join( | ||
__dirname, '..', 'tests', 'markserv-cli-readme' | ||
) + path.sep | ||
|
||
getPort().then(port => { | ||
const flags = { | ||
dir, | ||
port, | ||
livereloadport: false, | ||
address: 'localhost', | ||
silent: true, | ||
browser: false | ||
} | ||
|
||
const done = () => { | ||
t.end() | ||
} | ||
|
||
readme.run(flags).then(service => { | ||
const closeServer = () => { | ||
service.httpServer.close(done) | ||
} | ||
|
||
const opts = { | ||
url: service.launchUrl, | ||
timeout: 1000 * 2 | ||
} | ||
|
||
request(opts, (err, res, body) => { | ||
if (err) { | ||
t.fail(err) | ||
closeServer() | ||
} | ||
|
||
t.true(body.includes(expected)) | ||
|
||
t.is(res.statusCode, 200) | ||
t.pass() | ||
closeServer() | ||
}) | ||
}).catch(err => { | ||
t.fail(err) | ||
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 @@ | ||
# PASS |