Skip to content

Commit

Permalink
added a few tests on the queries API
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierlacot committed Jul 26, 2011
1 parent ac25cbe commit cf61f03
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Resources/app.js
@@ -1,4 +1,4 @@
(function(){
(function() {
// load joli library and models definition file
Ti.include('/lib/vendor/joli.js/joli.js');
Ti.include('/lib/model/models.js');
Expand Down
12 changes: 12 additions & 0 deletions Resources/test/query.js
Expand Up @@ -109,6 +109,18 @@
q = new joli.query().select().from('view_count').where('nb_views > ?', 1000);
expect(q.getQuery()).toBe('select * from view_count where nb_views > "1000"');

// array-based single replacement
q = new joli.query().select().from('view_count').where('nb_views > ?', [1000]);
expect(q.getQuery()).toBe('select * from view_count where nb_views > "1000"');

// multiple value replacements, for instance for between statements
q = new joli.query().select().from('view_count').where('nb_views between ? and ?', [1000, 2000]);
expect(q.getQuery()).toBe('select * from view_count where nb_views between "1000" and "2000"');

// check that replacements stop even if there are less arguments than expected
q = new joli.query().select().from('view_count').where('nb_views between ? and ?', [1000]);
expect(q.getQuery()).toBe('select * from view_count where nb_views between "1000" and ?');

// check with several chained calls
q = new joli.query().select().from('human').where('last_name = ?', 'Doe').where('first_name = ?', 'John');
expect(q.getQuery()).toBe('select * from human where last_name = "Doe" and first_name = "John"');
Expand Down

0 comments on commit cf61f03

Please sign in to comment.