sequelizer.aggregations.test.js 747 B

123456789101112131415161718192021222324252627
  1. var Sequelizer = require('../../../index')({ dialect: 'postgres' }).sequelizer;
  2. var analyze = require('../../support/analyze');
  3. var assert = require('assert');
  4. describe('Sequelizer ::', function() {
  5. describe('Aggregations', function() {
  6. it('should generate a SUM query', function() {
  7. var tree = analyze({
  8. sum: 'active',
  9. from: 'users'
  10. });
  11. var result = Sequelizer(tree);
  12. assert.equal(result.sql, 'select sum("active") from "users"');
  13. });
  14. it('should generate a AVG query', function() {
  15. var tree = analyze({
  16. avg: 'active',
  17. from: 'users'
  18. });
  19. var result = Sequelizer(tree);
  20. assert.equal(result.sql, 'select avg("active") from "users"');
  21. });
  22. });
  23. });