Debian Codegraph @

closure-library/closure/goog/testing/ui/rendererasserts_test.js

raw
1 // Copyright 2009 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.provide('goog.testing.ui.rendererassertsTest');
16 goog.setTestOnly('goog.testing.ui.rendererassertsTest');
17
18 goog.require('goog.testing.TestCase');
19 goog.require('goog.testing.asserts');
20 goog.require('goog.testing.jsunit');
21 goog.require('goog.testing.ui.rendererasserts');
22 goog.require('goog.ui.ControlRenderer');
23
24 function setUp() {
25 // TODO(b/25875505): Fix unreported assertions (go/failonunreportedasserts).
26 goog.testing.TestCase.getActiveTestCase().failOnUnreportedAsserts = false;
27 }
28
29 function testSuccess() {
30 function GoodRenderer() {}
31
32 goog.testing.ui.rendererasserts.assertNoGetCssClassCallsInConstructor(
33 GoodRenderer);
34 }
35
36 function testFailure() {
37 function BadRenderer() {
38 goog.ui.ControlRenderer.call(this);
39 this.myClass = this.getCssClass();
40 }
41 goog.inherits(BadRenderer, goog.ui.ControlRenderer);
42
43 var ex = assertThrows(
44 'Expected assertNoGetCssClassCallsInConstructor to fail.', function() {
45 goog.testing.ui.rendererasserts.assertNoGetCssClassCallsInConstructor(
46 BadRenderer);
47 });
48 assertTrue(
49 'Expected assertNoGetCssClassCallsInConstructor to throw a' +
50 ' jsunit exception',
51 ex.isJsUnitException);
52 assertContains('getCssClass', ex.message);
53 }