Skip to content

Commit

Permalink
Add test to fs.readFileSync in typescript files (parcel-bundler#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus committed Sep 23, 2018
1 parent 3ed33fd commit 622d0f6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parcel-bundler",
"version": "1.10.0-beta.1",
"version": "1.10.0-beta.2",
"description": "Blazing fast, zero configuration web application bundler",
"main": "index.js",
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions test/integration/typescript-fs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { readFileSync } from 'fs';
import rawFromTsx from './readFromTsx';

module.exports = {
fromTs: readFileSync(__dirname + '/raw.tsx', "utf-8"),
fromTsx: rawFromTsx,
};
1 change: 1 addition & 0 deletions test/integration/typescript-fs/raw.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default <div>Hello</div>;
5 changes: 5 additions & 0 deletions test/integration/typescript-fs/readFromTsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { readFileSync } from 'fs';

const raw = readFileSync(__dirname + '/raw.tsx', "utf-8");

export default raw;
14 changes: 14 additions & 0 deletions test/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,18 @@ describe('typescript', function() {
assert.equal(typeof output.test, 'function');
assert.equal(output.test(), 'test passed');
});

it('fs.readFileSync should inline a file as a string', async function() {
let b = await bundle(
path.join(__dirname, '/integration/typescript-fs/index.ts')
);

const text = 'export default <div>Hello</div>;';
let output = await run(b);

assert.deepEqual(output, {
fromTs: text,
fromTsx: text
});
});
});

0 comments on commit 622d0f6

Please sign in to comment.