query_part_specs.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
  2. import queryPart from '../query_part';
  3. describe('InfluxQueryPart', () => {
  4. describe('series with mesurement only', () => {
  5. it('should handle nested function parts', () => {
  6. var part = queryPart.create({
  7. type: 'derivative',
  8. params: ['10s'],
  9. });
  10. expect(part.text).to.be('derivative(10s)');
  11. expect(part.render('mean(value)')).to.be('derivative(mean(value), 10s)');
  12. });
  13. it('should handle suffirx parts', () => {
  14. var part = queryPart.create({
  15. type: 'math',
  16. params: ['/ 100'],
  17. });
  18. expect(part.text).to.be('math(/ 100)');
  19. expect(part.render('mean(value)')).to.be('mean(value) / 100');
  20. });
  21. it('should handle alias parts', () => {
  22. var part = queryPart.create({
  23. type: 'alias',
  24. params: ['test'],
  25. });
  26. expect(part.text).to.be('alias(test)');
  27. expect(part.render('mean(value)')).to.be('mean(value) AS "test"');
  28. });
  29. });
  30. });