[gjs/esm/dynamic-imports: 189/192] WIP - dynamic imports tests
- From: Evan Welsh <ewlsh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/esm/dynamic-imports: 189/192] WIP - dynamic imports tests
- Date: Sat, 6 Feb 2021 05:52:50 +0000 (UTC)
commit c9750bf0f706efb1795736a5420cb23feac697cd
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Dec 14 17:39:54 2020 -0800
WIP - dynamic imports tests
installed-tests/js/jsunit.gresources.xml | 1 +
installed-tests/js/modules/say.js | 7 +++++++
installed-tests/js/testESModules.js | 21 +++++++++++++++++++++
3 files changed, 29 insertions(+)
---
diff --git a/installed-tests/js/jsunit.gresources.xml b/installed-tests/js/jsunit.gresources.xml
index 3e100b1b..624ac738 100644
--- a/installed-tests/js/jsunit.gresources.xml
+++ b/installed-tests/js/jsunit.gresources.xml
@@ -21,6 +21,7 @@
<file>modules/mutualImport/a.js</file>
<file>modules/mutualImport/b.js</file>
<file>modules/overrides/GIMarshallingTests.js</file>
+ <file>modules/say.js</file>
<file>modules/subA/subB/__init__.js</file>
<file>modules/subA/subB/baz.js</file>
<file>modules/subA/subB/foobar.js</file>
diff --git a/installed-tests/js/modules/say.js b/installed-tests/js/modules/say.js
new file mode 100644
index 00000000..4729dff5
--- /dev/null
+++ b/installed-tests/js/modules/say.js
@@ -0,0 +1,7 @@
+export function say(str) {
+ return `<( ${str} )`;
+}
+
+export default function() {
+ return 'default export';
+}
diff --git a/installed-tests/js/testESModules.js b/installed-tests/js/testESModules.js
index a2997f28..2be3a149 100644
--- a/installed-tests/js/testESModules.js
+++ b/installed-tests/js/testESModules.js
@@ -86,3 +86,24 @@ describe('Builtin ES modules', function () {
expect(exit).toBe(system.exit);
});
});
+
+describe('Dynamic imports', function () {
+ let module;
+ beforeEach(function (done) {
+ import('resource:///org/gjs/jsunit/modules/say.js')
+ .then(m => (module = m))
+ .catch(err => {
+ logError(err);
+ fail();
+ })
+ .finally(done);
+ });
+
+ it('default import', function () {
+ expect(module.default()).toEqual('default export');
+ });
+
+ it('named import', function () {
+ expect(module.say('hi')).toEqual('<( hi )');
+ });
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]