analyzer.orderBy.test.js 1005 B

1234567891011121314151617181920212223242526272829303132333435
  1. var Analyzer = require('../../../index').query.analyzer;
  2. var tokenize = require('../../support/tokenize');
  3. var assert = require('assert');
  4. describe('Analyzer ::', function() {
  5. describe('ORDER BY statements', function() {
  6. it('should generate a valid group when ORDER BY is used', function() {
  7. var tokens = tokenize({
  8. select: ['*'],
  9. from: 'users',
  10. orderBy: [{ name: 'desc' }, { age: 'asc' }]
  11. });
  12. var result = Analyzer(tokens);
  13. assert.deepEqual(result, [
  14. [
  15. { type: 'IDENTIFIER', value: 'SELECT' },
  16. { type: 'VALUE', value: '*' }
  17. ],
  18. [
  19. { type: 'IDENTIFIER', value: 'FROM' },
  20. { type: 'VALUE', value: 'users' }
  21. ],
  22. [
  23. { type: 'IDENTIFIER', value: 'ORDERBY' },
  24. { type: 'KEY', value: 'name' },
  25. { type: 'VALUE', value: 'desc' },
  26. { type: 'KEY', value: 'age' },
  27. { type: 'VALUE', value: 'asc' }
  28. ]
  29. ]);
  30. });
  31. });
  32. });