UNPKG

4.16 kBPlain TextView Raw
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2015 - present Instructure, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25import { locator } from '@instructure/ui-test-locator'
26
27import {
28 accessible,
29 parseQueryArguments,
30 findWithLabel,
31 findWithText,
32 findWithTitle,
33 findByQuery,
34 findAllByQuery,
35 matchesSelector,
36 querySelectorAll,
37 querySelector,
38 firstOrNull,
39 wrapQueryResult,
40 find,
41 findAll,
42 findAllFrames,
43 findFrame,
44 debug
45} from '@instructure/ui-test-queries'
46
47import {
48 mount,
49 unmount,
50 stub,
51 spy,
52 viewport,
53 match
54} from '@instructure/ui-test-sandbox'
55import type {
56 SinonStub,
57 SinonSpy,
58 SinonSandbox
59} from '@instructure/ui-test-sandbox'
60
61import './utils/shims'
62
63import { waitForExpect } from './utils/waitForExpect'
64import { expect } from './utils/expect'
65
66import { generateA11yTests } from './utils/generateA11yTests'
67import {
68 generateComponentExamples,
69 StoryConfig,
70 Example,
71 ExamplesPage
72} from './utils/generateComponentExamples'
73import { generatePropCombinations } from './utils/generatePropCombinations'
74
75// these are defined in assertions.ts
76declare global {
77 // eslint-disable-next-line @typescript-eslint/no-namespace
78 export namespace Chai {
79 interface Assertion {
80 // @ts-expect-error This is intentionally overridden in Assertions.ts
81 readonly contain: Assertion
82 exactly(expected: number): Assertion
83 text(expected: string): void
84 className(expected: string): void
85 descendants(expected: string): void
86 children(expected: string): void
87 ancestors(expected: string): void
88 parents(expected: string): void
89 attribute(
90 expectedAttribute: string,
91 expectedAttributeValue?: string
92 ): void
93 style(expected: string, expectedAttributeValue?: string | number): void
94 bounds(expected: string, expectedAttributeValue?: string | number): void
95 tagName(expected: string): void
96 id(expected: string): void
97 visible(): boolean
98 clickable(): boolean
99 focus(): boolean
100 focused(): boolean
101 focusable(): boolean
102 tabbable(): boolean
103 checked(): boolean
104 selected(): boolean
105 disabled(): boolean
106 enabled(): boolean
107 readonly(): boolean
108 accessible(): boolean
109 role(expected: string): void
110 title(expected: string): void
111 value(expected: string): void
112 label(expected: string): void
113 }
114 }
115}
116
117export type {
118 StoryConfig,
119 Example,
120 ExamplesPage,
121 SinonStub,
122 SinonSpy,
123 SinonSandbox
124}
125
126// aliases for backwards compat:
127const within = wrapQueryResult
128const wrap = wrapQueryResult
129const wait = waitForExpect
130
131export {
132 generateComponentExamples,
133 generatePropCombinations,
134 generateA11yTests,
135 viewport,
136 accessible,
137 parseQueryArguments,
138 findWithLabel,
139 findWithText,
140 findWithTitle,
141 findByQuery,
142 findAllByQuery,
143 matchesSelector,
144 querySelectorAll,
145 querySelector,
146 locator,
147 firstOrNull,
148 within,
149 wrapQueryResult,
150 wrap,
151 waitForExpect,
152 wait,
153 expect,
154 mount,
155 unmount,
156 stub,
157 spy,
158 match,
159 find,
160 findAll,
161 findAllFrames,
162 findFrame,
163 debug
164}