[gjs: 1/6] tests/Gio: Add more Gio._promisify tests




commit 6da7cb0e9048ff7a93ee36e030f38deb99ca75f6
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Jul 8 04:16:19 2022 +0200

    tests/Gio: Add more Gio._promisify tests
    
    Ensure that it works and preserves the old behavior

 installed-tests/js/testGio.js | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/installed-tests/js/testGio.js b/installed-tests/js/testGio.js
index 1ea2510cf..0f315b7b8 100644
--- a/installed-tests/js/testGio.js
+++ b/installed-tests/js/testGio.js
@@ -72,6 +72,27 @@ describe('Promisify function', function () {
         expect(() => Gio._promisify(Gio.Subprocess.prototype, 'communicate_utf8_async', 
'commuicate_utf8_finish')).toThrowError(/commuicate_utf8_finish/);
     });
 
+    it('promisifies functions', async function () {
+        Gio._promisify(Gio.File.prototype, 'query_info_async');
+        const file = Gio.File.new_for_path('.');
+
+        const fileInfo = await file.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
+            Gio.FileQueryInfoFlags.NONE, GLib.PRIORITY_DEFAULT, null);
+        expect(fileInfo.get_file_type()).not.toBe(Gio.FileType.UNKNOWN);
+    });
+
+    it('preserves old behavior', function (done) {
+        Gio._promisify(Gio.File.prototype, 'query_info_async');
+        const file = Gio.File.new_for_path('.');
+
+        file.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
+            Gio.FileQueryInfoFlags.NONE, GLib.PRIORITY_DEFAULT, null, (_, res) => {
+                const fileInfo = file.query_info_finish(res);
+                expect(fileInfo.get_file_type()).not.toBe(Gio.FileType.UNKNOWN);
+                done();
+            });
+    });
+
     it('can guess the finish function', function () {
         expect(() => Gio._promisify(Gio._LocalFilePrototype, 'read_async')).not.toThrow();
         expect(() => Gio._promisify(Gio.DBus, 'get')).not.toThrow();


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