getEventsUrlPathFromDiscoverQuery.spec.jsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {getEventsUrlPathFromDiscoverQuery} from 'app/views/dashboards/utils/getEventsUrlPathFromDiscoverQuery';
  2. describe('getEventsUrlPathFromDiscoverQuery', function() {
  3. const organization = TestStubs.Organization();
  4. const query = {
  5. name: 'Known Users',
  6. projects: [1],
  7. fields: [],
  8. conditions: [['user.email', 'IS NOT NULL', null]],
  9. aggregations: [['uniq', 'user.email', 'Known Users']],
  10. limit: 1000,
  11. orderby: '-time',
  12. groupby: ['time'],
  13. rollup: 86400,
  14. };
  15. it('handles nulls in selection', function() {
  16. expect(
  17. getEventsUrlPathFromDiscoverQuery({
  18. organization,
  19. selection: {
  20. datetime: {
  21. start: null,
  22. end: null,
  23. period: '14d',
  24. },
  25. },
  26. query,
  27. })
  28. ).toBe(
  29. '/organizations/org-slug/events/?query=%21user.email%3A%22%22&statsPeriod=14d'
  30. );
  31. });
  32. it('has right absolute dates', function() {
  33. expect(
  34. getEventsUrlPathFromDiscoverQuery({
  35. organization,
  36. selection: {
  37. datetime: {
  38. start: new Date(),
  39. end: new Date(),
  40. },
  41. },
  42. query,
  43. values: [null, 'iPhone X'],
  44. })
  45. ).toBe(
  46. '/organizations/org-slug/events/?end=2017-10-17T02%3A41%3A20&query=%21user.email%3A%22%22&start=2017-10-17T02%3A41%3A20'
  47. );
  48. });
  49. it('has projects', function() {
  50. expect(
  51. getEventsUrlPathFromDiscoverQuery({
  52. organization,
  53. selection: {
  54. projects: [1],
  55. datetime: {start: null, end: null, period: '14d'},
  56. },
  57. query,
  58. })
  59. ).toBe(
  60. '/organizations/org-slug/events/?project=1&query=%21user.email%3A%22%22&statsPeriod=14d'
  61. );
  62. });
  63. });