[gjs: 2/3] tests: Add test for GLib.VariantDict.lookup failure case



commit b2174788aa3c4ba916844d01fa8e4e76cce0e431
Author: Philip Chimento <philip chimento gmail com>
Date:   Fri Aug 2 16:53:50 2019 -0700

    tests: Add test for GLib.VariantDict.lookup failure case
    
    See GNOME/gjs#263

 installed-tests/js/testGLib.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/installed-tests/js/testGLib.js b/installed-tests/js/testGLib.js
index 1645815b..66b7afb9 100644
--- a/installed-tests/js/testGLib.js
+++ b/installed-tests/js/testGLib.js
@@ -72,12 +72,23 @@ describe('GVariant constructor', function () {
 });
 
 describe('GVariantDict lookup', function () {
-    it('returns the unpacked variant', function () {
-        const variantDict = new GLib.VariantDict(null);
+    let variantDict;
+    beforeEach(function () {
+        variantDict = new GLib.VariantDict(null);
         variantDict.insert_value('foo', GLib.Variant.new_string('bar'));
+    });
+
+    it('returns the unpacked variant', function () {
         expect(variantDict.lookup('foo')).toEqual('bar');
         expect(variantDict.lookup('foo', null)).toEqual('bar');
         expect(variantDict.lookup('foo', 's')).toEqual('bar');
         expect(variantDict.lookup('foo', new GLib.VariantType('s'))).toEqual('bar');
     });
+
+    it("returns null if the key isn't present", function () {
+        expect(variantDict.lookup('bar')).toBeNull();
+        expect(variantDict.lookup('bar', null)).toBeNull();
+        expect(variantDict.lookup('bar', 's')).toBeNull();
+        expect(variantDict.lookup('bar', new GLib.VariantType('s'))).toBeNull();
+    });
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]