summaryrefslogtreecommitdiff
path: root/spec/javascripts/environments/environment_stop_spec.js.es6
blob: 3502914dbd607089c158526696ce7097f08d1185 (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
//= require vue
//= require environments/components/environment_stop
describe('Stop Component', () => {
  fixture.preload('environments/element.html');
  beforeEach(() => {
    fixture.load('environments/element.html');
  });

  it('should link to the provided URL', () => {
    const stopURL = '/stop';
    const component = new window.gl.environmentsList.StopComponent({
      el: document.querySelector('.test-dom-element'),
      propsData: {
        stop_url: stopURL,
      },
    });
    expect(component.$el.getAttribute('href')).toEqual(stopURL);
  });

  describe('When clicked', () => {
    it('Should open popup with confirmation warning', () => {
      const component = new window.gl.environmentsList.StopComponent({
        el: document.querySelector('.test-dom-element'),
        propsData: {
          stop_url: '#',
        },
      });

      let opened = false;

      spyOn(window, 'confirm').and.callFake(function () {
        opened = true;
        expect(opened).toEqual(true);
        return false;
      });
      component.$el.click();
    });
  });
});