OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // This file contains various hacks needed to inform JSCompiler of various | |
6 // test-specific properties and methods. It is used only with JSCompiler to | |
7 // verify the type-correctness of our code. | |
8 | |
9 var sinon = sinon || {}; | |
10 | |
11 /** @type {Object} */ | |
12 sinon.assert = {}; | |
13 | |
14 /** | |
15 * @param {(sinon.$spy|Function)} f | |
16 */ | |
17 sinon.assert.called = function(f) {}; | |
18 | |
19 /** | |
20 * @param {(sinon.$spy|Function)} f | |
21 */ | |
22 sinon.assert.calledOnce = function(f) {}; | |
23 | |
24 /** | |
25 * @param {(sinon.$spy|Function)} f | |
26 * @param {...} data | |
27 */ | |
28 sinon.assert.calledWith = function(f, data) {}; | |
29 | |
30 /** | |
31 * @param {(sinon.$spy|Function)} f | |
32 */ | |
33 sinon.assert.notCalled = function(f) {}; | |
34 | |
35 /** @constructor */ | |
36 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.
| |
37 | |
38 /** @return {sinon.expectation} */ | |
39 sinon.expectation.prototype.once = function() {}; | |
40 | |
41 /** | |
42 * @param {...} data | |
43 * @return {sinon.expectation} | |
44 */ | |
45 sinon.expectation.prototype.withArgs = function(data) {}; | |
46 | |
47 /** @return {boolean} */ | |
48 sinon.expectation.prototype.verify = function() {}; | |
49 | |
50 /** @param {...} data */ | |
51 sinon.expectation.prototype.returns = function(data) {}; | |
52 | |
53 /** @constructor */ | |
54 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.
| |
55 | |
56 /** | |
57 * @param {Object} obj | |
58 * @return {sinon.$mock} | |
59 */ | |
60 sinon.mock = function(obj) {}; | |
61 | |
62 /** | |
63 * @param {string} method | |
64 * @return {sinon.expectation} | |
65 */ | |
66 sinon.$mock.prototype.expects = function(method) {}; | |
67 | |
68 /** @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.
| |
69 sinon.spy = function() {}; | |
70 | |
71 /** | |
72 * This is a jscompile type that can be OR'ed with the actual type to make | |
73 * jscompile aware of the sinon.spy functions that are added to the base | |
74 * type. | |
75 * Example: Instead of specifying a type of | |
76 * {function():void} | |
77 * the following can be used to add the sinon.spy functions: | |
78 * {(sinon.$spy|function():void)} | |
79 * | |
80 * @constructor | |
81 */ | |
82 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.
| |
83 | |
84 /** @type {number} */ | |
85 sinon.$spy.prototype.callCount; | |
86 | |
87 /** @type {boolean} */ | |
88 sinon.$spy.prototype.called = false; | |
89 | |
90 /** @type {function(...):boolean} */ | |
91 sinon.$spy.prototype.calledWith = function() {}; | |
92 | |
93 /** @type {function(number):{args:Array}} */ | |
94 sinon.$spy.prototype.getCall = function(index) {}; | |
95 | |
96 sinon.$spy.prototype.reset = function() {}; | |
97 | |
98 /** | |
99 * @param {Object} obj | |
100 * @param {string} method | |
101 * @return {sinon.$testStub} | |
102 */ | |
103 sinon.stub = function(obj, method) {}; | |
104 | |
105 /** @constructor */ | |
106 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.
| |
107 | |
108 /** @type {function(number):{args:Array}} */ | |
109 sinon.$testStub.prototype.getCall = function(index) {}; | |
110 | |
111 sinon.$testStub.prototype.restore = function() {}; | |
112 | |
113 /** @param {*} a */ | |
114 sinon.$testStub.prototype.returns = function(a) {}; | |
115 | |
116 /** @type {function(string, (string|Array<string>)=):sinon.expectation} */ | |
117 sinon.$testStub.prototype.withArgs = function(messageName, opt_args) {}; | |
OLD | NEW |