compile-statement.test.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var assert = require('assert');
  2. var Pack = require('../../');
  3. describe('Queryable ::', function() {
  4. describe('Compile Statement', function() {
  5. it('should generate a SQL Statement from a WLQL query', function(done) {
  6. Pack.compileStatement({
  7. statement: {
  8. select: ['title', 'author', 'year'],
  9. from: 'books'
  10. }
  11. })
  12. .exec(function(err, report) {
  13. if (err) {
  14. return done(err);
  15. }
  16. assert.equal(report.nativeQuery, 'select `title`, `author`, `year` from `books`');
  17. return done();
  18. });
  19. });
  20. // FUTURE: Add lots of checking to the statement compiler
  21. it.skip('should return the malformed exit for bad WLQL', function(done) {
  22. Pack.compileStatement({
  23. statement: {
  24. foo: 'bar',
  25. from: 'books'
  26. }
  27. })
  28. .exec(function(err) {
  29. try {
  30. assert(err);
  31. assert.equal(err.exit, 'malformed', 'Instead got '+err.stack);
  32. } catch (err2) { return done(err2); }
  33. return done();
  34. });
  35. });
  36. });
  37. });