diff --git a/test/parallel/test-sqlite-statement-sync.js b/test/parallel/test-sqlite-statement-sync.js index 7a4069678af966..81526ecc412200 100644 --- a/test/parallel/test-sqlite-statement-sync.js +++ b/test/parallel/test-sqlite-statement-sync.js @@ -77,6 +77,34 @@ suite('StatementSync.prototype.all()', () => { }); }); +suite('StatementSync.prototype.iterate()', () => { + test('executes a query and returns an empty iterator on no results', (t) => { + const db = new DatabaseSync(nextDb()); + const stmt = db.prepare('CREATE TABLE storage(key TEXT, val TEXT)'); + t.assert.deepStrictEqual(stmt.iterate().toArray(), []); + }); + + test('executes a query and returns all results', (t) => { + const db = new DatabaseSync(nextDb()); + let stmt = db.prepare('CREATE TABLE storage(key TEXT, val TEXT)'); + t.assert.deepStrictEqual(stmt.run(), { changes: 0, lastInsertRowid: 0 }); + stmt = db.prepare('INSERT INTO storage (key, val) VALUES (?, ?)'); + t.assert.deepStrictEqual( + stmt.run('key1', 'val1'), + { changes: 1, lastInsertRowid: 1 }, + ); + t.assert.deepStrictEqual( + stmt.run('key2', 'val2'), + { changes: 1, lastInsertRowid: 2 }, + ); + stmt = db.prepare('SELECT * FROM storage ORDER BY key'); + t.assert.deepStrictEqual(stmt.iterate().toArray(), [ + { key: 'key1', val: 'val1' }, + { key: 'key2', val: 'val2' }, + ]); + }); +}); + suite('StatementSync.prototype.run()', () => { test('executes a query and returns change metadata', (t) => { const db = new DatabaseSync(nextDb()); diff --git a/test/parallel/test-sqlite.js b/test/parallel/test-sqlite.js index ee6912d14e7297..8acabb96fceab4 100644 --- a/test/parallel/test-sqlite.js +++ b/test/parallel/test-sqlite.js @@ -97,31 +97,3 @@ test('PRAGMAs are supported', (t) => { { journal_mode: 'wal' }, ); }); - -suite('StatementSync.prototype.iterate()', () => { - test('executes a query and returns an empty iterator on no results', (t) => { - const db = new DatabaseSync(nextDb()); - const stmt = db.prepare('CREATE TABLE storage(key TEXT, val TEXT)'); - t.assert.deepStrictEqual(stmt.iterate().toArray(), []); - }); - - test('executes a query and returns all results', (t) => { - const db = new DatabaseSync(nextDb()); - let stmt = db.prepare('CREATE TABLE storage(key TEXT, val TEXT)'); - t.assert.deepStrictEqual(stmt.run(), { changes: 0, lastInsertRowid: 0 }); - stmt = db.prepare('INSERT INTO storage (key, val) VALUES (?, ?)'); - t.assert.deepStrictEqual( - stmt.run('key1', 'val1'), - { changes: 1, lastInsertRowid: 1 }, - ); - t.assert.deepStrictEqual( - stmt.run('key2', 'val2'), - { changes: 1, lastInsertRowid: 2 }, - ); - stmt = db.prepare('SELECT * FROM storage ORDER BY key'); - t.assert.deepStrictEqual(stmt.iterate().toArray(), [ - { key: 'key1', val: 'val1' }, - { key: 'key2', val: 'val2' }, - ]); - }); -});