Skip to content

Commit 27314f7

Browse files
rubnogueiradhmlau
authored andcommitted
test: increase coverage
Signed-off-by: Ruben Nogueira <40404708+rubnogueira@users.noreply.github.com>
1 parent 3d5b1f8 commit 27314f7

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

test/sql.test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,47 @@ describe('sql connector', function() {
259259
expect(where.sql).to.not.match(/ AND $/);
260260
});
261261

262+
it('builds where and drops an or with only invalid clauses', function() {
263+
const where = connector.buildWhere('customer', {
264+
name: 'icecream',
265+
or: [{notAColumnName: ''}, {notAColumnNameEither: ''}],
266+
});
267+
expect(where.toJSON()).to.eql({
268+
sql: 'WHERE `NAME`=?',
269+
params: ['icecream'],
270+
});
271+
});
272+
273+
it('builds empty where for an or with only invalid clauses', function() {
274+
const where = connector.buildWhere('customer', {
275+
or: [{notAColumnName: ''}, {notAColumnNameEither: ''}],
276+
});
277+
expect(where.toJSON()).to.eql({
278+
sql: '',
279+
params: [],
280+
});
281+
});
282+
283+
it('builds empty where for an and with only invalid clauses', function() {
284+
const where = connector.buildWhere('customer', {
285+
and: [{notAColumnName: ''}, {notAColumnNameEither: ''}],
286+
});
287+
expect(where.toJSON()).to.eql({
288+
sql: '',
289+
params: [],
290+
});
291+
});
292+
293+
it('builds where and drops a nested or with only invalid clauses', function() {
294+
const where = connector.buildWhere('customer', {
295+
and: [{name: 'John'}, {or: [{notAColumnName: ''}]}],
296+
});
297+
expect(where.toJSON()).to.eql({
298+
sql: 'WHERE ((`NAME`=?))',
299+
params: ['John'],
300+
});
301+
});
302+
262303
it('builds order by with one field', function() {
263304
const orderBy = connector.buildOrderBy('customer', 'name');
264305
expect(orderBy).to.eql('ORDER BY `NAME`');

0 commit comments

Comments
 (0)