Skip to content

Commit

Permalink
Worked on flat test
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Dec 17, 2018
1 parent d43260b commit c7ed89f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/flat/flat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import content from "content.md"
import content from "./content.md"

export default function() {
return content
Expand Down
19 changes: 12 additions & 7 deletions test/flat/flat.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { bundle, clean } from "../util"
/* global __dirname */
import { bundle, clean, exists } from "../util"

const root = __dirname

test("Flat", async () => {
const outputFile = `./output/index.js`
const output = "output/index.js"

await bundle(__dirname, "flat.js", outputFile)
await bundle(root, "flat.js", output)

// await Promise.all([
// expect(fs.pathExists(outputFile)).resolves.toBeTruthy()
// ])
expect(exists(root,
[
output,
"output/bsdudxaF.md"
])).resolves.toBeTruthy()

// await clean(outputFile)
await clean(root, output)
})
7 changes: 0 additions & 7 deletions test/flat/output/index.js

This file was deleted.

12 changes: 10 additions & 2 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ export async function bundle(root, input, output, pluginOptions = {}) {
})
}

export async function clean(files) {
const tasks = files.map((file) => fs.remove(file))
export async function clean(root, files) {
const input = files instanceof Array ? files : [ files ]
const tasks = input.map((file) => fs.remove(join(root, file)))
return Promise.all(tasks)
}

export async function exists(root, files) {
const input = files instanceof Array ? files : [ files ]
const tasks = input.map((file) => fs.pathExists(join(root, file)))
const result = await Promise.all(tasks)
return !result.some((value) => value === false)
}

0 comments on commit c7ed89f

Please sign in to comment.