handle misformed tabstate

This commit is contained in:
nightwing 2017-02-19 15:52:14 +04:00
parent dc91171b1a
commit 0841961fc7
2 changed files with 22 additions and 12 deletions

View File

@ -498,8 +498,13 @@ define(function(require, module, exports) {
state.pane = panes[i];
}
if (!state.pane) {
throw new Error("Called open too early. Please wait until "
+ "a pane is available. Use the ready event.");
if (isReady) {
state.pane = createPane({});
container.appendChild(state.pane.aml);
} else {
throw new Error("Called open too early. Please wait until "
+ "a pane is available. Use the ready event.");
}
}
}

View File

@ -54,16 +54,6 @@ require(["lib/architect/architect", "lib/chai/chai"],
},
"plugins/c9.fs/fs.cache.xml",
// Mock plugins
{
consumes: ["apf", "ui", "Plugin"],
provides: [
"commands", "menus", "commands", "layout", "watcher", "proc",
"save", "anims", "clipboard", "dialog.alert", "auth.bootstrap",
"info", "dialog.error"
],
setup: expect.html.mocked
},
{
consumes: ["tabManager", "ui", "fs.cache", "fs"],
provides: [],
@ -112,6 +102,21 @@ require(["lib/architect/architect", "lib/chai/chai"],
var text;
describe("open(), openFile(), openEditor() and reload()", function() {
it('should recover from state with no panes', function(done) {
var oldState = tabs.getState();
tabs.setState({
"nodes": [],
"type": "hsplitbox"
}, function() {});
tabs.openEditor("timeview", function(err, tab) {
expect(tabs.getTabs()).length(1);
expect(tabs.focussedTab)
.to.exist
.to.equal(tab);
tabs.setState(oldState, done);
});
});
it('should open a pane from a path', function(done) {
var vpath = "/file.txt";
tabs.openFile(vpath, function(err, tab) {