tokenizer.orderBy.test.js 949 B

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