Skip to content

Commit 1014df8

Browse files
committed
refactor: rename interfaces
1 parent 05bca44 commit 1014df8

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

lib/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {IQueryUtils} from './typedefs'
1+
import {Queries} from './typedefs'
22

3-
export const queryNames: Array<keyof IQueryUtils> = [
3+
export const queryNames: Array<keyof Queries> = [
44
'queryByPlaceholderText',
55
'queryAllByPlaceholderText',
66
'getByPlaceholderText',

lib/fixture.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {PlaywrightTestArgs, TestFixture} from '@playwright/test'
22

33
import {getDocument, queries as unscopedQueries} from '.'
44
import {queryNames} from './common'
5-
import type {IScopedQueryUtils as Queries} from './typedefs'
5+
import type {ScopedQueries as Queries} from './typedefs'
66

77
interface TestingLibraryFixtures {
88
queries: Queries

lib/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path'
33
import {JSHandle, Page} from 'playwright'
44
import waitForExpect from 'wait-for-expect'
55

6-
import {ElementHandle, IConfigureOptions, IQueryUtils, IScopedQueryUtils} from './typedefs'
6+
import {ElementHandle, ConfigurationOptions, Queries, ScopedQueries} from './typedefs'
77
import {queryNames} from './common'
88

99
const domLibraryAsString = readFileSync(
@@ -88,11 +88,11 @@ async function covertToElementHandle(handle: JSHandle, asArray: boolean): Promis
8888
return asArray ? createElementHandleArray(handle) : createElementHandle(handle)
8989
}
9090

91-
function processNodeText(handles: IHandleSet): Promise<string> {
91+
function processNodeText(handles: HandleSet): Promise<string> {
9292
return handles.containerHandle.evaluate(handles.evaluateFn, ['getNodeText'])
9393
}
9494

95-
async function processQuery(handles: IHandleSet): Promise<DOMReturnType> {
95+
async function processQuery(handles: HandleSet): Promise<DOMReturnType> {
9696
const {containerHandle, evaluateFn, fnName, argsToForward} = handles
9797

9898
try {
@@ -111,7 +111,7 @@ async function processQuery(handles: IHandleSet): Promise<DOMReturnType> {
111111
}
112112
}
113113

114-
interface IHandleSet {
114+
interface HandleSet {
115115
containerHandle: ElementHandle
116116
// FIXME: Playwright doesn't expose a type for this like Puppeteer does with
117117
// `EvaluateFn`. This *should* be something like the `PageFunction` type that
@@ -122,9 +122,9 @@ interface IHandleSet {
122122
}
123123

124124
function createDelegateFor<T = DOMReturnType>(
125-
fnName: keyof IQueryUtils,
125+
fnName: keyof Queries,
126126
contextFn?: ContextFn,
127-
processHandleFn?: (handles: IHandleSet) => Promise<T>,
127+
processHandleFn?: (handles: HandleSet) => Promise<T>,
128128
): (...args: any[]) => Promise<T> {
129129
// @ts-ignore
130130
// eslint-disable-next-line no-param-reassign
@@ -171,7 +171,7 @@ export function wait(
171171

172172
export const waitFor = wait
173173

174-
export function configure(options: Partial<IConfigureOptions>): void {
174+
export function configure(options: Partial<ConfigurationOptions>): void {
175175
if (!options) {
176176
return
177177
}
@@ -189,7 +189,7 @@ export function configure(options: Partial<IConfigureOptions>): void {
189189
export function getQueriesForElement<T>(
190190
object: T,
191191
contextFn?: ContextFn,
192-
): T & IQueryUtils & IScopedQueryUtils {
192+
): T & Queries & ScopedQueries {
193193
const o = object as any
194194
// eslint-disable-next-line no-param-reassign
195195
if (!contextFn) contextFn = () => o
@@ -207,5 +207,5 @@ export function getQueriesForElement<T>(
207207
export const within = getQueriesForElement
208208

209209
// @ts-ignore
210-
export const queries: IQueryUtils = {}
210+
export const queries: Queries = {}
211211
getQueriesForElement(queries, el => el)

lib/typedefs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface SelectorRoleMatcherOptions extends SelectorMatcherOptions {
2121
name?: string | RegExp
2222
}
2323

24-
interface IQueryMethods {
24+
interface QueryMethods {
2525
queryByPlaceholderText(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element | null>
2626
queryAllByPlaceholderText(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element[]>
2727
getByPlaceholderText(el: Element, m: Matcher, opts?: MatcherOptions): Promise<Element>
@@ -173,16 +173,16 @@ export type BoundFunction<T> = T extends (
173173
: never
174174
export type BoundFunctions<T> = {[P in keyof T]: BoundFunction<T[P]>}
175175

176-
export interface IScopedQueryUtils extends BoundFunctions<IQueryMethods> {
177-
getQueriesForElement(): IScopedQueryUtils
176+
export interface ScopedQueries extends BoundFunctions<QueryMethods> {
177+
getQueriesForElement(): ScopedQueries
178178
getNodeText(): Promise<string>
179179
}
180180

181-
export interface IQueryUtils extends IQueryMethods {
182-
getQueriesForElement(): IScopedQueryUtils
181+
export interface Queries extends QueryMethods {
182+
getQueriesForElement(): ScopedQueries
183183
getNodeText(el: Element): Promise<string>
184184
}
185185

186-
export interface IConfigureOptions {
186+
export interface ConfigurationOptions {
187187
testIdAttribute: string
188188
}

0 commit comments

Comments
 (0)