Skip to content

Commit 146a64f

Browse files
committed
naming tweaks
1 parent a47f134 commit 146a64f

File tree

10 files changed

+85
-85
lines changed

10 files changed

+85
-85
lines changed

src/helpers/debug.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export type DebugOptions = {
1212
* Log pretty-printed deep test component instance
1313
*/
1414
export function debug(
15-
instance: JsonNode | JsonNode[],
15+
node: JsonNode | JsonNode[],
1616
{ message, ...formatOptions }: DebugOptions = {},
1717
) {
1818
if (message) {
19-
logger.info(`${message}\n\n`, formatJson(instance, formatOptions));
19+
logger.info(`${message}\n\n`, formatJson(node, formatOptions));
2020
} else {
21-
logger.info(formatJson(instance, formatOptions));
21+
logger.info(formatJson(node, formatOptions));
2222
}
2323
}

src/queries/display-value.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ const matchDisplayValue = (
2929
};
3030

3131
const queryAllByDisplayValue = (
32-
instance: HostElement,
32+
element: HostElement,
3333
): QueryAllByQuery<TextMatch, ByDisplayValueOptions> =>
3434
function queryAllByDisplayValueFn(displayValue, queryOptions) {
3535
return findAll(
36-
instance,
36+
element,
3737
(node) => isHostTextInput(node) && matchDisplayValue(node, displayValue, queryOptions),
3838
queryOptions,
3939
);
@@ -59,11 +59,11 @@ export type ByDisplayValueQueries = {
5959
findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;
6060
};
6161

62-
export const bindByDisplayValueQueries = (instance: HostElement): ByDisplayValueQueries => ({
63-
getByDisplayValue: getBy(instance),
64-
getAllByDisplayValue: getAllBy(instance),
65-
queryByDisplayValue: queryBy(instance),
66-
queryAllByDisplayValue: queryAllBy(instance),
67-
findByDisplayValue: findBy(instance),
68-
findAllByDisplayValue: findAllBy(instance),
62+
export const bindByDisplayValueQueries = (element: HostElement): ByDisplayValueQueries => ({
63+
getByDisplayValue: getBy(element),
64+
getAllByDisplayValue: getAllBy(element),
65+
queryByDisplayValue: queryBy(element),
66+
queryAllByDisplayValue: queryAllBy(element),
67+
findByDisplayValue: findBy(element),
68+
findAllByDisplayValue: findAllBy(element),
6969
});

src/queries/hint-text.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const getNodeByHintText = (node: HostElement, text: TextMatch, options: TextMatc
2121
return matches(text, node.props.accessibilityHint, normalizer, exact);
2222
};
2323

24-
const queryAllByHintText = (instance: HostElement): QueryAllByQuery<TextMatch, ByHintTextOptions> =>
24+
const queryAllByHintText = (element: HostElement): QueryAllByQuery<TextMatch, ByHintTextOptions> =>
2525
function queryAllByA11yHintFn(hint, queryOptions) {
26-
return findAll(instance, (node) => getNodeByHintText(node, hint, queryOptions), queryOptions);
26+
return findAll(element, (node) => getNodeByHintText(node, hint, queryOptions), queryOptions);
2727
};
2828

2929
const getMultipleError = (hint: TextMatch) =>
@@ -62,13 +62,13 @@ export type ByHintTextQueries = {
6262
findAllByAccessibilityHint: FindAllByQuery<TextMatch, ByHintTextOptions>;
6363
};
6464

65-
export const bindByHintTextQueries = (instance: HostElement): ByHintTextQueries => {
66-
const getByHintText = getBy(instance);
67-
const getAllByHintText = getAllBy(instance);
68-
const queryByHintText = queryBy(instance);
69-
const queryAllByHintText = queryAllBy(instance);
70-
const findByHintText = findBy(instance);
71-
const findAllByHintText = findAllBy(instance);
65+
export const bindByHintTextQueries = (element: HostElement): ByHintTextQueries => {
66+
const getByHintText = getBy(element);
67+
const getAllByHintText = getAllBy(element);
68+
const queryByHintText = queryBy(element);
69+
const queryAllByHintText = queryAllBy(element);
70+
const findByHintText = findBy(element);
71+
const findAllByHintText = findAllBy(element);
7272

7373
return {
7474
getByHintText,

src/queries/label-text.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import type { CommonQueryOptions } from './options';
1616

1717
type ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;
1818

19-
function queryAllByLabelText(instance: HostElement) {
19+
function queryAllByLabelText(element: HostElement) {
2020
return (text: TextMatch, queryOptions?: ByLabelTextOptions) => {
2121
return findAll(
22-
instance,
22+
element,
2323
(node) => matchAccessibilityLabel(node, text, queryOptions),
2424
queryOptions,
2525
);
@@ -46,11 +46,11 @@ export type ByLabelTextQueries = {
4646
findAllByLabelText: FindAllByQuery<TextMatch, ByLabelTextOptions>;
4747
};
4848

49-
export const bindByLabelTextQueries = (instance: HostElement): ByLabelTextQueries => ({
50-
getByLabelText: getBy(instance),
51-
getAllByLabelText: getAllBy(instance),
52-
queryByLabelText: queryBy(instance),
53-
queryAllByLabelText: queryAllBy(instance),
54-
findByLabelText: findBy(instance),
55-
findAllByLabelText: findAllBy(instance),
49+
export const bindByLabelTextQueries = (element: HostElement): ByLabelTextQueries => ({
50+
getByLabelText: getBy(element),
51+
getAllByLabelText: getAllBy(element),
52+
queryByLabelText: queryBy(element),
53+
queryAllByLabelText: queryAllBy(element),
54+
findByLabelText: findBy(element),
55+
findAllByLabelText: findAllBy(element),
5656
});

src/queries/make-queries.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type FindAllByQuery<Predicate, Options = void> = (
4141
waitForOptions?: WaitForOptions,
4242
) => Promise<HostElement[]>;
4343

44-
type UnboundQuery<Query> = (instance: HostElement) => Query;
44+
type UnboundQuery<Query> = (element: HostElement) => Query;
4545

4646
export type UnboundQueries<Predicate, Options> = {
4747
getBy: UnboundQuery<GetByQuery<Predicate, Options>>;
@@ -114,9 +114,9 @@ export function makeQueries<Predicate, Options>(
114114
getMissingError: (predicate: Predicate, options?: Options) => string,
115115
getMultipleError: (predicate: Predicate, options?: Options) => string,
116116
): UnboundQueries<Predicate, Options> {
117-
function getAllByQuery(instance: HostElement, { printElementTree = true } = {}) {
117+
function getAllByQuery(element: HostElement, { printElementTree = true } = {}) {
118118
return function getAllFn(predicate: Predicate, options?: Options) {
119-
const results = queryAllByQuery(instance)(predicate, options);
119+
const results = queryAllByQuery(element)(predicate, options);
120120

121121
if (results.length === 0) {
122122
const errorMessage = formatErrorMessage(
@@ -130,9 +130,9 @@ export function makeQueries<Predicate, Options>(
130130
};
131131
}
132132

133-
function queryByQuery(instance: HostElement, { printElementTree = true } = {}) {
133+
function queryByQuery(element: HostElement, { printElementTree = true } = {}) {
134134
return function singleQueryFn(predicate: Predicate, options?: Options) {
135-
const results = queryAllByQuery(instance)(predicate, options);
135+
const results = queryAllByQuery(element)(predicate, options);
136136

137137
if (results.length > 1) {
138138
throw new ErrorWithStack(
@@ -149,9 +149,9 @@ export function makeQueries<Predicate, Options>(
149149
};
150150
}
151151

152-
function getByQuery(instance: HostElement, { printElementTree = true } = {}) {
152+
function getByQuery(element: HostElement, { printElementTree = true } = {}) {
153153
return function getFn(predicate: Predicate, options?: Options) {
154-
const results = queryAllByQuery(instance)(predicate, options);
154+
const results = queryAllByQuery(element)(predicate, options);
155155

156156
if (results.length > 1) {
157157
throw new ErrorWithStack(getMultipleError(predicate, options), getFn);
@@ -169,7 +169,7 @@ export function makeQueries<Predicate, Options>(
169169
};
170170
}
171171

172-
function findAllByQuery(instance: HostElement) {
172+
function findAllByQuery(element: HostElement) {
173173
return function findAllFn(
174174
predicate: Predicate,
175175
queryOptions?: Options & WaitForOptions,
@@ -182,7 +182,7 @@ export function makeQueries<Predicate, Options>(
182182
const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);
183183

184184
return waitFor(
185-
() => getAllByQuery(instance, { printElementTree: false })(predicate, queryOptions),
185+
() => getAllByQuery(element, { printElementTree: false })(predicate, queryOptions),
186186
{
187187
...deprecatedWaitForOptions,
188188
...waitForOptions,
@@ -193,7 +193,7 @@ export function makeQueries<Predicate, Options>(
193193
};
194194
}
195195

196-
function findByQuery(instance: HostElement) {
196+
function findByQuery(element: HostElement) {
197197
return function findFn(
198198
predicate: Predicate,
199199
queryOptions?: Options & WaitForOptions,
@@ -206,7 +206,7 @@ export function makeQueries<Predicate, Options>(
206206
const deprecatedWaitForOptions = extractDeprecatedWaitForOptions(queryOptions);
207207

208208
return waitFor(
209-
() => getByQuery(instance, { printElementTree: false })(predicate, queryOptions),
209+
() => getByQuery(element, { printElementTree: false })(predicate, queryOptions),
210210
{
211211
...deprecatedWaitForOptions,
212212
...waitForOptions,

src/queries/placeholder-text.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ const matchPlaceholderText = (
2727
};
2828

2929
const queryAllByPlaceholderText = (
30-
instance: HostElement,
30+
element: HostElement,
3131
): QueryAllByQuery<TextMatch, ByPlaceholderTextOptions> =>
3232
function queryAllByPlaceholderFn(placeholder, queryOptions) {
3333
return findAll(
34-
instance,
34+
element,
3535
(node) => isHostTextInput(node) && matchPlaceholderText(node, placeholder, queryOptions),
3636
queryOptions,
3737
);
@@ -57,11 +57,11 @@ export type ByPlaceholderTextQueries = {
5757
findAllByPlaceholderText: FindAllByQuery<TextMatch, ByPlaceholderTextOptions>;
5858
};
5959

60-
export const bindByPlaceholderTextQueries = (instance: HostElement): ByPlaceholderTextQueries => ({
61-
getByPlaceholderText: getBy(instance),
62-
getAllByPlaceholderText: getAllBy(instance),
63-
queryByPlaceholderText: queryBy(instance),
64-
queryAllByPlaceholderText: queryAllBy(instance),
65-
findByPlaceholderText: findBy(instance),
66-
findAllByPlaceholderText: findAllBy(instance),
60+
export const bindByPlaceholderTextQueries = (element: HostElement): ByPlaceholderTextQueries => ({
61+
getByPlaceholderText: getBy(element),
62+
getAllByPlaceholderText: getAllBy(element),
63+
queryByPlaceholderText: queryBy(element),
64+
queryAllByPlaceholderText: queryAllBy(element),
65+
findByPlaceholderText: findBy(element),
66+
findAllByPlaceholderText: findAllBy(element),
6767
});

src/queries/role.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ const matchAccessibilityValueIfNeeded = (node: HostElement, value?: Accessibilit
5151
return value != null ? matchAccessibilityValue(node, value) : true;
5252
};
5353

54-
const queryAllByRole = (instance: HostElement): QueryAllByQuery<ByRoleMatcher, ByRoleOptions> =>
54+
const queryAllByRole = (element: HostElement): QueryAllByQuery<ByRoleMatcher, ByRoleOptions> =>
5555
function queryAllByRoleFn(role, options) {
5656
const normalizedRole = typeof role === 'string' ? normalizeRole(role) : role;
5757
return findAll(
58-
instance,
58+
element,
5959
(node) =>
6060
// run the cheapest checks first, and early exit to avoid unneeded computations
6161
isAccessibilityElement(node) &&
@@ -110,11 +110,11 @@ export type ByRoleQueries = {
110110
findAllByRole: FindAllByQuery<ByRoleMatcher, ByRoleOptions>;
111111
};
112112

113-
export const bindByRoleQueries = (instance: HostElement): ByRoleQueries => ({
114-
getByRole: getBy(instance),
115-
getAllByRole: getAllBy(instance),
116-
queryByRole: queryBy(instance),
117-
queryAllByRole: queryAllBy(instance),
118-
findByRole: findBy(instance),
119-
findAllByRole: findAllBy(instance),
113+
export const bindByRoleQueries = (element: HostElement): ByRoleQueries => ({
114+
getByRole: getBy(element),
115+
getAllByRole: getAllBy(element),
116+
queryByRole: queryBy(element),
117+
queryAllByRole: queryAllBy(element),
118+
findByRole: findBy(element),
119+
findAllByRole: findAllBy(element),
120120
});

src/queries/test-id.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const matchTestId = (node: HostElement, testId: TextMatch, options: TextMatchOpt
2121
return matches(testId, node.props.testID, normalizer, exact);
2222
};
2323

24-
const queryAllByTestId = (instance: HostElement): QueryAllByQuery<TextMatch, ByTestIdOptions> =>
24+
const queryAllByTestId = (element: HostElement): QueryAllByQuery<TextMatch, ByTestIdOptions> =>
2525
function queryAllByTestIdFn(testId, queryOptions) {
26-
return findAll(instance, (node) => matchTestId(node, testId, queryOptions), queryOptions);
26+
return findAll(element, (node) => matchTestId(node, testId, queryOptions), queryOptions);
2727
};
2828

2929
const getMultipleError = (testId: TextMatch) =>
@@ -46,11 +46,11 @@ export type ByTestIdQueries = {
4646
findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;
4747
};
4848

49-
export const bindByTestIdQueries = (instance: HostElement): ByTestIdQueries => ({
50-
getByTestId: getBy(instance),
51-
getAllByTestId: getAllBy(instance),
52-
queryByTestId: queryBy(instance),
53-
queryAllByTestId: queryAllBy(instance),
54-
findByTestId: findBy(instance),
55-
findAllByTestId: findAllBy(instance),
49+
export const bindByTestIdQueries = (element: HostElement): ByTestIdQueries => ({
50+
getByTestId: getBy(element),
51+
getAllByTestId: getAllBy(element),
52+
queryByTestId: queryBy(element),
53+
queryAllByTestId: queryAllBy(element),
54+
findByTestId: findBy(element),
55+
findAllByTestId: findAllBy(element),
5656
});

src/queries/text.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import type { CommonQueryOptions } from './options';
1717

1818
type ByTextOptions = CommonQueryOptions & TextMatchOptions;
1919

20-
const queryAllByText = (instance: HostElement): QueryAllByQuery<TextMatch, ByTextOptions> =>
20+
const queryAllByText = (element: HostElement): QueryAllByQuery<TextMatch, ByTextOptions> =>
2121
function queryAllByTextFn(text, options = {}) {
22-
return findAll(instance, (node) => isHostText(node) && matchTextContent(node, text, options), {
22+
return findAll(element, (node) => isHostText(node) && matchTextContent(node, text, options), {
2323
...options,
2424
matchDeepestOnly: true,
2525
});
@@ -44,11 +44,11 @@ export type ByTextQueries = {
4444
findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;
4545
};
4646

47-
export const bindByTextQueries = (instance: HostElement): ByTextQueries => ({
48-
getByText: getBy(instance),
49-
getAllByText: getAllBy(instance),
50-
queryByText: queryBy(instance),
51-
queryAllByText: queryAllBy(instance),
52-
findByText: findBy(instance),
53-
findAllByText: findAllBy(instance),
47+
export const bindByTextQueries = (element: HostElement): ByTextQueries => ({
48+
getByText: getBy(element),
49+
getAllByText: getAllBy(element),
50+
queryByText: queryBy(element),
51+
queryAllByText: queryAllBy(element),
52+
findByText: findBy(element),
53+
findAllByText: findAllBy(element),
5454
});

src/within.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { bindByRoleQueries } from './queries/role';
88
import { bindByTestIdQueries } from './queries/test-id';
99
import { bindByTextQueries } from './queries/text';
1010

11-
export function within(instance: HostElement) {
11+
export function within(element: HostElement) {
1212
return {
13-
...bindByTextQueries(instance),
14-
...bindByTestIdQueries(instance),
15-
...bindByDisplayValueQueries(instance),
16-
...bindByPlaceholderTextQueries(instance),
17-
...bindByLabelTextQueries(instance),
18-
...bindByHintTextQueries(instance),
19-
...bindByRoleQueries(instance),
13+
...bindByTextQueries(element),
14+
...bindByTestIdQueries(element),
15+
...bindByDisplayValueQueries(element),
16+
...bindByPlaceholderTextQueries(element),
17+
...bindByLabelTextQueries(element),
18+
...bindByHintTextQueries(element),
19+
...bindByRoleQueries(element),
2020
};
2121
}
2222

0 commit comments

Comments
 (0)