Skip to content

Commit ed4594b

Browse files
committed
Adding required import statement, or added to existing import for setupOnerror
1 parent 5fbc088 commit ed4594b

15 files changed

Lines changed: 320 additions & 77 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { module, test } from 'qunit';
2+
3+
module('foo', function() {
4+
test('foo test', async function(assert) {
5+
assert.expect(1);
6+
7+
Ember.onerror = function() {};
8+
Ember.onerror = () => {};
9+
Ember.onerror = fn;
10+
});
11+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { setupOnerror } from '@ember/test-helpers';
2+
import { module, test } from 'qunit';
3+
4+
module('foo', function() {
5+
test('foo test', async function(assert) {
6+
assert.expect(1);
7+
8+
setupOnerror(function() {});
9+
setupOnerror(() => {});
10+
setupOnerror(fn);
11+
});
12+
});
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
test('foo test', async function (assert) {
2-
assert.expect(1);
1+
import { module, test } from 'qunit';
2+
import { click } from '@ember/test-helpers';
33

4-
Ember.onerror = function() {};
5-
Ember.onerror = () => {};
6-
Ember.onerror = fn;
4+
module('foo', function() {
5+
test('foo test', async function(assert) {
6+
assert.expect(1);
7+
8+
Ember.onerror = function() {};
9+
Ember.onerror = () => {};
10+
Ember.onerror = fn;
11+
});
712
});
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
test('foo test', async function (assert) {
2-
assert.expect(1);
1+
import { module, test } from 'qunit';
2+
import { click, setupOnerror } from '@ember/test-helpers';
33

4-
setupOnerror(function() {});
5-
setupOnerror(() => {});
6-
setupOnerror(fn);
7-
});
4+
module('foo', function() {
5+
test('foo test', async function(assert) {
6+
assert.expect(1);
7+
8+
setupOnerror(function() {});
9+
setupOnerror(() => {});
10+
setupOnerror(fn);
11+
});
12+
});
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { getParser } = require('codemod-cli').jscodeshift;
2+
const { addImportStatement, writeImportStatements } = require('../utils');
23

34
module.exports = function transformer(file, api) {
45
const j = getParser(api);
@@ -10,19 +11,24 @@ module.exports = function transformer(file, api) {
1011
let onError = node.right;
1112

1213
return j.callExpression(j.identifier('setupOnerror'), [onError]);
13-
}
14+
};
1415

15-
root.find(j.AssignmentExpression, {
16+
let replacements = root.find(j.AssignmentExpression, {
1617
left: {
1718
object: {
18-
name: 'Ember'
19+
name: 'Ember',
1920
},
2021
property: {
21-
name: 'onerror'
22-
}
23-
}
24-
})
25-
.replaceWith(replacer);
22+
name: 'onerror',
23+
},
24+
},
25+
});
26+
27+
if (replacements.length > 0) {
28+
replacements.replaceWith(replacer);
29+
addImportStatement(['setupOnerror']);
30+
writeImportStatements(j, root);
31+
}
2632

27-
return root.toSource();
28-
}
33+
return root.toSource({ quote: 'single' });
34+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { module, test } from 'qunit';
2+
3+
module('foo', function() {
4+
test('foo test', async function(assert) {
5+
assert.expect(1);
6+
7+
sandbox.stub(Ember, 'onerror', function() {});
8+
sandbox.stub(Ember, 'onerror', () => {});
9+
sandbox.stub(Ember, 'onerror', fn);
10+
11+
sandbox.stub(Ember, 'foo', function() {});
12+
sandbox.stub(Ember, 'foo', () => {});
13+
sandbox.stub(Ember, 'foo', fn);
14+
15+
this.sandbox.stub(Ember, 'onerror', function() {});
16+
this.sandbox.stub(Ember, 'onerror', () => {});
17+
this.sandbox.stub(Ember, 'onerror', fn);
18+
});
19+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { setupOnerror } from '@ember/test-helpers';
2+
import { module, test } from 'qunit';
3+
4+
module('foo', function() {
5+
test('foo test', async function(assert) {
6+
assert.expect(1);
7+
8+
setupOnerror(function() {});
9+
setupOnerror(() => {});
10+
setupOnerror(fn);
11+
12+
sandbox.stub(Ember, 'foo', function() {});
13+
sandbox.stub(Ember, 'foo', () => {});
14+
sandbox.stub(Ember, 'foo', fn);
15+
16+
setupOnerror(function() {});
17+
setupOnerror(() => {});
18+
setupOnerror(fn);
19+
});
20+
});
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
test('foo test', async function (assert) {
2-
assert.expect(1);
1+
import { module, test } from 'qunit';
2+
import { click } from '@ember/test-helpers';
33

4-
sandbox.stub(Ember, 'onerror', function() {});
5-
sandbox.stub(Ember, 'onerror', () => {});
6-
sandbox.stub(Ember, 'onerror', fn);
4+
module('foo', function() {
5+
test('foo test', async function(assert) {
6+
assert.expect(1);
77

8-
sandbox.stub(Ember, 'foo', function() {});
9-
sandbox.stub(Ember, 'foo', () => {});
10-
sandbox.stub(Ember, 'foo', fn);
8+
sandbox.stub(Ember, 'onerror', function() {});
9+
sandbox.stub(Ember, 'onerror', () => {});
10+
sandbox.stub(Ember, 'onerror', fn);
1111

12-
this.sandbox.stub(Ember, 'onerror', function() {});
13-
this.sandbox.stub(Ember, 'onerror', () => {});
14-
this.sandbox.stub(Ember, 'onerror', fn);
15-
});
12+
sandbox.stub(Ember, 'foo', function() {});
13+
sandbox.stub(Ember, 'foo', () => {});
14+
sandbox.stub(Ember, 'foo', fn);
15+
16+
this.sandbox.stub(Ember, 'onerror', function() {});
17+
this.sandbox.stub(Ember, 'onerror', () => {});
18+
this.sandbox.stub(Ember, 'onerror', fn);
19+
});
20+
});
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
test('foo test', async function (assert) {
2-
assert.expect(1);
1+
import { module, test } from 'qunit';
2+
import { click, setupOnerror } from '@ember/test-helpers';
33

4-
setupOnerror(function() {});
5-
setupOnerror(() => {});
6-
setupOnerror(fn);
4+
module('foo', function() {
5+
test('foo test', async function(assert) {
6+
assert.expect(1);
77

8-
sandbox.stub(Ember, 'foo', function() {});
9-
sandbox.stub(Ember, 'foo', () => {});
10-
sandbox.stub(Ember, 'foo', fn);
8+
setupOnerror(function() {});
9+
setupOnerror(() => {});
10+
setupOnerror(fn);
1111

12-
setupOnerror(function() {});
13-
setupOnerror(() => {});
14-
setupOnerror(fn);
12+
sandbox.stub(Ember, 'foo', function() {});
13+
sandbox.stub(Ember, 'foo', () => {});
14+
sandbox.stub(Ember, 'foo', fn);
15+
16+
setupOnerror(function() {});
17+
setupOnerror(() => {});
18+
setupOnerror(fn);
19+
});
1520
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { module, test } from 'qunit';
2+
3+
module('foo', function() {
4+
test('foo test', async function(assert) {
5+
assert.expect(1);
6+
7+
sinon.stub(Ember, 'onerror', function() {});
8+
sinon.stub(Ember, 'onerror', () => {});
9+
sinon.stub(Ember, 'onerror', fn);
10+
11+
sinon.stub(Ember, 'foo', function() {});
12+
sinon.stub(Ember, 'foo', () => {});
13+
sinon.stub(Ember, 'foo', fn);
14+
15+
this.sinon.stub(Ember, 'onerror', function() {});
16+
this.sinon.stub(Ember, 'onerror', () => {});
17+
this.sinon.stub(Ember, 'onerror', fn);
18+
});
19+
});

0 commit comments

Comments
 (0)