From 622d0f6a9942e3cae0d603e1fc5b21be8d7f2896 Mon Sep 17 00:00:00 2001 From: hasparus Date: Sun, 23 Sep 2018 13:12:57 +0200 Subject: [PATCH] Add test to fs.readFileSync in typescript files (#1736) --- package.json | 2 +- test/integration/typescript-fs/index.ts | 7 +++++++ test/integration/typescript-fs/raw.tsx | 1 + test/integration/typescript-fs/readFromTsx.tsx | 5 +++++ test/typescript.js | 14 ++++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/integration/typescript-fs/index.ts create mode 100644 test/integration/typescript-fs/raw.tsx create mode 100644 test/integration/typescript-fs/readFromTsx.tsx diff --git a/package.json b/package.json index f69b075120a..cf4a84354ad 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/integration/typescript-fs/index.ts b/test/integration/typescript-fs/index.ts new file mode 100644 index 00000000000..11dd24b4c5f --- /dev/null +++ b/test/integration/typescript-fs/index.ts @@ -0,0 +1,7 @@ +import { readFileSync } from 'fs'; +import rawFromTsx from './readFromTsx'; + +module.exports = { + fromTs: readFileSync(__dirname + '/raw.tsx', "utf-8"), + fromTsx: rawFromTsx, +}; diff --git a/test/integration/typescript-fs/raw.tsx b/test/integration/typescript-fs/raw.tsx new file mode 100644 index 00000000000..10510de0391 --- /dev/null +++ b/test/integration/typescript-fs/raw.tsx @@ -0,0 +1 @@ +export default
Hello
; \ No newline at end of file diff --git a/test/integration/typescript-fs/readFromTsx.tsx b/test/integration/typescript-fs/readFromTsx.tsx new file mode 100644 index 00000000000..050e855ab4c --- /dev/null +++ b/test/integration/typescript-fs/readFromTsx.tsx @@ -0,0 +1,5 @@ +import { readFileSync } from 'fs'; + +const raw = readFileSync(__dirname + '/raw.tsx', "utf-8"); + +export default raw; \ No newline at end of file diff --git a/test/typescript.js b/test/typescript.js index e48b154b73c..2d07dd607fb 100644 --- a/test/typescript.js +++ b/test/typescript.js @@ -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
Hello
;'; + let output = await run(b); + + assert.deepEqual(output, { + fromTs: text, + fromTsx: text + }); + }); });