diff options
author | Sonny Piers <sonny@fastmail.net> | 2022-08-07 01:45:17 +0200 |
---|---|---|
committer | Sonny Piers <sonny@fastmail.net> | 2022-08-07 23:03:13 +0200 |
commit | 3b1eee40e92eb0445f08731b0d58807375f5413c (patch) | |
tree | d52a858b74ad5be7d282edbc32fde628be6de0f0 /installed-tests | |
parent | 27d26628c566a6770c95df34a2e17d10652857bf (diff) | |
download | gjs-3b1eee40e92eb0445f08731b0d58807375f5413c.tar.gz |
Make GFileEnumerator iterable and async iterable
Diffstat (limited to 'installed-tests')
-rw-r--r-- | installed-tests/js/testGio.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/installed-tests/js/testGio.js b/installed-tests/js/testGio.js index 0f315b7b..fc94bb58 100644 --- a/installed-tests/js/testGio.js +++ b/installed-tests/js/testGio.js @@ -311,3 +311,33 @@ describe('Gio.add_action_entries override', function () { expect(() => app.add_action_entries(entries)).toThrow(); }); }); + +describe('Gio.FileEnumerator overrides', function () { + it('iterates synchronously', function () { + const dir = Gio.File.new_for_path('.'); + let count = 0; + for (const value of dir.enumerate_children( + 'standard::name', + Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, + null + )) { + expect(value).toBeInstanceOf(Gio.FileInfo); + count++; + } + expect(count).toBeGreaterThan(0); + }); + + it('iterates asynchronously', async function () { + const dir = Gio.File.new_for_path('.'); + let count = 0; + for await (const value of dir.enumerate_children( + 'standard::name', + Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, + null + )) { + expect(value).toBeInstanceOf(Gio.FileInfo); + count++; + } + expect(count).toBeGreaterThan(0); + }); +}); |