Skip to content

Commit 46fd81b

Browse files
committed
Remove deprecation warning from tests for old API
1 parent 454e0fd commit 46fd81b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/collection-test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var sinonCollection = require("../lib/sinon/collection");
55
var sinonSpy = require("../lib/sinon/spy");
66
var sinonStub = require("../lib/sinon/stub");
77
var assert = referee.assert;
8+
var deprecated = require("../lib/sinon/util/core/deprecated");
89

910
describe("collection", function () {
1011
it("creates fake collection", function () {
@@ -106,8 +107,13 @@ describe("collection", function () {
106107
});
107108

108109
it("stubs environment property", function () {
110+
var originalPrintWarning = deprecated.printWarning;
111+
deprecated.printWarning = function () {};
112+
109113
this.collection.stub(process.env, "HELL", "froze over");
110114
assert.equals(process.env.HELL, "froze over");
115+
116+
deprecated.printWarning = originalPrintWarning;
111117
});
112118
});
113119
}
@@ -120,37 +126,57 @@ describe("collection", function () {
120126
});
121127

122128
it("stubs number property", function () {
129+
var originalPrintWarning = deprecated.printWarning;
130+
deprecated.printWarning = function () {};
131+
123132
this.collection.stub(this.object, "property", 1);
124133

125134
assert.equals(this.object.property, 1);
135+
136+
deprecated.printWarning = originalPrintWarning;
126137
});
127138

128139
it("restores number property", function () {
140+
var originalPrintWarning = deprecated.printWarning;
141+
deprecated.printWarning = function () {};
142+
129143
this.collection.stub(this.object, "property", 1);
130144
this.collection.restore();
131145

132146
assert.equals(this.object.property, 42);
147+
148+
deprecated.printWarning = originalPrintWarning;
133149
});
134150

135151
it("fails if property does not exist", function () {
152+
var originalPrintWarning = deprecated.printWarning;
153+
deprecated.printWarning = function () {};
154+
136155
var collection = this.collection;
137156
var object = {};
138157

139158
assert.exception(function () {
140159
collection.stub(object, "prop", 1);
141160
});
161+
162+
deprecated.printWarning = originalPrintWarning;
142163
});
143164

144165
it("fails if Symbol does not exist", function () {
145166
if (typeof Symbol === "function") {
146167
var collection = this.collection;
147168
var object = {};
148169

170+
var originalPrintWarning = deprecated.printWarning;
171+
deprecated.printWarning = function () {};
172+
149173
assert.exception(function () {
150174
collection.stub(object, Symbol(), 1);
151175
}, function (err) {
152176
return err.message === "Cannot stub non-existent own property Symbol()";
153177
});
178+
179+
deprecated.printWarning = originalPrintWarning;
154180
}
155181
});
156182
});

0 commit comments

Comments
 (0)