Skip to content

Commit 891321b

Browse files
authored
Merge pull request #897 from mtgto/fix_doc_and_type
Fix doc and type
2 parents d5d4a60 + 38044c8 commit 891321b

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ property which do not require Node integration.
208208

209209
#### client
210210

211-
Spectron uses [WebdriverIO](http://webdriver.io) and exposes the managed
211+
Spectron uses [WebdriverIO](https://webdriver.io) and exposes the managed
212212
`client` property on the created `Application` instances.
213213

214214
The `client` API is WebdriverIO's `browser` object. Documentation can be found
215-
[here](http://webdriver.io/api.html).
215+
[here](https://webdriver.io/docs/api).
216216

217217
Several additional commands are provided specific to Electron.
218218

@@ -221,8 +221,10 @@ All the commands return a `Promise`.
221221
So if you wanted to get the text of an element you would do:
222222

223223
```js
224-
app.client.getText('#error-alert').then(function (errorText) {
225-
console.log('The #error-alert text content is ' + errorText)
224+
app.client.$('#error-alert').then(function (element) {
225+
element.getText().then(function (errorText) {
226+
console.log('The #error-alert text content is ' + errorText)
227+
})
226228
})
227229
```
228230

@@ -239,9 +241,8 @@ API in your tests you would do:
239241

240242
```js
241243
app.electron.clipboard.writeText('pasta')
242-
.electron.clipboard.readText().then(function (clipboardText) {
243-
console.log('The clipboard text is ' + clipboardText)
244-
})
244+
const clipboardText = app.electron.clipboard.readText()
245+
console.log('The clipboard text is ' + clipboardText)
245246
```
246247

247248
#### browserWindow
@@ -651,7 +652,7 @@ test.afterEach(t => {
651652
return t.context.app.stop();
652653
});
653654
654-
test(t => {
655+
test('opens a window', t => {
655656
return t.context.app.client.waitUntilWindowLoaded()
656657
.getWindowCount().then(count => {
657658
t.is(count, 1);
@@ -688,7 +689,7 @@ test.afterEach.always(async t => {
688689
await t.context.app.stop();
689690
});
690691
691-
test(async t => {
692+
test('example', async t => {
692693
const app = t.context.app;
693694
await app.client.waitUntilWindowLoaded();
694695

lib/spectron.d.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,19 @@ declare module 'spectron' {
118118
): Promise<AccessibilityAuditResult>;
119119
}
120120

121-
export interface SpectronWindow extends Electron.BrowserWindow {
122-
capturePage(): Promise<Electron.NativeImage>;
123-
}
121+
export type SpectronWindow = {
122+
[P in keyof Electron.BrowserWindow]: Electron.BrowserWindow[P] extends (
123+
...args: infer A
124+
) => infer R
125+
? (...args: A) => Promise<R>
126+
: undefined;
127+
};
124128

125129
export interface SpectronWebContents extends Electron.WebContents {
126130
savePage(
127131
fullPath: string,
128132
saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML',
129-
callback?: (eror: Error) => void
133+
callback?: (error: Error) => void
130134
): boolean;
131135
savePage(
132136
fullPath: string,

0 commit comments

Comments
 (0)