tokenizer.del.test.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var Tokenizer = require('../../../index').query.tokenizer;
  2. var assert = require('assert');
  3. describe('Tokenizer ::', function() {
  4. describe('DELETE statements', function() {
  5. it('should generate a valid token array for an DELETE is used', function() {
  6. var result = Tokenizer({
  7. del: true,
  8. from: 'accounts',
  9. where: {
  10. and: [
  11. {
  12. activated: false
  13. }
  14. ]
  15. }
  16. });
  17. assert.deepEqual(result, [
  18. { type: 'IDENTIFIER', value: 'DELETE' },
  19. { type: 'ENDIDENTIFIER', value: 'DELETE' },
  20. { type: 'IDENTIFIER', value: 'FROM' },
  21. { type: 'VALUE', value: 'accounts' },
  22. { type: 'ENDIDENTIFIER', value: 'FROM' },
  23. { type: 'IDENTIFIER', value: 'WHERE' },
  24. { type: 'CONDITION', value: 'AND' },
  25. { type: 'GROUP', value: 0 },
  26. { type: 'KEY', value: 'activated' },
  27. { type: 'VALUE', value: false },
  28. { type: 'ENDGROUP', value: 0 },
  29. { type: 'ENDCONDITION', value: 'AND' },
  30. { type: 'ENDIDENTIFIER', value: 'WHERE' }
  31. ]);
  32. });
  33. });
  34. });