summaryrefslogtreecommitdiff
path: root/spec/frontend/cycle_analytics/limit_warning_component_spec.js
blob: 3dac74389095b3222f342dfd4f2151fa02cce304 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import LimitWarningComponent from '~/cycle_analytics/components/limit_warning_component.vue';
import Translate from '~/vue_shared/translate';

Vue.use(Translate);

const createComponent = (props) =>
  shallowMount(LimitWarningComponent, {
    propsData: {
      ...props,
    },
  });

describe('Limit warning component', () => {
  let component;

  beforeEach(() => {
    component = null;
  });

  afterEach(() => {
    component.destroy();
  });

  it('should not render if count is not exactly than 50', () => {
    component = createComponent({ count: 5 });

    expect(component.text().trim()).toBe('');

    component = createComponent({ count: 55 });

    expect(component.text().trim()).toBe('');
  });

  it('should render if count is exactly 50', () => {
    component = createComponent({ count: 50 });

    expect(component.text().trim()).toBe('Showing 50 events');
  });
});