summaryrefslogtreecommitdiff
path: root/installed-tests/js/testESModules.js
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2023-02-26 20:16:59 -0800
committerPhilip Chimento <philip.chimento@gmail.com>2023-03-04 23:40:32 -0800
commitde647bbfaf7964edf520a96212755c9a3dfc5c2c (patch)
treea928f42e1bfdd0369a0292f077de2b8d752e7341 /installed-tests/js/testESModules.js
parent9633f54961f83dbe06871eb9b9c11b997cc9d577 (diff)
downloadgjs-de647bbfaf7964edf520a96212755c9a3dfc5c2c.tar.gz
gi: Roll back change to imports.gi.versions object if gi.require() fails
If something like gi.require('GLib', '1.75') fails, then we don't want the faulty version number remaining on the imports.gi.versions object.
Diffstat (limited to 'installed-tests/js/testESModules.js')
-rw-r--r--installed-tests/js/testESModules.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/installed-tests/js/testESModules.js b/installed-tests/js/testESModules.js
index 30db17e4..e727c790 100644
--- a/installed-tests/js/testESModules.js
+++ b/installed-tests/js/testESModules.js
@@ -27,26 +27,32 @@ describe('ES module imports', function () {
it('import with version parameter', function () {
expect(gi.require('GObject', '2.0')).toBe(gi.require('GObject'));
+ expect(imports.gi.versions['GObject']).toBe('2.0');
});
it('import again with other version parameter', function () {
expect(() => gi.require('GObject', '1.75')).toThrow();
+ expect(imports.gi.versions['GObject']).toBe('2.0');
});
it('import for the first time with wrong version', function () {
expect(() => gi.require('Gtk', '1.75')).toThrow();
+ expect(imports.gi.versions['Gtk']).not.toBeDefined();
});
it('import with another version after a failed import', function () {
expect(gi.require('Gtk', '3.0').toString()).toEqual('[object GIRepositoryNamespace]');
+ expect(imports.gi.versions['Gtk']).toBe('3.0');
});
it('import nonexistent module', function () {
expect(() => gi.require('PLib')).toThrow();
+ expect(imports.gi.versions['PLib']).not.toBeDefined();
});
it('GObject introspection import via URL scheme', function () {
expect(Gio.toString()).toEqual('[object GIRepositoryNamespace]');
+ expect(imports.gi.versions['Gio']).toBe('2.0');
});
it('import.meta.url', function () {