Skip to content

Commit 5fb0db8

Browse files
authored
Merge pull request #13 from aspriya/tests-for-error-handling
Tests for error handling
2 parents e401552 + 5ede23a commit 5fb0db8

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

dist/inlineMarkdownEditor.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10386,8 +10386,6 @@ module.exports = function processSection(markdown, o) {
1038610386
.done(function onComplete(response) {
1038710387
// we should need fewer things here:
1038810388
o.onComplete(response, after, html, _el, uniqueId, __form, o);
10389-
}).error(function onFail(response) {
10390-
o.onFail(response, uniqueId);
1039110389
}).fail(function onFail(response) {
1039210390
o.onFail(response, uniqueId);
1039310391
}); // these don't work?
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
describe('error handling by onFail', function () {
2+
3+
var editor, html = "A simple text line";
4+
5+
beforeEach(function() {
6+
fixture = loadFixtures('index.html');
7+
$('.markdown').html(html);
8+
editor = inlineMarkdownEditor({
9+
replaceUrl: '/wiki/replace/',
10+
selector: '.markdown'
11+
});
12+
});
13+
14+
it("should call onFail", function(){
15+
jasmine.Ajax.install();
16+
17+
spyOn(editor.options, "onComplete");
18+
spyOn(editor.options, "onFail");
19+
20+
spyOn($, "post").and.callFake(function(options) {
21+
//here options is /wiki/replace/
22+
var d = $.Deferred();
23+
d.reject("this is the response");
24+
return d.promise();
25+
});
26+
27+
$('.inline-edit-btn').click(); // generate editor by clicking the pencil icon
28+
$('.inline-edit-form button.submit').click(); //click the save button in that form to send the post request
29+
30+
expect(editor.options.onComplete).not.toHaveBeenCalled();
31+
expect(editor.options.onFail).toHaveBeenCalled();
32+
});
33+
34+
})

src/processSection.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ module.exports = function processSection(markdown, o) {
6262
.done(function onComplete(response) {
6363
// we should need fewer things here:
6464
o.onComplete(response, after, html, _el, uniqueId, __form, o);
65-
}).error(function onFail(response) {
66-
o.onFail(response, uniqueId);
6765
}).fail(function onFail(response) {
6866
o.onFail(response, uniqueId);
6967
}); // these don't work?

0 commit comments

Comments
 (0)