Skip to content

Commit

Permalink
Adds some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cognitom committed Jan 15, 2017
1 parent baaed06 commit 2652b8e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/fixture/white.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>White</title>
<link rel="stylesheet" href="../paper.css">
<style>@page { size: A5 landscape }</style>
</head>

<body class="A5 landscape">
<section class="sheet padding-20mm">

</section>
</body>

</html>
27 changes: 27 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-env mocha */
import {equal, ok} from 'assert'
import {dirname} from 'path'
import request from 'request-promise-native'
import {readFile} from 'fs-promise'
import findPort from '../lib/find-port'
import startServer from '../lib/server'

const root = dirname(__dirname)

describe('paper-cli', function () {
it('finds an available port', async function () {
const port = await findPort()
ok(Number.isInteger(port))
})

it('starts a static server', async function () {
const port = await findPort()
const server = startServer(root, port)
const file = 'test/fixture/white.html'
const url = `http://localhost:${port}/${file}`
const actual = await request(url)
const expected = await readFile(file, 'utf8')
equal(actual, expected)
server.close()
})
})

0 comments on commit 2652b8e

Please sign in to comment.