tokenizer.aggregations.test.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var Tokenizer = require('../../../index').query.tokenizer;
  2. var assert = require('assert');
  3. describe('Tokenizer ::', function() {
  4. describe('Aggregations', function() {
  5. it('should generate a valid token array when SUM is used', function() {
  6. var result = Tokenizer({
  7. sum: 'active',
  8. from: 'users'
  9. });
  10. assert.deepEqual(result, [
  11. { type: 'IDENTIFIER', value: 'SUM' },
  12. { type: 'VALUE', value: 'active' },
  13. { type: 'ENDIDENTIFIER', value: 'SUM' },
  14. { type: 'IDENTIFIER', value: 'FROM' },
  15. { type: 'VALUE', value: 'users' },
  16. { type: 'ENDIDENTIFIER', value: 'FROM' }
  17. ]);
  18. });
  19. it('should generate a valid token array when AVG is used', function() {
  20. var result = Tokenizer({
  21. avg: 'active',
  22. from: 'users'
  23. });
  24. assert.deepEqual(result, [
  25. { type: 'IDENTIFIER', value: 'AVG' },
  26. { type: 'VALUE', value: 'active' },
  27. { type: 'ENDIDENTIFIER', value: 'AVG' },
  28. { type: 'IDENTIFIER', value: 'FROM' },
  29. { type: 'VALUE', value: 'users' },
  30. { type: 'ENDIDENTIFIER', value: 'FROM' }
  31. ]);
  32. });
  33. });
  34. });