mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
__non_webpack_require__ -> require in SystemJS
When running browser tests, e.g. via `gulp unittest`, the test files are not processed by babel, and neither by the "unittestcli" gulp target. This commit copies the babelPluginReplaceNonWebPackRequire plugin from the unittestcli target to the SystemJS config so that `__non_webpack_require__` is replaced with `require` for all build targets, and adds a unit test to ensure that this indeed works as expected.
This commit is contained in:
parent
ba5dbc9632
commit
d253889d97
2 changed files with 33 additions and 0 deletions
|
@ -108,6 +108,21 @@ describe('SVGGraphics', function () {
|
|||
});
|
||||
}
|
||||
|
||||
it('should fail require("zlib") unless in Node.js', function() {
|
||||
function testFunc() {
|
||||
__non_webpack_require__('zlib');
|
||||
}
|
||||
// Verifies that the script loader replaces __non_webpack_require__ with
|
||||
// require.
|
||||
expect(testFunc.toString()).toMatch(/\srequire\(["']zlib["']\)/);
|
||||
if (isNodeJS()) {
|
||||
expect(testFunc).not.toThrow();
|
||||
} else {
|
||||
// require not defined, require('zlib') not a module, etc.
|
||||
expect(testFunc).toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it('should produce a reasonably small svg:image', function(done) {
|
||||
if (!isNodeJS()) {
|
||||
pending('zlib.deflateSync is not supported in non-Node environments.');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue