11
11
goog . module ( 'goog.testing.i18n.assertsTest' ) ;
12
12
goog . setTestOnly ( ) ;
13
13
14
- const ExpectedFailures = goog . require ( 'goog.testing.ExpectedFailures' ) ;
15
14
const asserts = goog . require ( 'goog.testing.i18n.asserts' ) ;
16
15
const testSuite = goog . require ( 'goog.testing.testSuite' ) ;
17
16
18
17
// Add this mapping for testing only
19
18
asserts . addI18nMapping ( 'mappedValue' , 'newValue' ) ;
20
19
asserts . addI18nMapping ( 'X\u0020Y' , 'AB' ) ;
21
20
22
- let expectedFailures ;
23
-
24
21
testSuite ( {
25
- setUpPage ( ) {
26
- expectedFailures = new ExpectedFailures ( ) ;
27
- } ,
28
-
29
- tearDown ( ) {
30
- expectedFailures . handleTearDown ( ) ;
31
- } ,
32
-
33
22
/** @suppress {checkTypes} suppression added to enable type checking */
34
23
testEdgeCases ( ) {
35
24
// Pass
36
25
asserts . assertI18nEquals ( null , null ) ;
37
26
asserts . assertI18nEquals ( '' , '' ) ;
38
27
39
28
// Fail
40
- expectedFailures . expectFailureFor ( true ) ;
41
- try {
29
+ assertThrowsJsUnitException ( ( ) => {
42
30
asserts . assertI18nEquals ( null , '' ) ;
31
+ } ) ;
32
+ assertThrowsJsUnitException ( ( ) => {
43
33
asserts . assertI18nEquals ( null , 'test' ) ;
34
+ } ) ;
35
+ assertThrowsJsUnitException ( ( ) => {
44
36
asserts . assertI18nEquals ( '' , null ) ;
37
+ } ) ;
38
+ assertThrowsJsUnitException ( ( ) => {
45
39
asserts . assertI18nEquals ( '' , 'test' ) ;
40
+ } ) ;
41
+ assertThrowsJsUnitException ( ( ) => {
46
42
asserts . assertI18nEquals ( 'test' , null ) ;
43
+ } ) ;
44
+ assertThrowsJsUnitException ( ( ) => {
47
45
asserts . assertI18nEquals ( 'test' , '' ) ;
48
- } catch ( e ) {
49
- expectedFailures . handleException ( e ) ;
50
- }
46
+ } ) ;
47
+ } ,
48
+
49
+ /** @suppress {checkTypes} suppression added to enable type checking */
50
+ testEdgeCases_withComments ( ) {
51
+ // Pass
52
+ asserts . assertI18nEquals ( 'Expect null values to match.' , null , null ) ;
53
+ asserts . assertI18nEquals ( 'Expect empty values to match.' , '' , '' ) ;
54
+
55
+ // Fail
56
+ assertThrowsJsUnitException ( ( ) => {
57
+ asserts . assertI18nEquals (
58
+ 'Expect null and empty values to not match.' , null , '' ) ;
59
+ } ) ;
60
+ assertThrowsJsUnitException ( ( ) => {
61
+ asserts . assertI18nEquals (
62
+ 'Expect null and non-empty values to not match.' , null , 'test' ) ;
63
+ } ) ;
64
+ assertThrowsJsUnitException ( ( ) => {
65
+ asserts . assertI18nEquals (
66
+ 'Expect empty and null values to not match.' , '' , null ) ;
67
+ } ) ;
68
+ assertThrowsJsUnitException ( ( ) => {
69
+ asserts . assertI18nEquals (
70
+ 'Expect empty and non-empty values to not match.' , '' , 'test' ) ;
71
+ } ) ;
72
+ assertThrowsJsUnitException ( ( ) => {
73
+ asserts . assertI18nEquals (
74
+ 'Expect non-empty and null values to not match.' , 'test' , null ) ;
75
+ } ) ;
76
+ assertThrowsJsUnitException ( ( ) => {
77
+ asserts . assertI18nEquals (
78
+ 'Expect non-empty and empty values to not match.' , 'test' , '' ) ;
79
+ } ) ;
51
80
} ,
52
81
53
82
testContains ( ) {
@@ -57,12 +86,9 @@ testSuite({
57
86
asserts . assertI18nContains ( 'mappedValue' , '** newValue' ) ;
58
87
59
88
// Negative testing
60
- expectedFailures . expectFailureFor ( true ) ;
61
- try {
62
- asserts . assertI18nContains ( 'mappedValue' , '** dummy' ) ;
63
- } catch ( e ) {
64
- expectedFailures . handleException ( e ) ;
65
- }
89
+ assertThrowsJsUnitException ( ( ) => {
90
+ asserts . assertI18nEquals ( 'mappedValue' , '** dummy' ) ;
91
+ } ) ;
66
92
} ,
67
93
68
94
testMappingWorks ( ) {
@@ -72,12 +98,9 @@ testSuite({
72
98
asserts . assertI18nEquals ( 'mappedValue' , 'newValue' ) ;
73
99
74
100
// Negative testing
75
- expectedFailures . expectFailureFor ( true ) ;
76
- try {
101
+ assertThrowsJsUnitException ( ( ) => {
77
102
asserts . assertI18nEquals ( 'unmappedValue' , 'newValue' ) ;
78
- } catch ( e ) {
79
- expectedFailures . handleException ( e ) ;
80
- }
103
+ } ) ;
81
104
} ,
82
105
83
106
testWhiteSpaceStringWorks ( ) {
0 commit comments