aboutsummaryrefslogtreecommitdiffstats
path: root/test/bundler_smoke_tests/src-esm-commonjs
diff options
context:
space:
mode:
Diffstat (limited to 'test/bundler_smoke_tests/src-esm-commonjs')
-rw-r--r--test/bundler_smoke_tests/src-esm-commonjs/jquery-require.cjs12
-rw-r--r--test/bundler_smoke_tests/src-esm-commonjs/main.js38
2 files changed, 50 insertions, 0 deletions
diff --git a/test/bundler_smoke_tests/src-esm-commonjs/jquery-require.cjs b/test/bundler_smoke_tests/src-esm-commonjs/jquery-require.cjs
new file mode 100644
index 000000000..7da6dc473
--- /dev/null
+++ b/test/bundler_smoke_tests/src-esm-commonjs/jquery-require.cjs
@@ -0,0 +1,12 @@
+"use strict";
+
+const $ = require( "jquery" );
+const $slim = require( "jquery/slim" );
+
+const { jQueryFactory } = require( "jquery/factory" );
+const { jQueryFactory: jQueryFactorySlim } = require( "jquery/factory-slim" );
+
+module.exports.$required = $;
+module.exports.$slimRequired = $slim;
+module.exports.jQueryFactoryRequired = jQueryFactory;
+module.exports.jQueryFactorySlimRequired = jQueryFactorySlim;
diff --git a/test/bundler_smoke_tests/src-esm-commonjs/main.js b/test/bundler_smoke_tests/src-esm-commonjs/main.js
new file mode 100644
index 000000000..2ea6da190
--- /dev/null
+++ b/test/bundler_smoke_tests/src-esm-commonjs/main.js
@@ -0,0 +1,38 @@
+import { $ as $imported } from "jquery";
+import { $ as $slimImported } from "jquery/slim";
+
+import { jQueryFactory as jQueryFactoryImported } from "jquery/factory";
+import { jQueryFactory as jQueryFactorySlimImported } from "jquery/factory-slim";
+
+import {
+ $required,
+ $slimRequired,
+ jQueryFactoryRequired,
+ jQueryFactorySlimRequired
+} from "./jquery-require.cjs";
+
+console.assert( $required === $imported,
+ "Only one copy of full jQuery should exist" );
+console.assert( /^jQuery/.test( $imported.expando ),
+ "jQuery.expando should be detected on full jQuery" );
+
+console.assert( $slimRequired === $slimImported,
+ "Only one copy of slim jQuery should exist" );
+console.assert( /^jQuery/.test( $slimImported.expando ),
+ "jQuery.expando should be detected on slim jQuery" );
+
+console.assert( jQueryFactoryImported === jQueryFactoryRequired,
+ "Only one copy of full jQueryFactory should exist" );
+console.assert( !( "expando" in jQueryFactoryImported ),
+ "jQuery.expando should not be attached to the full factory" );
+const $fromFactory = jQueryFactoryImported( window );
+console.assert( /^jQuery/.test( $fromFactory.expando ),
+ "jQuery.expando should be detected on full jQuery from factory" );
+
+console.assert( jQueryFactorySlimImported === jQueryFactorySlimRequired,
+ "Only one copy of slim jQueryFactory should exist" );
+console.assert( !( "expando" in jQueryFactorySlimImported ),
+ "jQuery.expando should not be attached to the slim factory" );
+const $fromFactorySlim = jQueryFactorySlimImported( window );
+console.assert( /^jQuery/.test( $fromFactorySlim.expando ),
+ "jQuery.expando should be detected on slim jQuery from factory" );