Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(978)

Side by Side Diff: appengine/config_service/ui/bower_components/sinon-chai/test/callArguments.coffee

Issue 2923973003: Added base template for config ui. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 "use strict"
2
3 sinon = require("sinon")
4
5 describe "Call arguments", ->
6 spy = null
7 arg1 = null
8 arg2 = null
9 arg3 = null
10 arg4 = null
11 notArg = null
12 any = null
13
14 beforeEach ->
15 spy = sinon.spy()
16 arg1 = "A"
17 arg2 = "B"
18 arg3 = {D: "E"}
19 arg4 = {D: {E: {E: "P"}}}
20 notArg = "C"
21 any = sinon.match.any
22
23 describe "calledWith", ->
24 it "should throw an assertion error when the spy is not called", ->
25 expect(-> spy.should.have.been.calledWith(arg1, arg2)).to.throw(Asse rtionError)
26
27 it "should not throw when the spy is called with the correct arguments", ->
28 spy(arg1, arg2)
29
30 expect(-> spy.should.have.been.calledWith(arg1, arg2)).to.not.throw( )
31 expect(-> spy.getCall(0).should.have.been.calledWith(arg1, arg2)).to .not.throw()
32
33 it "should not throw when the spy is called with the correct arguments a nd more", ->
34 spy(arg1, arg2, notArg)
35
36 expect(-> spy.should.have.been.calledWith(arg1, arg2)).to.not.throw( )
37 expect(-> spy.getCall(0).should.have.been.calledWith(arg1, arg2)).to .not.throw()
38
39 it "should throw an assertion error when the spy is called with incorrec t arguments", ->
40 spy(notArg, arg1)
41
42 expect(-> spy.should.have.been.calledWith(arg1, arg2)).to.throw(Asse rtionError)
43 expect(-> spy.getCall(0).should.have.been.calledWith(arg1, arg2)).to .throw(AssertionError)
44
45 it "should not throw when the spy is called with incorrect arguments but then correct ones", ->
46 spy(notArg, arg1)
47 spy(arg1, arg2)
48
49 expect(-> spy.should.have.been.calledWith(arg1, arg2)).to.not.throw( )
50 expect(-> spy.getCall(1).should.have.been.calledWith(arg1, arg2)).to .not.throw()
51
52 it "should handle objects in arguments", ->
53 spy(arg1, arg3)
54 _arg3 = JSON.parse(JSON.stringify(arg3))
55
56 expect(-> spy.should.have.been.calledWith(arg1, _arg3)).to.not.throw ()
57 expect(-> spy.getCall(0).should.have.been.calledWith(arg1, _arg3)).t o.not.throw()
58
59 it "should handle deep objects in arguments", ->
60 spy(arg1, arg4)
61 _arg4 = JSON.parse(JSON.stringify(arg4))
62
63 expect(-> spy.should.have.been.calledWith(arg1, _arg4)).to.not.throw ()
64 expect(-> spy.getCall(0).should.have.been.calledWith(arg1, _arg4)).t o.not.throw()
65
66
67 describe "always calledWith", ->
68 it "should throw an assertion error when the spy is not called", ->
69 expect(-> spy.should.always.have.been.calledWith(arg1, arg2)).to.thr ow(AssertionError)
70 expect(-> spy.should.have.always.been.calledWith(arg1, arg2)).to.thr ow(AssertionError)
71 expect(-> spy.should.have.been.always.calledWith(arg1, arg2)).to.thr ow(AssertionError)
72
73 it "should not throw when the spy is called with the correct arguments", ->
74 spy(arg1, arg2)
75
76 expect(-> spy.should.always.have.been.calledWith(arg1, arg2)).to.not .throw()
77 expect(-> spy.should.have.always.been.calledWith(arg1, arg2)).to.not .throw()
78 expect(-> spy.should.have.been.always.calledWith(arg1, arg2)).to.not .throw()
79
80 it "should not throw when the spy is called with the correct arguments a nd more", ->
81 spy(arg1, arg2, notArg)
82
83 expect(-> spy.should.always.have.been.calledWith(arg1, arg2)).to.not .throw()
84 expect(-> spy.should.have.always.been.calledWith(arg1, arg2)).to.not .throw()
85 expect(-> spy.should.have.been.always.calledWith(arg1, arg2)).to.not .throw()
86
87 it "should throw an assertion error when the spy is called with incorrec t arguments", ->
88 spy(notArg, arg1)
89
90 expect(-> spy.should.always.have.been.calledWith(arg1, arg2)).to.thr ow(AssertionError)
91 expect(-> spy.should.have.always.been.calledWith(arg1, arg2)).to.thr ow(AssertionError)
92 expect(-> spy.should.have.been.always.calledWith(arg1, arg2)).to.thr ow(AssertionError)
93
94 it "should throw an assertion error when the spy is called with incorrec t arguments but then correct ones", ->
95 spy(notArg, arg1)
96 spy(arg1, arg2)
97
98 expect(-> spy.should.always.have.been.calledWith(arg1, arg2)).to.thr ow(AssertionError)
99 expect(-> spy.should.have.always.been.calledWith(arg1, arg2)).to.thr ow(AssertionError)
100 expect(-> spy.should.have.been.always.calledWith(arg1, arg2)).to.thr ow(AssertionError)
101
102 describe "calledWithExactly", ->
103 it "should throw an assertion error when the spy is not called", ->
104 expect(-> spy.should.have.been.calledWithExactly(arg1, arg2)).to.thr ow(AssertionError)
105
106 it "should not throw when the spy is called with the correct arguments", ->
107 spy(arg1, arg2)
108
109 expect(-> spy.should.have.been.calledWithExactly(arg1, arg2)).to.not .throw()
110 expect(-> spy.getCall(0).should.have.been.calledWithExactly(arg1, ar g2)).to.not.throw()
111
112 it "should throw an assertion error when the spy is called with the corr ect arguments and more", ->
113 spy(arg1, arg2, notArg)
114
115 expect(-> spy.should.have.been.calledWithExactly(arg1, arg2)).to.thr ow(AssertionError)
116 expect(-> spy.getCall(0).should.have.been.calledWithExactly(arg1, ar g2)).to.throw(AssertionError)
117
118 it "should throw an assertion error when the spy is called with incorrec t arguments", ->
119 spy(notArg, arg1)
120
121 expect(-> spy.should.have.been.calledWithExactly(arg1, arg2)).to.thr ow(AssertionError)
122 expect(-> spy.getCall(0).should.have.been.calledWithExactly(arg1, ar g2)).to.throw(AssertionError)
123
124 it "should not throw when the spy is called with incorrect arguments but then correct ones", ->
125 spy(notArg, arg1)
126 spy(arg1, arg2)
127
128 expect(-> spy.should.have.been.calledWithExactly(arg1, arg2)).to.not .throw()
129 expect(-> spy.getCall(1).should.have.been.calledWithExactly(arg1, ar g2)).to.not.throw()
130
131
132 describe "always calledWithExactly", ->
133 it "should throw an assertion error when the spy is not called", ->
134 expect(-> spy.should.always.have.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
135 expect(-> spy.should.have.always.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
136 expect(-> spy.should.have.been.always.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
137
138 it "should not throw when the spy is called with the correct arguments", ->
139 spy(arg1, arg2)
140
141 expect(-> spy.should.always.have.been.calledWithExactly(arg1, arg2)) .to.not.throw()
142 expect(-> spy.should.have.always.been.calledWithExactly(arg1, arg2)) .to.not.throw()
143 expect(-> spy.should.have.been.always.calledWithExactly(arg1, arg2)) .to.not.throw()
144
145 it "should throw an assertion error when the spy is called with the corr ect arguments and more", ->
146 spy(arg1, arg2, notArg)
147
148 expect(-> spy.should.always.have.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
149 expect(-> spy.should.have.always.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
150 expect(-> spy.should.have.been.always.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
151
152 it "should throw an assertion error when the spy is called with incorrec t arguments", ->
153 spy(notArg, arg1)
154
155 expect(-> spy.should.always.have.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
156 expect(-> spy.should.have.always.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
157 expect(-> spy.should.have.been.always.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
158
159 it "should throw an assertion error when the spy is called with incorrec t arguments but then correct ones", ->
160 spy(notArg, arg1)
161 spy(arg1, arg2)
162
163 expect(-> spy.should.always.have.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
164 expect(-> spy.should.have.always.been.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
165 expect(-> spy.should.have.been.always.calledWithExactly(arg1, arg2)) .to.throw(AssertionError)
166
167 describe "calledWithMatch", ->
168 it "should throw an assertion error when the spy is not called", ->
169 expect(-> spy.should.have.been.calledWithMatch(any, any)).to.throw(A ssertionError)
170
171 it "should not throw when the spy is called with the correct arguments", ->
172 spy(arg1, arg2)
173
174 expect(-> spy.should.have.been.calledWithMatch(any, any)).to.not.thr ow()
175 expect(-> spy.getCall(0).should.have.been.calledWithMatch(any, any)) .to.not.throw()
176
177 it "should not throw when the spy is called with the correct arguments a nd more", ->
178 spy(arg1, arg2, notArg)
179
180 expect(-> spy.should.have.been.calledWithMatch(any, any)).to.not.thr ow()
181 expect(-> spy.getCall(0).should.have.been.calledWithMatch(any, any)) .to.not.throw()
182
183 it "should throw an assertion error when the spy is called with incorrec t arguments", ->
184 spy(notArg, arg1)
185
186 expect(-> spy.should.have.been.calledWithMatch(any, arg2)).to.throw( AssertionError)
187 expect(-> spy.getCall(0).should.have.been.calledWithMatch(arg1, any) ).to.throw(AssertionError)
188
189 it "should not throw when the spy is called with incorrect arguments but then correct ones", ->
190 spy(notArg, arg1)
191 spy(arg1, arg2)
192
193 expect(-> spy.should.have.been.calledWithMatch(arg1, arg2)).to.not.t hrow()
194 expect(-> spy.getCall(1).should.have.been.calledWithMatch(arg1, arg2 )).to.not.throw()
195
196
197 describe "always calledWithMatch", ->
198 it "should throw an assertion error when the spy is not called", ->
199 expect(-> spy.should.always.have.been.calledWithMatch(any, any)).to. throw(AssertionError)
200 expect(-> spy.should.have.always.been.calledWithMatch(arg1, any)).to .throw(AssertionError)
201 expect(-> spy.should.have.been.always.calledWithMatch(any, arg2)).to .throw(AssertionError)
202
203 it "should not throw when the spy is called with the correct arguments", ->
204 spy(arg1, arg2)
205
206 expect(-> spy.should.always.have.been.calledWithMatch(any, any)).to. not.throw()
207 expect(-> spy.should.have.always.been.calledWithMatch(any, arg2)).to .not.throw()
208 expect(-> spy.should.have.been.always.calledWithMatch(arg1, any)).to .not.throw()
209
210 it "should not throw when the spy is called with the correct arguments a nd more", ->
211 spy(arg1, arg2, notArg)
212
213 expect(-> spy.should.always.have.been.calledWithMatch(any, any)).to. not.throw()
214 expect(-> spy.should.have.always.been.calledWithMatch(any, arg2)).to .not.throw()
215 expect(-> spy.should.have.been.always.calledWithMatch(arg1, any)).to .not.throw()
216
217 it "should throw an assertion error when the spy is called with incorrec t arguments", ->
218 spy(notArg, arg1)
219
220 expect(-> spy.should.always.have.been.calledWithMatch(any, arg2)).to .throw(AssertionError)
221 expect(-> spy.should.have.always.been.calledWithMatch(arg1, any)).to .throw(AssertionError)
222 expect(-> spy.should.have.been.always.calledWithMatch(arg1, arg2)).t o.throw(AssertionError)
223
224 it "should throw an assertion error when the spy is called with incorrec t arguments but then correct ones", ->
225 spy(notArg, arg1)
226 spy(arg1, arg2)
227
228 expect(-> spy.should.always.have.been.calledWithMatch(arg1, arg2)).t o.throw(AssertionError)
229 expect(-> spy.should.have.always.been.calledWithMatch(arg1, arg2)).t o.throw(AssertionError)
230 expect(-> spy.should.have.been.always.calledWithMatch(arg1, arg2)).t o.throw(AssertionError)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698