File tree Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Original file line number Diff line number Diff line change @@ -104,14 +104,6 @@ function renderUseClipboard(textToCopy: string) {
104
104
105
105
type ScheduleConfig = Readonly < { isHttps : boolean } > ;
106
106
107
- /**
108
- * Unconventional test setup, but we need two separate instances of the
109
- * MockClipboard (one for HTTP and one for HTTPS).
110
- *
111
- * All beforeAll and afterEach hooks must be tied to the specific instance, or
112
- * else you get shared mutable state, and test cases interfering with each
113
- * other. Test isolation is especially important for this test file
114
- */
115
107
export function scheduleClipboardTests ( { isHttps } : ScheduleConfig ) {
116
108
const mockClipboardInstance = makeMockClipboard ( isHttps ) ;
117
109
@@ -121,10 +113,8 @@ export function scheduleClipboardTests({ isHttps }: ScheduleConfig) {
121
113
...originalNavigator ,
122
114
clipboard : mockClipboardInstance ,
123
115
} ) ) ;
124
- } ) ;
125
116
126
- if ( ! isHttps ) {
127
- beforeAll ( ( ) => {
117
+ if ( ! isHttps ) {
128
118
// Not the biggest fan of exposing implementation details like this, but
129
119
// making any kind of mock for execCommand is really gnarly in general
130
120
global . document . execCommand = jest . fn ( ( ) => {
@@ -141,8 +131,8 @@ export function scheduleClipboardTests({ isHttps }: ScheduleConfig) {
141
131
142
132
return copySuccessful ;
143
133
} ) ;
144
- } ) ;
145
- }
134
+ }
135
+ } ) ;
146
136
147
137
afterEach ( ( ) => {
148
138
mockClipboardInstance . setMockText ( "" ) ;
You can’t perform that action at this time.
0 commit comments