This repository was archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgate_test.js
More file actions
96 lines (77 loc) · 3.61 KB
/
gate_test.js
File metadata and controls
96 lines (77 loc) · 3.61 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
describe("gates toggles", function () {
"use strict";
var gates,
ajax_spy;
beforeEach(function () {
setFixtures('<td>' +
'<a data-gate-id="0c3a0328-ee73-48c6-a94a-a701d21a99b8-1" data-gate-group="group" data-gate-name="name" data-gate-environment="environment" action="open"' +
'class="js_gate_button btn btn-danger">Closed' +
'</a>' +
'<div class="label label-danger">api closed</div>' +
'<br>' +
'<div id="0c3a0328-ee73-48c6-a94a-a701d21a99b8-1-button-timestamp" class="timestamp" data-toggle="tooltip"' +
'data-placement="bottom" title="" data-original-title="2016-03-10 17:19:47+0100">10 days ago' +
'</div>' +
'<div id="ticket_a73e5dcf-376b-4e2d-ae7c-53130934bcf6_env" class="timestamp">' +
'<a href="https://github.com/otto-de/gatekeeper">a73e5dcf-376b-4e2d-ae7c-53130934bcf6</a>' +
'<span class="label label-default" data-toggle="tooltip" data-placement="bottom" title=""' +
'data-original-title="Updated: 2016-03-21 16:09:59+0100">5 seconds ago</span>' +
'<a class="js_remove_button" data-ticket-id="a73e5dcf-376b-4e2d-ae7c-53130934bcf6">' +
'<span class="glyphicon glyphicon-trash"></span>' +
'</a>' +
'</div>' +
'</td>');
gates = o_p13n.tools.gates();
});
describe("click on button and", function () {
beforeEach(function() {
gates.init();
ajax_spy = spyOn($, "ajax");
});
it("sends request", function () {
$('.js_gate_button').trigger('click');
expect(ajax_spy.calls.mostRecent().args[0]["type"]).toEqual("PUT");
expect(ajax_spy.calls.mostRecent().args[0]["url"]).toEqual("/api/gates/group/name/environment");
});
});
describe("click on delete and", function () {
beforeEach(function() {
gates.init();
ajax_spy = spyOn($, "ajax");
});
it("sends request", function () {
$('.js_remove_button').trigger('click');
expect(ajax_spy.calls.mostRecent().args[0]["type"]).toEqual("DELETE");
expect(ajax_spy.calls.mostRecent().args[0]["url"]).toEqual("/api/tickets/a73e5dcf-376b-4e2d-ae7c-53130934bcf6");
});
});
});
describe("textarea", function () {
"use strict";
var gates,
ajax_spy;
beforeEach(function () {
setFixtures('<textarea class="textarea js_gate_textarea" data-gate-group="some-group" data-gate-name="some-service" data-gate-environment="develop" rows="2" style="height: 50px;">Some Text</textarea>');
gates = o_p13n.tools.gates();
});
describe("", function () {
beforeEach(function(done) {
gates.init();
ajax_spy = spyOn($, "ajax");
$('.js_gate_textarea').height(0)
$('.js_gate_textarea').val('This is a very important message\n\n\n\n');
$('.js_gate_textarea').keyup()
$('.js_gate_textarea').focus()
setTimeout(function() {
done();
}, 1000);
});
it("saves on input", function (done) {
expect(ajax_spy.calls.mostRecent().args[0]["type"]).toEqual("PUT");
expect(ajax_spy.calls.mostRecent().args[0]["url"]).toEqual("/api/gates/some-group/some-service/develop");
expect(ajax_spy.calls.mostRecent().args[0]["data"]).toEqual('{"message":"This is a very important message\\n\\n\\n\\n"}');
expect($('.js_gate_textarea').height()).toBeGreaterThan(50);
done();
});
});
});