Skip to content

Commit

Permalink
Added JS file content checks + simplified eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Dec 17, 2018
1 parent 70c387b commit 63baa1c
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
extends:
- readable

globals:
__dirname: true

rules:
no-console:
- off
12 changes: 12 additions & 0 deletions test/flat-multi/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ exports[`Flat Multi 1`] = `
bsdudxaF.md
index.js"
`;

exports[`Flat Multi 2`] = `
"import content from './bsdudxaF.md';
import image from './bXipeBrs.png';
function index() {
return content + image
}
export default index;
"
`;
4 changes: 2 additions & 2 deletions test/flat-multi/index.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* global __dirname */
import { bundle, clean, list } from "../util"
import { bundle, clean, list, read } from "../util"

const root = __dirname

test("Flat Multi", async () => {
await bundle(root, "index.js", "output/index.js")

expect(list(root, "output")).resolves.toMatchSnapshot()
expect(read(root, "output/index.js")).resolves.toMatchSnapshot()

await clean(root, "output")
})
11 changes: 11 additions & 0 deletions test/flat-single/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ exports[`Flat Single 1`] = `
"bsdudxaF.md
index.js"
`;

exports[`Flat Single 2`] = `
"import content from './bsdudxaF.md';
function index() {
return content
}
export default index;
"
`;
4 changes: 2 additions & 2 deletions test/flat-single/index.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* global __dirname */
import { bundle, clean, list } from "../util"
import { bundle, clean, list, read } from "../util"

const root = __dirname

test("Flat Single", async () => {
await bundle(root, "index.js", "output/index.js")

expect(list(root, "output")).resolves.toMatchSnapshot()
expect(read(root, "output/index.js")).resolves.toMatchSnapshot()

await clean(root, "output")
})
11 changes: 11 additions & 0 deletions test/indirect-deep-single/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ exports[`Indirect Single 1`] = `
"bsdudxaF.md
index.js"
`;

exports[`Indirect Single 2`] = `
"import content from './sub/folder/bsdudxaF.md';
function index() {
return content
}
export default index;
"
`;
4 changes: 2 additions & 2 deletions test/indirect-deep-single/index.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* global __dirname */
import { bundle, clean, list } from "../util"
import { bundle, clean, list, read } from "../util"

const root = __dirname

test("Indirect Single", async () => {
await bundle(root, "index.js", "output/index.js")

expect(list(root, "output")).resolves.toMatchSnapshot()
expect(read(root, "output/index.js")).resolves.toMatchSnapshot()

await clean(root, "output")
})
11 changes: 11 additions & 0 deletions test/indirect-single/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ exports[`Indirect Single 1`] = `
"bsdudxaF.md
index.js"
`;

exports[`Indirect Single 2`] = `
"import content from './bsdudxaF.md';
function index() {
return content
}
export default index;
"
`;
4 changes: 2 additions & 2 deletions test/indirect-single/index.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* global __dirname */
import { bundle, clean, list } from "../util"
import { bundle, clean, list, read } from "../util"

const root = __dirname

test("Indirect Single", async () => {
await bundle(root, "index.js", "output/index.js")

expect(list(root, "output")).resolves.toMatchSnapshot()
expect(read(root, "output/index.js")).resolves.toMatchSnapshot()

await clean(root, "output")
})
11 changes: 11 additions & 0 deletions test/one-level/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ exports[`One Level 1`] = `
"bsdudxaF.md
index.js"
`;

exports[`One Level 2`] = `
"import content from './bsdudxaF.md';
function index() {
return content
}
export default index;
"
`;
4 changes: 2 additions & 2 deletions test/one-level/index.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* global __dirname */
import { bundle, clean, list } from "../util"
import { bundle, clean, list, read } from "../util"

const root = __dirname

test("One Level", async () => {
await bundle(root, "index.js", "output/index.js")

expect(list(root, "output")).resolves.toMatchSnapshot()
expect(read(root, "output/index.js")).resolves.toMatchSnapshot()

await clean(root, "output")
})
6 changes: 6 additions & 0 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ export async function list(root, folder) {
})
})
}

export async function read(root, file, options = {}) {
const content = await fs.readFile(join(root, file), { encoding: options.encoding || "utf-8" })
console.log(content)
return content
}

0 comments on commit 63baa1c

Please sign in to comment.