1
1
mirror of https://github.com/c8r/x0.git synced 2024-09-11 13:45:52 +03:00
x0/test/build.js
2018-05-25 10:48:02 -04:00

46 lines
1023 B
JavaScript

import fs from 'fs'
import path from 'path'
import test from 'ava'
import rimraf from 'rimraf'
import build from '../lib/build'
const input = path.resolve('test/components')
const output = path.resolve('test/output')
const htmlFile = path.resolve('test/output/index.html')
const propsFile = path.resolve('test/output/props/index.html')
const bundleFile = path.resolve('test/output/bundle.js')
const options = {
input,
dirname: input,
outDir: output,
}
const clean = () => {
if (fs.existsSync(output)) {
rimraf.sync(output)
}
// fs.remove(output)
}
test.before(clean)
test.after(clean)
test('static renders', async t => {
const res = await build(options)
const html = fs.readFileSync(htmlFile, 'utf8')
t.snapshot(html)
})
test('static uses getInitialProps method', async t => {
const res = await build(options)
const html = fs.readFileSync(propsFile, 'utf8')
t.snapshot(html)
})
test.skip('static makes a directory', async t => {
clean()
const res = await build(options)
t.pass()
})