mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 08:47:53 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* SortedWindowHandler assists in making e2e tests more robust by returning
|
||||
* deterministic window handles. An instance must be created before new windows
|
||||
@@ -6,16 +5,17 @@
|
||||
* closed.
|
||||
*/
|
||||
class SortedWindowHandler {
|
||||
|
||||
/**
|
||||
* Constructor, must be called before new windows were created.
|
||||
*/
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
this.client.windowHandles((result) => {
|
||||
this.client.windowHandles(result => {
|
||||
this.handles = result.value;
|
||||
if (this.handles.length > 2) {
|
||||
throw new Error('SortedWindowHandler must be created before new windows were created.');
|
||||
throw new Error(
|
||||
'SortedWindowHandler must be created before new windows were created.'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -24,20 +24,25 @@ class SortedWindowHandler {
|
||||
* windowHandles will call given `callback` with an array of window handles.
|
||||
*/
|
||||
windowHandles(callback) {
|
||||
this.client.windowHandles((result) => {
|
||||
|
||||
this.client.windowHandles(result => {
|
||||
if (result.value.message) {
|
||||
throw new Error(result.value.message);
|
||||
}
|
||||
|
||||
this.handles = this.handles.filter((handle) => result.value.includes(handle));
|
||||
const remaining = result.value.filter((handle) => !this.handles.includes(handle));
|
||||
this.handles = this.handles.filter(handle =>
|
||||
result.value.includes(handle)
|
||||
);
|
||||
const remaining = result.value.filter(
|
||||
handle => !this.handles.includes(handle)
|
||||
);
|
||||
|
||||
if (remaining.length === 1) {
|
||||
this.handles.push(remaining[0]);
|
||||
}
|
||||
if (remaining.length > 1) {
|
||||
throw new Error('Cannot detect new window handle, because more than one windows was created.');
|
||||
throw new Error(
|
||||
'Cannot detect new window handle, because more than one windows was created.'
|
||||
);
|
||||
}
|
||||
callback(this.handles);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user