Skip to content

Commit 17bf8d5

Browse files
committed
format
1 parent 471e697 commit 17bf8d5

File tree

2 files changed

+72
-67
lines changed

2 files changed

+72
-67
lines changed

lib/sinon/default-behaviors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ function throwsException(fake, error, message) {
3333
const SKIP_OPTIONS_FOR_YIELDS = {
3434
skipReturn: true,
3535
skipThrows: true,
36-
}
36+
};
3737

3838
function clear(fake, options) {
3939
fake.fakeFn = undefined;
4040

4141
fake.callsThrough = undefined;
4242
fake.callsThroughWithNew = undefined;
4343

44-
if(!options || !options.skipThrows) {
44+
if (!options || !options.skipThrows) {
4545
fake.exception = undefined;
4646
fake.exceptionCreator = undefined;
4747
fake.throwArgAt = undefined;
@@ -53,7 +53,7 @@ function clear(fake, options) {
5353
fake.callArgProp = undefined;
5454
fake.callbackAsync = undefined;
5555

56-
if(!options || !options.skipReturn) {
56+
if (!options || !options.skipReturn) {
5757
fake.returnValue = undefined;
5858
fake.returnValueDefined = undefined;
5959
fake.returnArgAt = undefined;

test/stub-test.js

Lines changed: 69 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ describe("stub", function () {
229229
const obj = {
230230
fn() {
231231
return 1;
232-
}
233-
}
234-
const stub = createStub(obj, 'fn').callThrough().returns(2);
232+
},
233+
};
234+
const stub = createStub(obj, "fn").callThrough().returns(2);
235235

236236
assert.equals(stub(), 2);
237237
});
@@ -299,14 +299,13 @@ describe("stub", function () {
299299
const obj = {
300300
fn() {
301301
return Promise.resolve(1);
302-
}
303-
}
304-
const stub = createStub(obj, 'fn').callThrough().resolves(2);
302+
},
303+
};
304+
const stub = createStub(obj, "fn").callThrough().resolves(2);
305305

306-
return stub()
307-
.then(function (actual) {
308-
assert.equals(actual, 2);
309-
});
306+
return stub().then(function (actual) {
307+
assert.equals(actual, 2);
308+
});
310309
});
311310

312311
it("supersedes previous callsFake", function () {
@@ -434,10 +433,10 @@ describe("stub", function () {
434433
const obj = {
435434
fn() {
436435
return Promise.resolve(1);
437-
}
436+
},
438437
};
439438
const reason = new Error();
440-
const stub = createStub(obj, 'fn').callThrough().rejects(reason);
439+
const stub = createStub(obj, "fn").callThrough().rejects(reason);
441440

442441
return stub()
443442
.then(function () {
@@ -528,14 +527,13 @@ describe("stub", function () {
528527
const obj = {
529528
fn() {
530529
return Promise.resolve(1);
531-
}
530+
},
532531
};
533-
createStub(obj, 'fn').callThrough().resolvesThis();
532+
createStub(obj, "fn").callThrough().resolvesThis();
534533

535-
return obj.fn()
536-
.then(function (actual) {
537-
assert.same(actual, obj);
538-
});
534+
return obj.fn().then(function (actual) {
535+
assert.same(actual, obj);
536+
});
539537
});
540538

541539
it("supersedes previous callsFake", function () {
@@ -623,15 +621,14 @@ describe("stub", function () {
623621
it("supersedes previous callThrough", function () {
624622
const obj = {
625623
fn() {
626-
return Promise.resolve('nooooo');
627-
}
624+
return Promise.resolve("nooooo");
625+
},
628626
};
629-
createStub(obj, 'fn').callThrough().resolvesArg(1);
627+
createStub(obj, "fn").callThrough().resolvesArg(1);
630628

631-
return obj.fn('zero', 'one')
632-
.then(function (actual) {
633-
assert.same(actual, "one");
634-
});
629+
return obj.fn("zero", "one").then(function (actual) {
630+
assert.same(actual, "one");
631+
});
635632
});
636633

637634
it("does not invoke Promise.resolve when the behavior is added to the stub", function () {
@@ -696,10 +693,10 @@ describe("stub", function () {
696693
it("supersedes previous callThrough", function () {
697694
const obj = {
698695
fn() {
699-
return 'nooooo';
700-
}
696+
return "nooooo";
697+
},
701698
};
702-
createStub(obj, 'fn').callThrough().returnsArg(0);
699+
createStub(obj, "fn").callThrough().returnsArg(0);
703700

704701
assert.equals(obj.fn("myarg"), "myarg");
705702
});
@@ -833,10 +830,10 @@ describe("stub", function () {
833830
it("supersedes previous callThrough", function () {
834831
const obj = {
835832
fn() {
836-
return 'nooooo';
837-
}
833+
return "nooooo";
834+
},
838835
};
839-
createStub(obj, 'fn').callThrough().throwsArg(1);
836+
createStub(obj, "fn").callThrough().throwsArg(1);
840837
const expectedError = new Error("catpants");
841838

842839
assert.exception(
@@ -905,10 +902,10 @@ describe("stub", function () {
905902
it("supersedes previous callThrough", function () {
906903
const obj = {
907904
fn() {
908-
return 'nooooo';
909-
}
905+
return "nooooo";
906+
},
910907
};
911-
createStub(obj, 'fn').callThrough().returnsThis();
908+
createStub(obj, "fn").callThrough().returnsThis();
912909

913910
assert.same(obj.fn(), obj);
914911
});
@@ -1150,11 +1147,11 @@ describe("stub", function () {
11501147
it("supersedes previous callThrough", function () {
11511148
const obj = {
11521149
fn() {
1153-
return 'nooooo';
1154-
}
1150+
return "nooooo";
1151+
},
11551152
};
11561153
const expectedError = new Error("catpants");
1157-
createStub(obj, 'fn').callThrough().throws(expectedError);
1154+
createStub(obj, "fn").callThrough().throws(expectedError);
11581155

11591156
assert.exception(obj.fn, {
11601157
message: expectedError.message,
@@ -1240,10 +1237,10 @@ describe("stub", function () {
12401237
it("supersedes previous callThrough", function () {
12411238
const obj = {
12421239
fn() {
1243-
return 'nooooo';
1244-
}
1240+
return "nooooo";
1241+
},
12451242
};
1246-
const stub = createStub(obj, 'fn').callThrough().callsArg(0);
1243+
const stub = createStub(obj, "fn").callThrough().callsArg(0);
12471244

12481245
const callback = createStub().returns("return value");
12491246

@@ -1326,10 +1323,12 @@ describe("stub", function () {
13261323
it("supersedes previous callThrough", function () {
13271324
const obj = {
13281325
fn() {
1329-
return 'nooooo';
1330-
}
1326+
return "nooooo";
1327+
},
13311328
};
1332-
const stub = createStub(obj, 'fn').callThrough().callsArgWith(0, 'test');
1329+
const stub = createStub(obj, "fn")
1330+
.callThrough()
1331+
.callsArgWith(0, "test");
13331332
const callback = createStub().returns("return value");
13341333

13351334
assert.same(stub(callback), "return value");
@@ -1426,10 +1425,10 @@ describe("stub", function () {
14261425
it("supersedes previous callThrough", function () {
14271426
const obj = {
14281427
fn() {
1429-
return 'nooooo';
1430-
}
1428+
return "nooooo";
1429+
},
14311430
};
1432-
createStub(obj, 'fn').callThrough().callsArgOn(0, this.fakeContext);
1431+
createStub(obj, "fn").callThrough().callsArgOn(0, this.fakeContext);
14331432
const callback = createStub().returns("return value");
14341433

14351434
assert.same(obj.fn(callback), "return value");
@@ -1562,12 +1561,14 @@ describe("stub", function () {
15621561
it("supersedes previous callThrough", function () {
15631562
const obj = {
15641563
fn() {
1565-
return 'nooooo';
1566-
}
1564+
return "nooooo";
1565+
},
15671566
};
15681567

1569-
const arg = 'hello';
1570-
createStub(obj, 'fn').callThrough().callsArgOnWith(1, this.fakeContext, arg);
1568+
const arg = "hello";
1569+
createStub(obj, "fn")
1570+
.callThrough()
1571+
.callsArgOnWith(1, this.fakeContext, arg);
15711572
const callback = createStub();
15721573

15731574
obj.fn(1, callback);
@@ -1632,13 +1633,15 @@ describe("stub", function () {
16321633
it("supersedes previous callThrough", function () {
16331634
const obj = {
16341635
fn() {
1635-
return 'nooooo';
1636-
}
1636+
return "nooooo";
1637+
},
16371638
};
16381639

1639-
createStub(obj, 'fn').callThrough().callsFake(() => 'yeees');
1640+
createStub(obj, "fn")
1641+
.callThrough()
1642+
.callsFake(() => "yeees");
16401643

1641-
assert.same(obj.fn(), 'yeees');
1644+
assert.same(obj.fn(), "yeees");
16421645
});
16431646
});
16441647

@@ -1941,10 +1944,10 @@ describe("stub", function () {
19411944
const obj = {
19421945
fn() {
19431946
return 1;
1944-
}
1947+
},
19451948
};
19461949

1947-
createStub(obj, 'fn').callThrough().yields(2);
1950+
createStub(obj, "fn").callThrough().yields(2);
19481951
const spy = createSpy();
19491952
obj.fn(spy);
19501953

@@ -2085,10 +2088,10 @@ describe("stub", function () {
20852088
const obj = {
20862089
fn() {
20872090
return 1;
2088-
}
2091+
},
20892092
};
20902093

2091-
createStub(obj, 'fn').callThrough().yieldsRight(2);
2094+
createStub(obj, "fn").callThrough().yieldsRight(2);
20922095
const spy = createSpy();
20932096
obj.fn(spy);
20942097

@@ -2256,10 +2259,10 @@ describe("stub", function () {
22562259
const obj = {
22572260
fn() {
22582261
return 1;
2259-
}
2262+
},
22602263
};
22612264

2262-
createStub(obj, 'fn').callThrough().yieldsOn(this.fakeContext, 2);
2265+
createStub(obj, "fn").callThrough().yieldsOn(this.fakeContext, 2);
22632266
const spy = createSpy();
22642267
obj.fn(spy);
22652268

@@ -2421,10 +2424,10 @@ describe("stub", function () {
24212424
const obj = {
24222425
fn() {
24232426
return 1;
2424-
}
2427+
},
24252428
};
24262429

2427-
createStub(obj, 'fn').callThrough().yieldsTo("success", 2);
2430+
createStub(obj, "fn").callThrough().yieldsTo("success", 2);
24282431
const callback = createSpy();
24292432
obj.fn({ success: callback });
24302433

@@ -2621,10 +2624,12 @@ describe("stub", function () {
26212624
const obj = {
26222625
fn() {
26232626
return 1;
2624-
}
2627+
},
26252628
};
26262629

2627-
createStub(obj, 'fn').callThrough().yieldsToOn("success", this.fakeContext, 2);
2630+
createStub(obj, "fn")
2631+
.callThrough()
2632+
.yieldsToOn("success", this.fakeContext, 2);
26282633
const callback = createSpy();
26292634
obj.fn({ success: callback });
26302635

0 commit comments

Comments
 (0)