parent
32233ccb99
commit
dc828e0e5a
2 changed files with 27 additions and 2 deletions
|
|
@ -407,8 +407,8 @@ app.views.Publisher = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
tryClose : function(){
|
tryClose : function(){
|
||||||
// if it is not submittable, close it.
|
// if it is not submittable and not in preview mode, close it.
|
||||||
if( !this._submittable() ){
|
if (!this._submittable() && !this.markdownEditor.isPreviewMode()) {
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,31 @@ describe("app.views.Publisher", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("tryClose", function() {
|
||||||
|
it("doesn't close the publisher if it is submittable", function() {
|
||||||
|
spyOn(this.view, "_submittable").and.returnValue(true);
|
||||||
|
spyOn(this.view, "close");
|
||||||
|
this.view.tryClose();
|
||||||
|
expect(this.view.close).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("doesn't close the publisher if it is in preview mode", function() {
|
||||||
|
spyOn(this.view, "_submittable").and.returnValue(false);
|
||||||
|
spyOn(this.view.markdownEditor, "isPreviewMode").and.returnValue(true);
|
||||||
|
spyOn(this.view, "close");
|
||||||
|
this.view.tryClose();
|
||||||
|
expect(this.view.close).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("closes the publisher if it is neither submittable nor in preview mode", function() {
|
||||||
|
spyOn(this.view, "_submittable").and.returnValue(false);
|
||||||
|
spyOn(this.view.markdownEditor, "isPreviewMode").and.returnValue(false);
|
||||||
|
spyOn(this.view, "close");
|
||||||
|
this.view.tryClose();
|
||||||
|
expect(this.view.close).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("_beforeUnload", function(){
|
describe("_beforeUnload", function(){
|
||||||
it("calls _submittable", function(){
|
it("calls _submittable", function(){
|
||||||
spyOn(this.view, "_submittable");
|
spyOn(this.view, "_submittable");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue