rangeutil_specs.ts 947 B

12345678910111213141516171819202122232425262728293031323334
  1. import {describe, beforeEach, it, sinon, expect} from 'test/lib/common'
  2. import rangeUtil = require('app/core/utils/rangeutil')
  3. import _ = require('lodash')
  4. import moment = require('moment')
  5. describe("rangeUtil", () => {
  6. describe("Can get range explained", () => {
  7. it('should handle simple old expression with only amount and unit', () => {
  8. var info = rangeUtil.describeTextRange('5m');
  9. expect(info.display).to.be('Last 5 minutes')
  10. });
  11. it('should have singular when amount is 1', () => {
  12. var info = rangeUtil.describeTextRange('1h');
  13. expect(info.display).to.be('Last 1 hour')
  14. });
  15. it('should handle now/d', () => {
  16. var info = rangeUtil.describeTextRange('now/d');
  17. expect(info.display).to.be('The day so far');
  18. });
  19. it('should handle now/w', () => {
  20. var info = rangeUtil.describeTextRange('now/w');
  21. expect(info.display).to.be('Week to date');
  22. });
  23. });
  24. });