File: replace-ava-by-jest.patch

package info (click to toggle)
node-rollup-plugin-inject 5.0.5~ds1%2B~3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 520 kB
  • sloc: javascript: 1,215; makefile: 7
file content (284 lines) | stat: -rw-r--r-- 7,233 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
Description: replace ava by jest
Author: Yadd <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2022-10-29

--- /dev/null
+++ b/packages/inject/test/__snapshots__/test.js.snap
@@ -0,0 +1,146 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`escapes apostrophes in module name 1`] = `
+"import { default as $ } from 'd\\'oh';
+
+$(() => {
+  console.log('ready');
+});
+"
+`;
+
+exports[`escapes backslashes in module name 1`] = `
+"import { default as $ } from 'slash\\\\back';
+
+$(() => {
+  console.log('ready');
+});
+"
+`;
+
+exports[`generates * imports 1`] = `
+"import * as foo from 'foo';
+
+console.log(foo.bar);
+console.log(foo.baz);
+"
+`;
+
+exports[`handles redundant keys 1`] = `
+"import { default as $inject_Buffer_isBuffer } from 'is-buffer';
+
+$inject_Buffer_isBuffer('foo');
+"
+`;
+
+exports[`handles shadowed variables 1`] = `
+"function launch($) {
+  $(() => {
+    console.log('ready');
+  });
+}
+
+launch((fn) => fn());
+"
+`;
+
+exports[`handles shorthand properties (as assignment) 1`] = `
+"const { Promise = "fallback" } = foo;
+console.log(Promise);
+
+"
+`;
+
+exports[`handles shorthand properties 1`] = `
+"import { Promise as Promise } from 'es6-promise';
+
+const polyfills = { Promise };
+polyfills.Promise.resolve().then(() => 'it works');
+"
+`;
+
+exports[`handles shorthand properties in function (as fallback value) 1`] = `
+"import { Promise as Promise } from 'es6-promise';
+
+function foo({bar = Promise}) {
+  console.log(bar);
+}
+foo();
+
+"
+`;
+
+exports[`handles shorthand properties in function 1`] = `
+"function foo({Promise}) {
+  console.log(Promise);
+}
+foo();
+
+"
+`;
+
+exports[`ignores check isReference is false 1`] = `
+"import { bar as foo } from 'path';
+
+console.log({ bar: foo });
+class Foo {
+  bar() {
+    console.log(this);
+  }
+}
+export { Foo };
+export { foo as bar };
+"
+`;
+
+exports[`ignores existing imports 1`] = `
+"import $ from 'jquery';
+
+$(() => {
+  console.log('ready');
+});
+"
+`;
+
+exports[`inserts a default import statement 1`] = `
+"import { default as $ } from 'jquery';
+
+$(() => {
+  console.log('ready');
+});
+"
+`;
+
+exports[`inserts a named import statement 1`] = `
+"import { Promise as Promise } from 'es6-promise';
+
+Promise.all([thisThing, thatThing]).then(() => someOtherThing);
+"
+`;
+
+exports[`overwrites keypaths 1`] = `
+"import { default as $inject_Object_assign } from 'fixtures/keypaths/polyfills/object-assign.js';
+
+const original = { foo: 'bar' };
+const clone = $inject_Object_assign({}, original);
+
+export default clone;
+"
+`;
+
+exports[`transpiles non-JS files but handles failures to parse 1`] = `
+"import './styles.css';
+import foo from './foo.es6';
+
+assert.equal(foo, path.join('..', 'baz'));
+"
+`;
+
+exports[`uses the modules property 1`] = `
+"import { default as $ } from 'jquery';
+
+$(() => {
+  console.log('ready');
+});
+"
+`;
--- a/packages/inject/test/test.js
+++ b/packages/inject/test/test.js
@@ -3,11 +3,10 @@
 const os = require('os');
 
 const acorn = require('acorn');
-const test = require('ava');
 
 const inject = require('..');
 
-const compare = (t, fixture, options) => {
+const compare = (fixture, options) => {
   const filename = path.resolve(`test/fixtures/${fixture}/input.js`);
   const input = fs.readFileSync(filename, 'utf-8');
   const output = inject(options).transform.call(
@@ -22,81 +21,81 @@
     filename
   );
 
-  t.snapshot(output ? output.code : input);
+  expect(output ? output.code : input).toMatchSnapshot();
 };
 
-test('inserts a default import statement', (t) => {
-  compare(t, 'basic', { $: 'jquery' });
+test('inserts a default import statement', () => {
+  compare('basic', { $: 'jquery' });
 });
 
-test('uses the modules property', (t) => {
-  compare(t, 'basic', {
+test('uses the modules property', () => {
+  compare('basic', {
     modules: { $: 'jquery' }
   });
 });
 
-test('escapes apostrophes in module name', (t) => {
-  compare(t, 'basic', { $: "d'oh" });
+test('escapes apostrophes in module name', () => {
+  compare('basic', { $: "d'oh" });
 });
 
 if (os.platform() === 'win32') {
   // backslash is path separator on Windows,
   // so it cannot appear within filename
 } else {
-  test('escapes backslashes in module name', (t) => {
-    compare(t, 'basic', { $: 'slash\\back' });
+  test('escapes backslashes in module name', () => {
+    compare('basic', { $: 'slash\\back' });
   });
 }
 
-test('inserts a named import statement', (t) => {
-  compare(t, 'named', { Promise: ['es6-promise', 'Promise'] });
+test('inserts a named import statement', () => {
+  compare('named', { Promise: ['es6-promise', 'Promise'] });
 });
 
-test('overwrites keypaths', (t) => {
-  compare(t, 'keypaths', {
+test('overwrites keypaths', () => {
+  compare('keypaths', {
     'Object.assign': 'fixtures/keypaths/polyfills/object-assign.js'
   });
 });
 
-test('ignores existing imports', (t) => {
-  compare(t, 'existing', { $: 'jquery' });
+test('ignores existing imports', () => {
+  compare('existing', { $: 'jquery' });
 });
 
-test('handles shadowed variables', (t) => {
-  compare(t, 'shadowing', { $: 'jquery' });
+test('handles shadowed variables', () => {
+  compare('shadowing', { $: 'jquery' });
 });
 
-test('handles shorthand properties', (t) => {
-  compare(t, 'shorthand', { Promise: ['es6-promise', 'Promise'] });
+test('handles shorthand properties', () => {
+  compare('shorthand', { Promise: ['es6-promise', 'Promise'] });
 });
 
-test('handles shorthand properties (as assignment)', (t) => {
-  compare(t, 'shorthand-assignment', { Promise: ['es6-promise', 'Promise'] });
+test('handles shorthand properties (as assignment)', () => {
+  compare('shorthand-assignment', { Promise: ['es6-promise', 'Promise'] });
 });
 
-test('handles shorthand properties in function', (t) => {
-  compare(t, 'shorthand-func', { Promise: ['es6-promise', 'Promise'] });
+test('handles shorthand properties in function', () => {
+  compare('shorthand-func', { Promise: ['es6-promise', 'Promise'] });
 });
 
-test('handles shorthand properties in function (as fallback value)', (t) => {
-  compare(t, 'shorthand-func-fallback', { Promise: ['es6-promise', 'Promise'] });
+test('handles shorthand properties in function (as fallback value)', () => {
+  compare('shorthand-func-fallback', { Promise: ['es6-promise', 'Promise'] });
 });
 
-test('handles redundant keys', (t) => {
-  compare(t, 'redundant-keys', {
+test('handles redundant keys', () => {
+  compare('redundant-keys', {
     Buffer: 'Buffer',
     'Buffer.isBuffer': 'is-buffer'
   });
 });
 
-test('generates * imports', (t) => {
-  compare(t, 'import-namespace', { foo: ['foo', '*'] });
+test('generates * imports', () => {
+  compare('import-namespace', { foo: ['foo', '*'] });
 });
 
-test('transpiles non-JS files but handles failures to parse', (t) => {
-  compare(t, 'non-js', { relative: ['path', 'relative'] });
+test('transpiles non-JS files but handles failures to parse', () => {
+  compare('non-js', { relative: ['path', 'relative'] });
 });
 
-test('ignores check isReference is false', (t) => {
-  compare(t, 'is-reference', { bar: 'path' });
+test('ignores check isReference is false', () => {
+  compare('is-reference', { bar: 'path' });
 });