Skip to content

Commit

Permalink
Added keep-name test.
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Dec 17, 2018
1 parent 299e1e5 commit 61bce4a
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default function rebase(options = {}) {
const fileName = path.basename(importee, fileExt)
const fileHash = await getHash(fileSource)
const fileTarget = keepName ?
`${fileName}_${fileHash}${fileExt}` :
`${fileName}~${fileHash}${fileExt}` :
`${fileHash}${fileExt}`

// Registering for our copying job when the bundle is created (kind of a job queue)
Expand Down
30 changes: 30 additions & 0 deletions test/keep-name/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Keep Name 1`] = `
"content~bsdudxaF.md
image_bXipeBrs.png
index.js
index~gToHHcDx.css
index~gToHHcDx.css.map"
`;

exports[`Keep Name 2`] = `
"import content from './content~bsdudxaF.md';
import css from './index~gToHHcDx.css';
function index() {
return content + css
}
export default index;
"
`;

exports[`Keep Name 3`] = `
"body {
font-size: 20px;
background: url(./image_bXipeBrs.png) top left repeat;
}
/*# sourceMappingURL=index~gToHHcDx.css.map */"
`;
1 change: 1 addition & 0 deletions test/keep-name/content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Hello
Binary file added test/keep-name/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/keep-name/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
font-size: 20px;
background: url(./image.png) top left repeat;
}
6 changes: 6 additions & 0 deletions test/keep-name/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import content from "./content.md"
import css from "./index.css"

export default function() {
return content + css
}
13 changes: 13 additions & 0 deletions test/keep-name/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { bundle, clean, list, read } from "../util"

const root = __dirname

test("Keep Name", async () => {
await bundle(root, "index.js", "output/index.js", { keepName: true })

expect(await list(root, "output")).toMatchSnapshot()
expect(await read(root, "output/index.js")).toMatchSnapshot()
expect(await read(root, "output/index~gToHHcDx.css")).toMatchSnapshot()

await clean(root, "output")
})

0 comments on commit 61bce4a

Please sign in to comment.