Chromium Code Reviews| Index: remoting/webapp/js_proto/sinon_proto.js |
| diff --git a/remoting/webapp/js_proto/sinon_proto.js b/remoting/webapp/js_proto/sinon_proto.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a58873a8ab541f25db0e889f0e0c0923eae82f83 |
| --- /dev/null |
| +++ b/remoting/webapp/js_proto/sinon_proto.js |
| @@ -0,0 +1,117 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// This file contains various hacks needed to inform JSCompiler of various |
| +// test-specific properties and methods. It is used only with JSCompiler to |
| +// verify the type-correctness of our code. |
| + |
| +var sinon = sinon || {}; |
| + |
| +/** @type {Object} */ |
| +sinon.assert = {}; |
| + |
| +/** |
| + * @param {(sinon.$spy|Function)} f |
| + */ |
| +sinon.assert.called = function(f) {}; |
| + |
| +/** |
| + * @param {(sinon.$spy|Function)} f |
| + */ |
| +sinon.assert.calledOnce = function(f) {}; |
| + |
| +/** |
| + * @param {(sinon.$spy|Function)} f |
| + * @param {...} data |
| + */ |
| +sinon.assert.calledWith = function(f, data) {}; |
| + |
| +/** |
| + * @param {(sinon.$spy|Function)} f |
| + */ |
| +sinon.assert.notCalled = function(f) {}; |
| + |
| +/** @constructor */ |
| +sinon.expectation = function() {}; |
|
kelvinp
2015/02/26 00:31:30
Use upper case for type names s/expectation/Expect
garykac
2015/02/28 02:33:33
Done.
|
| + |
| +/** @return {sinon.expectation} */ |
| +sinon.expectation.prototype.once = function() {}; |
| + |
| +/** |
| + * @param {...} data |
| + * @return {sinon.expectation} |
| + */ |
| +sinon.expectation.prototype.withArgs = function(data) {}; |
| + |
| +/** @return {boolean} */ |
| +sinon.expectation.prototype.verify = function() {}; |
| + |
| +/** @param {...} data */ |
| +sinon.expectation.prototype.returns = function(data) {}; |
| + |
| +/** @constructor */ |
| +sinon.$mock = function() {}; |
|
kelvinp
2015/02/26 00:31:30
Use upper case for type names s/$mock/Mock
Not nee
garykac
2015/02/28 02:33:33
Done.
|
| + |
| +/** |
| + * @param {Object} obj |
| + * @return {sinon.$mock} |
| + */ |
| +sinon.mock = function(obj) {}; |
| + |
| +/** |
| + * @param {string} method |
| + * @return {sinon.expectation} |
| + */ |
| +sinon.$mock.prototype.expects = function(method) {}; |
| + |
| +/** @type {function(...):Function} */ |
|
kelvinp
2015/02/26 00:31:30
should it be
/**
* @param {...} var_args
* @ret
garykac
2015/02/28 02:33:33
They're the same thing.
|
| +sinon.spy = function() {}; |
| + |
| +/** |
| + * This is a jscompile type that can be OR'ed with the actual type to make |
| + * jscompile aware of the sinon.spy functions that are added to the base |
| + * type. |
| + * Example: Instead of specifying a type of |
| + * {function():void} |
| + * the following can be used to add the sinon.spy functions: |
| + * {(sinon.$spy|function():void)} |
| + * |
| + * @constructor |
| + */ |
| +sinon.$spy = function() {}; |
|
kelvinp
2015/02/26 00:31:30
Use upper case for type names s/$spy/Spy
garykac
2015/02/28 02:33:33
Done.
|
| + |
| +/** @type {number} */ |
| +sinon.$spy.prototype.callCount; |
| + |
| +/** @type {boolean} */ |
| +sinon.$spy.prototype.called = false; |
| + |
| +/** @type {function(...):boolean} */ |
| +sinon.$spy.prototype.calledWith = function() {}; |
| + |
| +/** @type {function(number):{args:Array}} */ |
| +sinon.$spy.prototype.getCall = function(index) {}; |
| + |
| +sinon.$spy.prototype.reset = function() {}; |
| + |
| +/** |
| + * @param {Object} obj |
| + * @param {string} method |
| + * @return {sinon.$testStub} |
| + */ |
| +sinon.stub = function(obj, method) {}; |
| + |
| +/** @constructor */ |
| +sinon.$testStub = function() {}; |
|
kelvinp
2015/02/26 00:31:30
Use upper case for type names s/$testStub/TestStub
garykac
2015/02/28 02:33:33
Done.
|
| + |
| +/** @type {function(number):{args:Array}} */ |
| +sinon.$testStub.prototype.getCall = function(index) {}; |
| + |
| +sinon.$testStub.prototype.restore = function() {}; |
| + |
| +/** @param {*} a */ |
| +sinon.$testStub.prototype.returns = function(a) {}; |
| + |
| +/** @type {function(string, (string|Array<string>)=):sinon.expectation} */ |
| +sinon.$testStub.prototype.withArgs = function(messageName, opt_args) {}; |