Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to fs.readFileSync in TypeScript files (#1736) #2046

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
});
});
});