Skip to content

Commit

Permalink
Update example to use getMenuItem
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hahn committed Jan 24, 2018
1 parent 4dac07a commit b3ca355
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"electron-prebuilt": "^1.4.13",
"mocha": "^5.0.0",
"spectron": "^3.7.2",
"spectron-menu-addon": "0.3.0",
"spectron-menu-addon": "0.3.2",
"ts-loader": "^3.3.1",
"ts-node": "^4.1.0",
"tslint": "^5.9.1",
Expand Down
7 changes: 5 additions & 2 deletions example/test/disabled-menu-item.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import menuAddon from 'spectron-menu-addon'
import ExamplePage from './pageobject/example.page'
import { expect } from 'chai'
import { MenuItem } from 'electron'

describe('Menu items status', () => {
let page: ExamplePage
Expand All @@ -15,10 +16,12 @@ describe('Menu items status', () => {
})

it('should verify File->Increment as enabled', async () => {
expect(await page.isItemEnabled('Count', 'Increment')).to.equal(true)
const menuItem = await page.getMenuItem('Count', 'Increment')
expect(menuItem.enabled).to.equal(true)
})

it('should verify File->Reset as disabled', async () => {
expect(await page.isItemEnabled('Count', 'Reset')).to.equal(false)
const menuItem = await page.getMenuItem('Count', 'Reset')
expect(menuItem.enabled).to.equal(false)
})
})
5 changes: 3 additions & 2 deletions example/test/pageobject/example.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Application } from 'spectron'
import menuAddon from 'spectron-menu-addon'

import createApplication from './create-application'
import { MenuItem } from 'electron'

export default class ExamplePage {
app: Application
Expand Down Expand Up @@ -30,8 +31,8 @@ export default class ExamplePage {
menuAddon.clickMenu(...menuItems)
}

isItemEnabled = async (...menuItems: string[]) => {
return await menuAddon.isItemEnabled(...menuItems)
getMenuItem = async (...menuItems: string[]): Promise<MenuItem> => {
return await menuAddon.getMenuItem(...menuItems)
}

getText = async () => {
Expand Down
6 changes: 3 additions & 3 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3761,9 +3761,9 @@ spdx-license-ids@^1.0.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57"

[email protected].0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/spectron-menu-addon/-/spectron-menu-addon-0.3.0.tgz#2ac62dcde6f8c2c1c8760905050b379ed080f779"
[email protected].2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/spectron-menu-addon/-/spectron-menu-addon-0.3.2.tgz#bfdd3a7b2060faf1333c61e5310a1612dc1ec54a"

spectron@^3.7.2:
version "3.7.2"
Expand Down

0 comments on commit b3ca355

Please sign in to comment.