Skip to content

Commit

Permalink
afterOpen hook test
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala committed Oct 13, 2018
1 parent 905244b commit 384e773
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ class MyPlugin {
// not on any page loading
}

_afterOpen() { // This hook will be called after the page is opened and _loaded
_afterOpen() { // This hook will be called after the page is opened and loaded
// You can use this hook to start performing actions with evaluate or
// adding custom scripts with this._browser.page.addScriptTag
}
Expand Down
7 changes: 7 additions & 0 deletions tests/browser/plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("Plugins", () => {
this.browser = browser;
this.beforeOpenCalled = false;
this.beforeCloseCalled = false;
this.afterOpenCalled = false;
}

myMethod() {
Expand All @@ -25,6 +26,10 @@ describe("Plugins", () => {
_beforeClose() {
this.beforeCloseCalled = true;
}

_afterOpen() {
this.afterOpenCalled = true;
}
}

class AssertionPluginTest {
Expand Down Expand Up @@ -78,8 +83,10 @@ describe("Plugins", () => {
assert.ok(browser.pluginTest);
assert.strictEqual(browser.pluginTest.beforeOpenCalled, false);
assert.strictEqual(browser.pluginTest.beforeCloseCalled, false);
assert.strictEqual(browser.pluginTest.afterOpenCalled, false);
await browser.open(configUrls.index);
assert.strictEqual(browser.pluginTest.beforeOpenCalled, true);
assert.strictEqual(browser.pluginTest.afterOpenCalled, true);
assert.strictEqual(browser.pluginTest.beforeCloseCalled, false);
await browser.close();
assert.strictEqual(browser.pluginTest.beforeCloseCalled, true);
Expand Down

0 comments on commit 384e773

Please sign in to comment.