[gjs/esm/dynamic-imports: 2/3] WIP - dynamic imports tests
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/esm/dynamic-imports: 2/3] WIP - dynamic imports tests
- Date: Mon, 8 Feb 2021 00:44:21 +0000 (UTC)
commit 42e28266a45af444884c4f0e502f13fdf2ac404d
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Dec 14 17:39:54 2020 -0800
WIP - dynamic imports tests
installed-tests/js/.eslintrc.yml | 1 +
installed-tests/js/jsunit.gresources.xml | 1 +
installed-tests/js/modules/say.js | 10 ++++++++++
installed-tests/js/testESModules.js | 20 ++++++++++++++++++++
4 files changed, 32 insertions(+)
---
diff --git a/installed-tests/js/.eslintrc.yml b/installed-tests/js/.eslintrc.yml
index 28ec04c6..c1a4c9bd 100644
--- a/installed-tests/js/.eslintrc.yml
+++ b/installed-tests/js/.eslintrc.yml
@@ -35,5 +35,6 @@ overrides:
- testESModules.js
- modules/importmeta.js
- modules/exports.js
+ - modules/say.js
parserOptions:
sourceType: module
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..d1c7ab56
--- /dev/null
+++ b/installed-tests/js/modules/say.js
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
+// SPDX-FileCopyrightText: 2020 Philip Chimento <philip chimento gmail com>
+
+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 d1b7210d..a36cccc5 100644
--- a/installed-tests/js/testESModules.js
+++ b/installed-tests/js/testESModules.js
@@ -77,3 +77,23 @@ describe('Builtin ES modules', function () {
expect(exit).toBe(system.exit);
});
});
+
+describe('Dynamic imports', function () {
+ let module;
+ beforeEach(async function () {
+ try {
+ module = await import('resource:///org/gjs/jsunit/modules/say.js');
+ } catch (err) {
+ logError(err);
+ fail();
+ }
+ });
+
+ 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]