thin_man 0.19.5 → 0.19.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/thin_man.js +931 -925
- data/lib/thin_man/version.rb +1 -1
- data/test/javascript/karma.conf.js +49 -44
- data/test/javascript/spec/thinManSpec.js +254 -214
- metadata +3 -3
data/lib/thin_man/version.rb
CHANGED
@@ -2,70 +2,75 @@
|
|
2
2
|
// Generated on Thu Sep 10 2015 16:43:39 GMT-0500 (COT)
|
3
3
|
|
4
4
|
module.exports = function(config) {
|
5
|
-
|
5
|
+
config.set({
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
// base path that will be used to resolve all patterns (eg. files, exclude)
|
8
|
+
basePath: '',
|
9
9
|
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
// frameworks to use
|
12
|
+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
13
|
+
frameworks: ['jasmine-ajax', 'jasmine', 'requirejs'],
|
14
14
|
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
// list of files / patterns to load in the browser
|
17
|
+
files: [
|
18
|
+
'test-main.js',
|
19
|
+
{ pattern: 'jquery.js' },
|
20
|
+
{ pattern: 'jasmine-fixture.js' },
|
21
|
+
{ pattern: '../../app/assets/javascripts/thin_man.js' },
|
22
|
+
{ pattern: '../../app/assets/javascripts/debug_logger.js' },
|
23
|
+
{ pattern: 'spec/helpers/*.js' },
|
24
|
+
{ pattern: 'spec/**/*Spec.js', included: false }
|
25
|
+
],
|
26
26
|
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
],
|
28
|
+
// list of files to exclude
|
29
|
+
exclude: [],
|
31
30
|
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
},
|
32
|
+
// preprocess matching files before serving them to the browser
|
33
|
+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
34
|
+
preprocessors: {},
|
37
35
|
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
// test results reporter to use
|
38
|
+
// possible values: 'dots', 'progress'
|
39
|
+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
40
|
+
reporters: ['spec'],
|
43
41
|
|
44
42
|
|
45
|
-
|
46
|
-
|
43
|
+
// web server port
|
44
|
+
port: 9876,
|
47
45
|
|
48
46
|
|
49
|
-
|
50
|
-
|
47
|
+
// enable / disable colors in the output (reporters and logs)
|
48
|
+
colors: true,
|
51
49
|
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
// level of logging
|
52
|
+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
53
|
+
logLevel: config.LOG_INFO,
|
56
54
|
|
57
55
|
|
58
|
-
|
59
|
-
|
56
|
+
// enable / disable watching file and executing tests whenever any file changes
|
57
|
+
autoWatch: false,
|
60
58
|
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
// start these browsers
|
61
|
+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
62
|
+
browsers: ['PhantomJS'],
|
63
|
+
// customLaunchers: {
|
64
|
+
// 'PhantomJS_custom': {
|
65
|
+
// base: 'PhantomJS',
|
66
|
+
// debug: true,
|
67
|
+
// },
|
68
|
+
// },
|
69
|
+
// browsers: ['Chrome'],
|
65
70
|
|
66
71
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}
|
72
|
+
// Continuous Integration mode
|
73
|
+
// if true, Karma captures browsers, runs the tests and exits
|
74
|
+
singleRun: true
|
75
|
+
})
|
76
|
+
}
|
@@ -1,232 +1,272 @@
|
|
1
|
-
describe("thin_man", function(){
|
1
|
+
describe("thin_man", function() {
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
function getAjaxArg(arg_name) {
|
4
|
+
return $.ajax.calls.argsFor(0)[0][arg_name];
|
5
|
+
}
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
describe(".ajaxSuccess", function(){
|
14
|
-
var $link, $target, thin;
|
15
|
-
|
16
|
-
beforeEach(function(){
|
17
|
-
$link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"]');
|
18
|
-
$target = affix('#test_dom_id');
|
19
|
-
thin = new thin_man.AjaxLinkSubmission($link);
|
20
|
-
});
|
21
|
-
|
22
|
-
it("Add result to the target", function(){
|
23
|
-
thin.ajaxSuccess({ html: "Hello" }, 'success', TestResponses.success)
|
24
|
-
expect($target.html()).toEqual("Hello")
|
25
|
-
});
|
26
|
-
|
27
|
-
it("focus on first element", function(){
|
28
|
-
var form = '<form><input type="text"><textarea>dummy</textarea></form>'
|
29
|
-
thin.ajaxSuccess(form, 'success', TestResponses.success)
|
30
|
-
expect($target.html()).toEqual(form);
|
31
|
-
expect($("[type='text']").length).toEqual(1);
|
32
|
-
//Check if it's focused
|
33
|
-
expect($("[type='text']").get(0)).toBe(document.activeElement);
|
34
|
-
});
|
35
|
-
|
36
|
-
it("empties the target if there is no html in the json", function(){
|
37
|
-
$target.html('Remove me.')
|
38
|
-
thin.ajaxSuccess({flash_message: 'Successfully moved the widget.'}, 'success', TestResponses.success)
|
39
|
-
expect($target.html()).toEqual('')
|
40
|
-
})
|
41
|
-
|
42
|
-
it("handles success with no target", function(){
|
43
|
-
$no_target_link = affix('a[data-ajax-link="true"][data-ajax-target=""]');
|
44
|
-
thin = new thin_man.AjaxLinkSubmission($no_target_link);
|
45
|
-
thin.ajaxSuccess({flash_message: 'Success'},'success', TestResponses.success)
|
46
|
-
})
|
47
|
-
});
|
48
|
-
|
49
|
-
describe(".ajaxComplete", function(){
|
50
|
-
var $link, thin;
|
51
|
-
|
52
|
-
beforeEach(function(){
|
53
|
-
$link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"] #test_dom_id');
|
54
|
-
affix('[data-thin-man-flash-template] [data-thin-man-flash-content]');
|
55
|
-
thin = new thin_man.AjaxLinkSubmission($link);
|
56
|
-
});
|
7
|
+
describe("Base class", function() {
|
8
|
+
beforeAll(function() {
|
9
|
+
jasmine.Ajax.install();
|
10
|
+
jasmine.clock().install();
|
11
|
+
});
|
57
12
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
13
|
+
describe(".ajaxSuccess", function() {
|
14
|
+
var $link, $target, thin;
|
15
|
+
|
16
|
+
beforeEach(function() {
|
17
|
+
$link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"]');
|
18
|
+
$target = affix('#test_dom_id');
|
19
|
+
thin = new thin_man.AjaxLinkSubmission($link);
|
20
|
+
});
|
21
|
+
|
22
|
+
it("Add result to the target", function() {
|
23
|
+
thin.ajaxSuccess({ html: "Hello" }, 'success', TestResponses.success)
|
24
|
+
expect($target.html()).toEqual("Hello")
|
25
|
+
});
|
26
|
+
|
27
|
+
it("focus on first element", function() {
|
28
|
+
var form = '<form><input type="text"><textarea>dummy</textarea></form>'
|
29
|
+
thin.ajaxSuccess(form, 'success', TestResponses.success)
|
30
|
+
expect($target.html()).toEqual(form);
|
31
|
+
expect($("[type='text']").length).toEqual(1);
|
32
|
+
//Check if it's focused
|
33
|
+
expect($("[type='text']").get(0)).toBe(document.activeElement);
|
34
|
+
});
|
35
|
+
|
36
|
+
it("empties the target if there is no html in the json", function() {
|
37
|
+
$target.html('Remove me.')
|
38
|
+
thin.ajaxSuccess({ flash_message: 'Successfully moved the widget.' }, 'success', TestResponses.success)
|
39
|
+
expect($target.html()).toEqual('')
|
40
|
+
})
|
41
|
+
|
42
|
+
it("handles success with no target", function() {
|
43
|
+
$no_target_link = affix('a[data-ajax-link="true"][data-ajax-target=""]');
|
44
|
+
thin = new thin_man.AjaxLinkSubmission($no_target_link);
|
45
|
+
thin.ajaxSuccess({ flash_message: 'Success' }, 'success', TestResponses.success)
|
46
|
+
})
|
62
47
|
});
|
63
48
|
|
64
|
-
|
65
|
-
|
66
|
-
|
49
|
+
describe(".ajaxComplete", function() {
|
50
|
+
var $link, thin;
|
51
|
+
|
52
|
+
beforeEach(function() {
|
53
|
+
$link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"] #test_dom_id');
|
54
|
+
affix('[data-thin-man-flash-template] [data-thin-man-flash-content]');
|
55
|
+
thin = new thin_man.AjaxLinkSubmission($link);
|
56
|
+
});
|
57
|
+
|
58
|
+
describe("Display flash message", function() {
|
59
|
+
it("successfully response", function() {
|
60
|
+
thin.ajaxComplete(TestResponses.success);
|
61
|
+
expect(thin.flash.flash_content.text()).toMatch('successfully response');
|
62
|
+
});
|
63
|
+
|
64
|
+
it("error response", function() {
|
65
|
+
thin.ajaxComplete(TestResponses.error);
|
66
|
+
expect(thin.flash.flash_content.text()).toMatch('error response');
|
67
|
+
});
|
68
|
+
});
|
69
|
+
|
70
|
+
it("fade out if flash_persist is false", function() {
|
71
|
+
spyOn($.fn, 'fadeOut');
|
72
|
+
thin.ajaxComplete(TestResponses.success);
|
73
|
+
jasmine.clock().tick(2000);
|
74
|
+
expect($.fn.fadeOut).toHaveBeenCalled();
|
75
|
+
});
|
67
76
|
});
|
68
|
-
});
|
69
|
-
|
70
|
-
it("fade out if flash_persist is false", function(){
|
71
|
-
spyOn($.fn, 'fadeOut');
|
72
|
-
thin.ajaxComplete(TestResponses.success);
|
73
|
-
jasmine.clock().tick(2000);
|
74
|
-
expect($.fn.fadeOut).toHaveBeenCalled();
|
75
|
-
});
|
76
|
-
});
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
describe(".ajaxError", function() {
|
79
|
+
var $link, thin;
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
beforeEach(function() {
|
82
|
+
$link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"]');
|
83
|
+
$target = affix('#test_dom_id');
|
84
|
+
thin = new thin_man.AjaxLinkSubmission($link);
|
85
|
+
});
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
it('as a string', function() {
|
88
|
+
thin.ajaxError(TestResponses.conflictString);
|
89
|
+
expect($('#test_dom_id').html()).toMatch('conflict string response');
|
90
|
+
});
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
it('as an object', function() {
|
93
|
+
thin.ajaxError(TestResponses.conflict);
|
94
|
+
expect($('#test_dom_id').html()).toMatch('Required field');
|
95
|
+
});
|
96
96
|
|
97
|
+
});
|
97
98
|
});
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
99
|
+
|
100
|
+
describe("AjaxLinkSubmission", function() {
|
101
|
+
it("submits an ajax call with options", function() {
|
102
|
+
var $link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"][href="/url"][data-ajax-method="PATCH"][data-return-type="json"]');
|
103
|
+
thin_man.AjaxLinkSubmission($link)
|
104
|
+
spyOn($, 'ajax');
|
105
|
+
$link.click();
|
106
|
+
expect($.ajax).toHaveBeenCalled();
|
107
|
+
expect(getAjaxArg("url")).toMatch("/url");
|
108
|
+
expect(getAjaxArg("type")).toMatch("PATCH");
|
109
|
+
expect(getAjaxArg("datatype")).toMatch("json");
|
110
|
+
expect(thin_man.hasOwnProperty('link_groups')).toEqual(false)
|
111
|
+
});
|
112
|
+
it("fires grouped links in sequence", function() {
|
113
|
+
var $link_zero = affix('a[data-ajax-link-now="true"][data-ajax-target="#test_dom_id"][href="/url"][data-ajax-method="PATCH"][data-sequence-group="test_group"][data-sequence-number="0"]');
|
114
|
+
var $link_one = affix('a[data-ajax-link-now="true"][data-ajax-target="#test_dom_id"][href="/url"][data-ajax-method="PATCH"][data-sequence-group="test_group"][data-sequence-number="1"]');
|
115
|
+
var $link_two = affix('a[data-ajax-link-now="true"][data-ajax-target="#test_dom_id"][href="/url"][data-ajax-method="PATCH"][data-sequence-group="test_group"][data-sequence-number="2"]');
|
116
|
+
zero = new thin_man.AjaxLinkSubmission($link_zero)
|
117
|
+
one = new thin_man.AjaxLinkSubmission($link_one)
|
118
|
+
two = new thin_man.AjaxLinkSubmission($link_two)
|
119
|
+
expect(thin_man.hasOwnProperty('link_groups')).toEqual(true)
|
120
|
+
spyOn(one, 'fire')
|
121
|
+
spyOn(two, 'fire')
|
122
|
+
zero.ajaxComplete()
|
123
|
+
expect(one.fire).toHaveBeenCalled();
|
124
|
+
expect(two.fire).not.toHaveBeenCalled();
|
125
|
+
one.ajaxComplete()
|
126
|
+
expect(one.fire.calls.count()).toEqual(1);
|
127
|
+
expect(two.fire).toHaveBeenCalled();
|
128
|
+
})
|
111
129
|
});
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
130
|
+
describe("DeleteLink", function() {
|
131
|
+
it("submits an ajax delete call with options", function() {
|
132
|
+
var $link = affix('a[data-ajax-delete="true"][data-ajax-target="#test_dom_id"][href="/url"]');
|
133
|
+
var delete_link = new thin_man.DeleteLink($link)
|
134
|
+
spyOn($, 'ajax');
|
135
|
+
$link.click();
|
136
|
+
expect($.ajax).toHaveBeenCalled();
|
137
|
+
expect(delete_link.getAjaxType()).toEqual('DELETE')
|
138
|
+
expect(delete_link.getAjaxUrl()).toEqual('/url')
|
139
|
+
expect(delete_link.trigger).toEqual($link)
|
140
|
+
})
|
141
|
+
it("removes target after delete", function() {
|
142
|
+
var $link = affix('a#test_dom_id[data-ajax-delete="true"][data-ajax-target="#test_dom_id"][href="/url"]');
|
143
|
+
var data = "";
|
144
|
+
var textStatus = "success";
|
145
|
+
var jqXHR = new XMLHttpRequest();
|
146
|
+
var delete_link = new thin_man.DeleteLink($link)
|
147
|
+
|
148
|
+
delete_link.ajaxSuccess(data, textStatus, jqXHR)
|
149
|
+
|
150
|
+
expect($('#test_dom_id').length).toEqual(0)
|
151
|
+
})
|
152
|
+
it("replaces response after target after delete", function() {
|
153
|
+
var $div = affix('div#test_dom_id')
|
154
|
+
var $link = $div.affix('a[data-ajax-delete="true"][data-ajax-target="#test_dom_id"][href="/url"]');
|
155
|
+
var data = "I'm The Replacement Data";
|
156
|
+
var textStatus = "success";
|
157
|
+
var jqXHR = new XMLHttpRequest();
|
158
|
+
var delete_link = new thin_man.DeleteLink($link)
|
159
|
+
|
160
|
+
delete_link.ajaxSuccess(data, textStatus, jqXHR)
|
161
|
+
|
162
|
+
expect($('#test_dom_id').html()).toEqual(data)
|
163
|
+
})
|
164
|
+
it("replaces response after target after delete and renders flash message", function() {
|
165
|
+
var $div = affix('div#test_dom_id')
|
166
|
+
var $link = $div.affix('a[data-ajax-delete="true"][data-ajax-target="#test_dom_id"][href="/url"]');
|
167
|
+
var $flash = affix('div[data-thin-man-flash-template]');
|
168
|
+
var $content = $flash.affix('div[data-thin-man-flash-content]')
|
169
|
+
|
170
|
+
var data = { html: "I'm Barry Allen", flash_message: "I'm the flash" }
|
171
|
+
var textStatus = "success";
|
172
|
+
var jqXHR = { responseText: JSON.stringify(data) }
|
173
|
+
var delete_link = new thin_man.DeleteLink($link)
|
174
|
+
|
175
|
+
delete_link.ajaxSuccess(data, textStatus, jqXHR)
|
176
|
+
delete_link.ajaxComplete(jqXHR)
|
177
|
+
|
178
|
+
expect($('#test_dom_id').html()).toEqual(data.html)
|
179
|
+
expect($('body').html()).toContain(data.flash_message)
|
180
|
+
})
|
153
181
|
});
|
182
|
+
describe("AjaxFormSubmission", function() {
|
183
|
+
it("submits an ajax call with options", function() {
|
184
|
+
var $form = affix('form[data-ajax-form="true"][method="PATCH"][action="/url"]');
|
185
|
+
$form.affix('input[type="text"][name="name"][value="Jon Snow"]')
|
186
|
+
thin_man.AjaxFormSubmission($form)
|
187
|
+
spyOn($, 'ajax');
|
188
|
+
$form.submit();
|
189
|
+
expect($.ajax).toHaveBeenCalled();
|
190
|
+
expect(getAjaxArg("url")).toMatch("/url");
|
191
|
+
expect(getAjaxArg("type")).toMatch("PATCH");
|
192
|
+
expect(getAjaxArg("datatype")).toMatch("html");
|
193
|
+
});
|
154
194
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
195
|
+
describe("GET request", function() {
|
196
|
+
var $form;
|
197
|
+
|
198
|
+
beforeEach(function() {
|
199
|
+
$form = affix('form[data-ajax-form="true"][action="/url"][method="GET"]');
|
200
|
+
});
|
201
|
+
|
202
|
+
it("serialize data", function() {
|
203
|
+
$form.affix('input[type="text"][name="name"][value="Jon Snow"]');
|
204
|
+
var thin = new thin_man.AjaxFormSubmission($form);
|
205
|
+
spyOn($, 'ajax');
|
206
|
+
$form.submit();
|
207
|
+
expect($.ajax).toHaveBeenCalled();
|
208
|
+
expect(thin.ajax_options.data).toEqual([{ name: 'name', value: 'Jon Snow' }, { name: 'thin_man_submitter', value: 'link_now' }]);
|
209
|
+
});
|
210
|
+
|
211
|
+
it(".getProcessData", function() {
|
212
|
+
var thin = new thin_man.AjaxFormSubmission($form)
|
213
|
+
expect(thin.getProcessData()).toBe(true);
|
214
|
+
});
|
215
|
+
|
216
|
+
it(".sendContentType", function() {
|
217
|
+
var thin = new thin_man.AjaxFormSubmission($form)
|
218
|
+
expect(thin.sendContentType()).toBe(true);
|
219
|
+
});
|
220
|
+
});
|
181
221
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
222
|
+
describe("POST/PATCH/DELETE request", function() {
|
223
|
+
var $form;
|
224
|
+
beforeEach(function() {
|
225
|
+
$form = affix('form[data-ajax-form="true"][action="/url"]');
|
226
|
+
});
|
227
|
+
|
228
|
+
it("Set data in a FormData object", function() {
|
229
|
+
thin_man.AjaxFormSubmission($form)
|
230
|
+
spyOn($, 'ajax');
|
231
|
+
$form.submit();
|
232
|
+
expect(getAjaxArg("data")).toEqual(jasmine.any(FormData));
|
233
|
+
});
|
234
|
+
|
235
|
+
it(".getProcessData", function() {
|
236
|
+
var thin = new thin_man.AjaxFormSubmission($form)
|
237
|
+
expect(thin.getProcessData()).toBe(false);
|
238
|
+
});
|
239
|
+
|
240
|
+
it(".sendContentType", function() {
|
241
|
+
var thin = new thin_man.AjaxFormSubmission($form)
|
242
|
+
expect(thin.sendContentType()).toBe(false);
|
243
|
+
});
|
244
|
+
});
|
205
245
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
246
|
+
describe("Log", function() {
|
247
|
+
beforeEach(function() {
|
248
|
+
spyOn(console, 'log');
|
249
|
+
});
|
250
|
+
|
251
|
+
it("Don't show a warning with a valid target", function() {
|
252
|
+
$link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"]');
|
253
|
+
$target = affix('#test_dom_id');
|
254
|
+
thin = new thin_man.AjaxLinkSubmission($link);
|
255
|
+
expect(console.log).not.toHaveBeenCalled();
|
256
|
+
});
|
257
|
+
|
258
|
+
it("Show a warning when target not found", function() {
|
259
|
+
$link = affix('a[data-ajax-link="true"][data-ajax-target="#not_valid_target"]');
|
260
|
+
thin = new thin_man.AjaxLinkSubmission($link);
|
261
|
+
expect(console.log).toHaveBeenCalledWith('Warning! Thin Man selector #not_valid_target not found');
|
262
|
+
});
|
263
|
+
|
264
|
+
it("Show a warning when target not provided", function() {
|
265
|
+
$link = affix('a[data-ajax-link="true"]');
|
266
|
+
thin = new thin_man.AjaxLinkSubmission($link);
|
267
|
+
expect(console.log).toHaveBeenCalledWith('Warning! Thin Man selector not given');
|
268
|
+
});
|
269
|
+
});
|
230
270
|
|
231
|
-
|
232
|
-
});
|
271
|
+
});
|
272
|
+
});
|