Skip to content

Commit a22f3f4

Browse files
committed
Updating readme
1 parent 4200152 commit a22f3f4

8 files changed

Lines changed: 184 additions & 36 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ ember-sinon-sandbox-codemod <TRANSFORM NAME> path/of/files/ or/some**/*glob.js
1919
## Transforms
2020

2121
<!--TRANSFORMS_START-->
22-
* [ember-sinon-sandbox-codemod](transforms/ember-sinon-sandbox-codemod/README.md)
22+
* [remove-sandbox-create](transforms/remove-sandbox-create/README.md)
23+
* [remove-sinon-usages](transforms/remove-sinon-usages/README.md)
2324
<!--TRANSFORMS_END-->
2425

2526
## Contributing

transforms/remove-sandbox-create/README.md

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
# ember-sinon-sandbox-codemod
2-
1+
# remove-sandbox-create
32

43
## Usage
54

65
```
7-
npx ember-sinon-sandbox-codemod ember-sinon-sandbox-codemod path/of/files/ or/some**/*glob.js
6+
npx ember-sinon-sandbox-codemod remove-sandbox-create path/of/files/ or/some**/*glob.js
87
98
# or
109
1110
yarn global add ember-sinon-sandbox-codemod
12-
ember-sinon-sandbox-codemod ember-sinon-sandbox-codemod path/of/files/ or/some**/*glob.js
11+
ember-sinon-sandbox-codemod remove-sandbox-create path/of/files/ or/some**/*glob.js
1312
```
1413

1514
## Input / Output
1615

1716
<!--FIXTURES_TOC_START-->
18-
* [sinon.sandbox.create.empty.beforeeach](#sinon.sandbox.create.empty.beforeeach)
19-
* [sinon.sandbox.create.funcref.beforeeach](#sinon.sandbox.create.funcref.beforeeach)
20-
* [sinon.sandbox.create.nonempty.beforeeach](#sinon.sandbox.create.nonempty.beforeeach)
21-
* [sinon.sandbox.restore.empty.aftereach](#sinon.sandbox.restore.empty.aftereach)
22-
* [sinon.sandbox.restore.nonempty.aftereach](#sinon.sandbox.restore.nonempty.aftereach)
23-
<!--FIXTURES_TOC_END-->
24-
25-
<!--FIXTURES_CONTENT_START-->
26-
---
17+
18+
- [sinon.sandbox.create.empty.beforeeach](#sinon.sandbox.create.empty.beforeeach)
19+
- [sinon.sandbox.create.funcref.beforeeach](#sinon.sandbox.create.funcref.beforeeach)
20+
- [sinon.sandbox.create.nonempty.beforeeach](#sinon.sandbox.create.nonempty.beforeeach)
21+
- [sinon.sandbox.restore.empty.aftereach](#sinon.sandbox.restore.empty.aftereach)
22+
- [sinon.sandbox.restore.nonempty.aftereach](#sinon.sandbox.restore.nonempty.aftereach)
23+
<!--FIXTURES_TOC_END-->
24+
25+
## <!--FIXTURES_CONTENT_START-->
26+
2727
<a id="sinon.sandbox.create.empty.beforeeach">**sinon.sandbox.create.empty.beforeeach**</a>
2828

29-
**Input** (<small>[sinon.sandbox.create.empty.beforeeach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.create.empty.beforeeach.input.js)</small>):
29+
**Input** (<small>[sinon.sandbox.create.empty.beforeeach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.create.empty.beforeeach.input.js)</small>):
30+
3031
```js
3132
import { moduleForAcceptance, test } from 'ember-qunit';
3233

@@ -42,10 +43,10 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
4243
test('it happens', function(assert) {
4344
assert.ok(true);
4445
});
45-
4646
```
4747

48-
**Output** (<small>[sinon.sandbox.create.empty.beforeeach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.create.empty.beforeeach.output.js)</small>):
48+
**Output** (<small>[sinon.sandbox.create.empty.beforeeach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.create.empty.beforeeach.output.js)</small>):
49+
4950
```js
5051
import { moduleForAcceptance, test } from 'ember-qunit';
5152

@@ -54,12 +55,14 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {});
5455
test('it happens', function(assert) {
5556
assert.ok(true);
5657
});
57-
5858
```
59+
5960
---
61+
6062
<a id="sinon.sandbox.create.funcref.beforeeach">**sinon.sandbox.create.funcref.beforeeach**</a>
6163

62-
**Input** (<small>[sinon.sandbox.create.funcref.beforeeach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.create.funcref.beforeeach.input.js)</small>):
64+
**Input** (<small>[sinon.sandbox.create.funcref.beforeeach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.create.funcref.beforeeach.input.js)</small>):
65+
6366
```js
6467
import { moduleForAcceptance, test } from 'ember-qunit';
6568
import { before } from './before';
@@ -71,10 +74,10 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
7174
test('it happens', function(assert) {
7275
assert.ok(true);
7376
});
74-
7577
```
7678

77-
**Output** (<small>[sinon.sandbox.create.funcref.beforeeach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.create.funcref.beforeeach.output.js)</small>):
79+
**Output** (<small>[sinon.sandbox.create.funcref.beforeeach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.create.funcref.beforeeach.output.js)</small>):
80+
7881
```js
7982
import { moduleForAcceptance, test } from 'ember-qunit';
8083
import { before } from './before';
@@ -86,12 +89,14 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
8689
test('it happens', function(assert) {
8790
assert.ok(true);
8891
});
89-
9092
```
93+
9194
---
95+
9296
<a id="sinon.sandbox.create.nonempty.beforeeach">**sinon.sandbox.create.nonempty.beforeeach**</a>
9397

94-
**Input** (<small>[sinon.sandbox.create.nonempty.beforeeach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.create.nonempty.beforeeach.input.js)</small>):
98+
**Input** (<small>[sinon.sandbox.create.nonempty.beforeeach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.create.nonempty.beforeeach.input.js)</small>):
99+
95100
```js
96101
import { moduleForAcceptance, test } from 'ember-qunit';
97102

@@ -108,10 +113,10 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
108113
test('it happens', function(assert) {
109114
assert.ok(true);
110115
});
111-
112116
```
113117

114-
**Output** (<small>[sinon.sandbox.create.nonempty.beforeeach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.create.nonempty.beforeeach.output.js)</small>):
118+
**Output** (<small>[sinon.sandbox.create.nonempty.beforeeach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.create.nonempty.beforeeach.output.js)</small>):
119+
115120
```js
116121
import { moduleForAcceptance, test } from 'ember-qunit';
117122

@@ -124,12 +129,14 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
124129
test('it happens', function(assert) {
125130
assert.ok(true);
126131
});
127-
128132
```
133+
129134
---
135+
130136
<a id="sinon.sandbox.restore.empty.aftereach">**sinon.sandbox.restore.empty.aftereach**</a>
131137

132-
**Input** (<small>[sinon.sandbox.restore.empty.aftereach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.restore.empty.aftereach.input.js)</small>):
138+
**Input** (<small>[sinon.sandbox.restore.empty.aftereach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.restore.empty.aftereach.input.js)</small>):
139+
133140
```js
134141
import { moduleForAcceptance, test } from 'ember-qunit';
135142

@@ -147,10 +154,10 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
147154
test('it happens', function(assert) {
148155
assert.ok(true);
149156
});
150-
151157
```
152158

153-
**Output** (<small>[sinon.sandbox.restore.empty.aftereach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.restore.empty.aftereach.output.js)</small>):
159+
**Output** (<small>[sinon.sandbox.restore.empty.aftereach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.restore.empty.aftereach.output.js)</small>):
160+
154161
```js
155162
import { moduleForAcceptance, test } from 'ember-qunit';
156163

@@ -159,12 +166,14 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {});
159166
test('it happens', function(assert) {
160167
assert.ok(true);
161168
});
162-
163169
```
170+
164171
---
172+
165173
<a id="sinon.sandbox.restore.nonempty.aftereach">**sinon.sandbox.restore.nonempty.aftereach**</a>
166174

167-
**Input** (<small>[sinon.sandbox.restore.nonempty.aftereach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.restore.nonempty.aftereach.input.js)</small>):
175+
**Input** (<small>[sinon.sandbox.restore.nonempty.aftereach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.restore.nonempty.aftereach.input.js)</small>):
176+
168177
```js
169178
import { moduleForAcceptance, test } from 'ember-qunit';
170179

@@ -183,10 +192,10 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
183192
test('it happens', function(assert) {
184193
assert.ok(true);
185194
});
186-
187195
```
188196

189-
**Output** (<small>[sinon.sandbox.restore.nonempty.aftereach.input.js](transforms/ember-sinon-sandbox-codemod/__testfixtures__/sinon.sandbox.restore.nonempty.aftereach.output.js)</small>):
197+
**Output** (<small>[sinon.sandbox.restore.nonempty.aftereach.input.js](transforms/remove-sandbox-create/__testfixtures__/sinon.sandbox.restore.nonempty.aftereach.output.js)</small>):
198+
190199
```js
191200
import { moduleForAcceptance, test } from 'ember-qunit';
192201

@@ -199,6 +208,6 @@ moduleForAcceptance('foo', 'Acceptance | Foo', {
199208
test('it happens', function(assert) {
200209
assert.ok(true);
201210
});
202-
203211
```
204-
<!--FIXTURE_CONTENT_END-->
212+
213+
<!--FIXTURE_CONTENT_END-->

transforms/remove-sandbox-create/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module.exports = function(file, api) {
1+
const { getParser } = require('codemod-cli').jscodeshift;
2+
3+
module.exports = function transformer(file, api) {
24
const j = api.jscodeshift;
35
const root = j(file.source);
46

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# remove-sinon-usages
2+
3+
4+
## Usage
5+
6+
```
7+
npx ember-sinon-sandbox-codemod remove-sinon-usages path/of/files/ or/some**/*glob.js
8+
9+
# or
10+
11+
yarn global add ember-sinon-sandbox-codemod
12+
ember-sinon-sandbox-codemod remove-sinon-usages path/of/files/ or/some**/*glob.js
13+
```
14+
15+
## Input / Output
16+
17+
<!--FIXTURES_TOC_START-->
18+
* [transform.sinon.to.sandbox](#transform.sinon.to.sandbox)
19+
<!--FIXTURES_TOC_END-->
20+
21+
<!--FIXTURES_CONTENT_START-->
22+
---
23+
<a id="transform.sinon.to.sandbox">**transform.sinon.to.sandbox**</a>
24+
25+
**Input** (<small>[transform.sinon.to.sandbox.input.js](transforms/remove-sinon-usages/__testfixtures__/transform.sinon.to.sandbox.input.js)</small>):
26+
```js
27+
import { module, test } from 'qunit';
28+
29+
module('Unit | blah', function(hooks) {
30+
test('blah', function(assert) {
31+
assert.expect(1);
32+
33+
let stub = sinon.stub().returns(true);
34+
let spy = sinon.spy();
35+
let clock = sinon.useFakeTimers();
36+
sinon.match({
37+
one: 1,
38+
two: 2,
39+
three: 3,
40+
});
41+
42+
assert.ok(true);
43+
});
44+
});
45+
46+
```
47+
48+
**Output** (<small>[transform.sinon.to.sandbox.input.js](transforms/remove-sinon-usages/__testfixtures__/transform.sinon.to.sandbox.output.js)</small>):
49+
```js
50+
import { module, test } from 'qunit';
51+
52+
module('Unit | blah', function(hooks) {
53+
test('blah', function(assert) {
54+
assert.expect(1);
55+
56+
let stub = this.sandbox.stub().returns(true);
57+
let spy = this.sandbox.spy();
58+
let clock = this.sandbox.useFakeTimers();
59+
this.sandbox.match({
60+
one: 1,
61+
two: 2,
62+
three: 3,
63+
});
64+
65+
assert.ok(true);
66+
});
67+
});
68+
69+
```
70+
<!--FIXTURE_CONTENT_END-->
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { module, test } from 'qunit';
2+
3+
module('Unit | blah', function(hooks) {
4+
test('blah', function(assert) {
5+
assert.expect(1);
6+
7+
let stub = sinon.stub().returns(true);
8+
let spy = sinon.spy();
9+
let clock = sinon.useFakeTimers();
10+
sinon.match({
11+
one: 1,
12+
two: 2,
13+
three: 3,
14+
});
15+
16+
assert.ok(true);
17+
});
18+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { module, test } from 'qunit';
2+
3+
module('Unit | blah', function(hooks) {
4+
test('blah', function(assert) {
5+
assert.expect(1);
6+
7+
let stub = this.sandbox.stub().returns(true);
8+
let spy = this.sandbox.spy();
9+
let clock = this.sandbox.useFakeTimers();
10+
this.sandbox.match({
11+
one: 1,
12+
two: 2,
13+
three: 3,
14+
});
15+
16+
assert.ok(true);
17+
});
18+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { getParser } = require('codemod-cli').jscodeshift;
2+
3+
module.exports = function transformer(file, api) {
4+
const j = getParser(api);
5+
const root = j(file.source);
6+
7+
function transformSinonIdentifier() {
8+
let sinon = root.find(j.Identifier, {
9+
name: 'sinon',
10+
});
11+
12+
sinon.replaceWith(j.identifier('this.sandbox'));
13+
}
14+
15+
transformSinonIdentifier();
16+
17+
return root.toSource({
18+
quote: 'single',
19+
wrapColumn: 100,
20+
trailingComma: true,
21+
});
22+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
const { runTransformTest } = require('codemod-cli');
4+
5+
runTransformTest({
6+
type: 'jscodeshift',
7+
name: 'remove-sinon-usages',
8+
});

0 commit comments

Comments
 (0)