Debian Codegraph @

closure-library/closure/goog/labs/mock/verificationmode_test.js

raw
1 // Copyright 2013 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 goog.module('goog.labs.mock.VerificationModeTest');
16 goog.setTestOnly('goog.labs.mock.VerificationModeTest');
17
18 var testSuite = goog.require('goog.testing.testSuite');
19 var verification = goog.require('goog.labs.mock.verification');
20
21 var atLeast = verification.atLeast;
22 var atMost = verification.atMost;
23 var never = verification.never;
24 var times = verification.times;
25
26 testSuite({
27 getTestName: function() { return 'goog.labs.mock.VerificationModeTest'; },
28
29 testTimesVerify_expectedEqualsActual_shouldReturnTrue: function() {
30 assertTrue(times(4).verify(4));
31 },
32
33 testTimesVerify_expectedGreaterThanActual_shouldReturnFalse: function() {
34 assertFalse(times(4).verify(3));
35 },
36
37 testTimesVerify_expectedLessThanActual_shouldReturnFalse: function() {
38 assertFalse(times(4).verify(5));
39 },
40
41 testTimesDescribe_shouldReturnCorrectMessage: function() {
42 assertEquals(4 + ' times', times(4).describe());
43 },
44
45 testNeverVerify_shouldEqualTimesZeroVerify: function() {
46 assertEquals(times(0).verify(0), never().verify(0));
47 },
48
49 testNeverDescribe_shouldReturnTimesZeroMessage: function() {
50 assertEquals(times(0).describe(), never().describe());
51 },
52
53 testAtLeastVerify_expectedEqualsActual_shouldReturnTrue: function() {
54 assertTrue(atLeast(4).verify(4));
55 },
56
57 testAtLeastVerify_expectedLessThanActual_shouldReturnTrue: function() {
58 assertTrue(atLeast(1).verify(3));
59 },
60
61 testAtLeastVerify_expectedGreaterThanActual_shouldReturnFalse: function() {
62 assertFalse(atLeast(4).verify(3));
63 },
64
65 testAtLeastDescribe_shouldReturnCorrectMessage: function() {
66 assertEquals('at least ' + 4 + ' times', atLeast(4).describe());
67 },
68
69 testAtMostVerify_expectedEqualsActual_shouldReturnTrue: function() {
70 assertTrue(atMost(4).verify(4));
71 },
72
73 testAtMostVerify_expectedGreaterThanActual_shouldReturnTrue: function() {
74 assertTrue(atMost(4).verify(3));
75 },
76
77 testAtMostVerify_expectedLessThanActual_shouldReturnFalse: function() {
78 assertFalse(atMost(1).verify(3));
79 },
80
81 testAtMostDescribe_shouldReturnCorrectMessage: function() {
82 assertEquals('at most ' + 4 + ' times', atMost(4).describe());
83 }
84 });