-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add persist: false option to createWindow #247
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ class MockDesktop { | |
public static application: any = { | ||
eventListeners: new Map(), | ||
uuid: "uuid", | ||
getChildWindows(callback) { callback([MockWindow.singleton]); }, | ||
getChildWindows(callback) { callback([MockWindow.singleton, new MockWindow("Window2", JSON.stringify({ persist: false }))]); }, | ||
setTrayIcon() { }, | ||
getWindow() { return MockWindow.singleton; }, | ||
addEventListener(eventName, listener) { | ||
|
@@ -60,9 +60,11 @@ class MockInterApplicationBus { | |
class MockWindow { | ||
static singleton: MockWindow = new MockWindow("Singleton"); | ||
public nativeWindow: Window = jasmine.createSpyObj("window", ["location", "getState", "setState"]); | ||
private customData: string; | ||
|
||
constructor(name?: string) { | ||
constructor(name?: string, customData?: string) { | ||
this.name = name; | ||
this.customData = customData; | ||
} | ||
|
||
public name: string; | ||
|
@@ -142,7 +144,7 @@ class MockWindow { | |
} | ||
|
||
getOptions(callback: (options: any) => void, error: (reason) => void): any { | ||
callback({ url: "url" }); | ||
callback({ url: "url", customData: this.customData }); | ||
return {}; | ||
} | ||
|
||
|
@@ -647,72 +649,80 @@ describe("OpenFinContainer", () => { | |
container.addListener("window-created", () => done()); | ||
MockDesktop.application.emit('window-created', { name: "name" }); | ||
}); | ||
}); | ||
|
||
describe("window management", () => { | ||
it("getAllWindows returns wrapped native windows", (done) => { | ||
container.getAllWindows().then(windows => { | ||
expect(windows).not.toBeNull(); | ||
expect(windows.length).toEqual(2); | ||
expect(windows[0].innerWindow).toEqual(MockWindow.singleton); | ||
done(); | ||
}); | ||
describe("window management", () => { | ||
it("getAllWindows returns wrapped native windows", (done) => { | ||
container.getAllWindows().then(windows => { | ||
expect(windows).not.toBeNull(); | ||
expect(windows.length).toEqual(3); | ||
expect(windows[0].innerWindow).toEqual(MockWindow.singleton); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe("getWindow", () => { | ||
it("getWindowById returns wrapped window", (done) => { | ||
container.getWindowById("Singleton").then(win => { | ||
expect(win).toBeDefined(); | ||
expect(win.id).toEqual("Singleton"); | ||
done(); | ||
}); | ||
describe("getWindow", () => { | ||
it("getWindowById returns wrapped window", (done) => { | ||
container.getWindowById("Singleton").then(win => { | ||
expect(win).toBeDefined(); | ||
expect(win.id).toEqual("Singleton"); | ||
done(); | ||
}); | ||
}); | ||
|
||
it ("getWindowById with unknown id returns null", (done) => { | ||
container.getWindowById("DoesNotExist").then(win => { | ||
expect(win).toBeNull(); | ||
done(); | ||
}); | ||
it ("getWindowById with unknown id returns null", (done) => { | ||
container.getWindowById("DoesNotExist").then(win => { | ||
expect(win).toBeNull(); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("getWindowByName returns wrapped window", (done) => { | ||
container.getWindowByName("Singleton").then(win => { | ||
expect(win).toBeDefined(); | ||
expect(win.id).toEqual("Singleton"); | ||
done(); | ||
}); | ||
it("getWindowByName returns wrapped window", (done) => { | ||
container.getWindowByName("Singleton").then(win => { | ||
expect(win).toBeDefined(); | ||
expect(win.id).toEqual("Singleton"); | ||
done(); | ||
}); | ||
}); | ||
|
||
it ("getWindowByName with unknown name returns null", (done) => { | ||
container.getWindowByName("DoesNotExist").then(win => { | ||
expect(win).toBeNull(); | ||
done(); | ||
}); | ||
it ("getWindowByName with unknown name returns null", (done) => { | ||
container.getWindowByName("DoesNotExist").then(win => { | ||
expect(win).toBeNull(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it("closeAllWindows invokes window.close", (done) => { | ||
spyOn(MockWindow.singleton, "close").and.callThrough(); | ||
(<any>container).closeAllWindows().then(done).catch(error => { | ||
it("closeAllWindows invokes window.close", (done) => { | ||
spyOn(MockWindow.singleton, "close").and.callThrough(); | ||
(<any>container).closeAllWindows().then(done).catch(error => { | ||
fail(error); | ||
done(); | ||
});; | ||
expect(MockWindow.singleton.close).toHaveBeenCalled(); | ||
}); | ||
|
||
it("saveLayout invokes underlying saveLayoutToStorage", (done) => { | ||
spyOn<any>(container, "saveLayoutToStorage").and.stub(); | ||
container.saveLayout("Test") | ||
.then(layout => { | ||
expect(layout).toBeDefined(); | ||
expect((<any>container).saveLayoutToStorage).toHaveBeenCalledWith("Test", layout); | ||
done(); | ||
}).catch(error => { | ||
fail(error); | ||
done(); | ||
});; | ||
expect(MockWindow.singleton.close).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); | ||
|
||
it("saveLayout invokes underlying saveLayoutToStorage", (done) => { | ||
spyOn<any>(container, "saveLayoutToStorage").and.stub(); | ||
container.saveLayout("Test") | ||
.then(layout => { | ||
expect(layout).toBeDefined(); | ||
expect((<any>container).saveLayoutToStorage).toHaveBeenCalledWith("Test", layout); | ||
done(); | ||
}).catch(error => { | ||
fail(error); | ||
done(); | ||
}); | ||
}); | ||
it("buildLayout skips windows with persist false", (done) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new test added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
container.buildLayout().then(layout => { | ||
expect(layout).toBeDefined(); | ||
expect(layout.windows.length).toEqual(2); | ||
expect(layout.windows[0].name === "Singleton") | ||
}).then(done); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("notifications", () => { | ||
it("showNotification passes message and invokes underlying notification api", () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire describe block was incorrect under another describe so moved out to higher level