@@ -5,6 +5,7 @@ var sinonCollection = require("../lib/sinon/collection");
5
5
var sinonSpy = require ( "../lib/sinon/spy" ) ;
6
6
var sinonStub = require ( "../lib/sinon/stub" ) ;
7
7
var assert = referee . assert ;
8
+ var deprecated = require ( "../lib/sinon/util/core/deprecated" ) ;
8
9
9
10
describe ( "collection" , function ( ) {
10
11
it ( "creates fake collection" , function ( ) {
@@ -106,8 +107,13 @@ describe("collection", function () {
106
107
} ) ;
107
108
108
109
it ( "stubs environment property" , function ( ) {
110
+ var originalPrintWarning = deprecated . printWarning ;
111
+ deprecated . printWarning = function ( ) { } ;
112
+
109
113
this . collection . stub ( process . env , "HELL" , "froze over" ) ;
110
114
assert . equals ( process . env . HELL , "froze over" ) ;
115
+
116
+ deprecated . printWarning = originalPrintWarning ;
111
117
} ) ;
112
118
} ) ;
113
119
}
@@ -120,37 +126,57 @@ describe("collection", function () {
120
126
} ) ;
121
127
122
128
it ( "stubs number property" , function ( ) {
129
+ var originalPrintWarning = deprecated . printWarning ;
130
+ deprecated . printWarning = function ( ) { } ;
131
+
123
132
this . collection . stub ( this . object , "property" , 1 ) ;
124
133
125
134
assert . equals ( this . object . property , 1 ) ;
135
+
136
+ deprecated . printWarning = originalPrintWarning ;
126
137
} ) ;
127
138
128
139
it ( "restores number property" , function ( ) {
140
+ var originalPrintWarning = deprecated . printWarning ;
141
+ deprecated . printWarning = function ( ) { } ;
142
+
129
143
this . collection . stub ( this . object , "property" , 1 ) ;
130
144
this . collection . restore ( ) ;
131
145
132
146
assert . equals ( this . object . property , 42 ) ;
147
+
148
+ deprecated . printWarning = originalPrintWarning ;
133
149
} ) ;
134
150
135
151
it ( "fails if property does not exist" , function ( ) {
152
+ var originalPrintWarning = deprecated . printWarning ;
153
+ deprecated . printWarning = function ( ) { } ;
154
+
136
155
var collection = this . collection ;
137
156
var object = { } ;
138
157
139
158
assert . exception ( function ( ) {
140
159
collection . stub ( object , "prop" , 1 ) ;
141
160
} ) ;
161
+
162
+ deprecated . printWarning = originalPrintWarning ;
142
163
} ) ;
143
164
144
165
it ( "fails if Symbol does not exist" , function ( ) {
145
166
if ( typeof Symbol === "function" ) {
146
167
var collection = this . collection ;
147
168
var object = { } ;
148
169
170
+ var originalPrintWarning = deprecated . printWarning ;
171
+ deprecated . printWarning = function ( ) { } ;
172
+
149
173
assert . exception ( function ( ) {
150
174
collection . stub ( object , Symbol ( ) , 1 ) ;
151
175
} , function ( err ) {
152
176
return err . message === "Cannot stub non-existent own property Symbol()" ;
153
177
} ) ;
178
+
179
+ deprecated . printWarning = originalPrintWarning ;
154
180
}
155
181
} ) ;
156
182
} ) ;
0 commit comments