|
1 | 1 | describe('i18nService', function () { |
2 | | - var i18nConstants, i18nService; |
| 2 | + var $log, i18nConstants, i18nService; |
3 | 3 |
|
4 | 4 | beforeEach(function() { |
5 | | - module('ui.grid'); |
| 5 | + $log = jasmine.createSpyObj('$log', ['warn']); |
| 6 | + module('ui.grid', function($provide) { |
| 7 | + $provide.value('$log', $log) |
| 8 | + }); |
6 | 9 | inject(function (_i18nConstants_, _i18nService_) { |
7 | 10 | i18nConstants = _i18nConstants_; |
8 | 11 | i18nService = _i18nService_; |
9 | 12 | }); |
10 | 13 | }); |
| 14 | + afterEach(function() { |
| 15 | + $log.warn.calls.reset(); |
| 16 | + }); |
11 | 17 |
|
12 | 18 | describe('i18n service', function() { |
13 | 19 | it('should default to English', function() { |
@@ -77,30 +83,34 @@ describe('i18nService', function () { |
77 | 83 | it('should get safe text when text is defined', function() { |
78 | 84 | expect(i18nService.getSafeText('search.placeholder')).toBe('Search...'); |
79 | 85 | }); |
80 | | - it('should get missing text for missing property', function() { |
| 86 | + it('should get empty string for missing property', function() { |
81 | 87 | var badText = 'search.bad.text'; |
82 | 88 |
|
83 | | - expect(i18nService.getSafeText(badText)).toBe(i18nConstants.MISSING + badText); |
| 89 | + expect(i18nService.getSafeText(badText)).toBe(''); |
| 90 | + expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + badText); |
84 | 91 | }); |
85 | 92 | it('should get fallback text when language is missing or nonexistent', function() { |
86 | 93 | expect(i18nService.getSafeText('search.placeholder', 'valerian')).toBe('Search...'); |
87 | 94 | }); |
88 | | - it('should get missing text when language is missing or nonexistent and there is no fallback', function() { |
| 95 | + it('should get empty string when language is missing or nonexistent and there is no fallback', function() { |
89 | 96 | var badText = 'bad.text'; |
90 | 97 |
|
91 | | - expect(i18nService.getSafeText(badText, 'valerian')).toBe(i18nConstants.MISSING + badText); |
| 98 | + expect(i18nService.getSafeText(badText, 'valerian')).toBe(''); |
| 99 | + expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + badText); |
92 | 100 | }); |
93 | | - it('should get missing text when language is missing or nonexistent and the fallback language is the same', function() { |
| 101 | + it('should get empty string when language is missing or nonexistent and the fallback language is the same', function() { |
94 | 102 | var missingProperty = 'search.placeholder'; |
95 | 103 |
|
96 | 104 | i18nService.setFallbackLang('valerian'); |
97 | | - expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe(i18nConstants.MISSING + missingProperty); |
| 105 | + expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe(''); |
| 106 | + expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + missingProperty); |
98 | 107 | }); |
99 | | - it('should get missing text when language is missing or nonexistent and the fallback language is also missing it', function() { |
| 108 | + it('should get empty string when language is missing or nonexistent and the fallback language is also missing it', function() { |
100 | 109 | var missingProperty = 'search.placeholder'; |
101 | 110 |
|
102 | 111 | i18nService.setFallbackLang('orcish'); |
103 | | - expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe(i18nConstants.MISSING + missingProperty); |
| 112 | + expect(i18nService.getSafeText(missingProperty, 'valerian')).toBe(''); |
| 113 | + expect($log.warn).toHaveBeenCalledWith(i18nConstants.MISSING + missingProperty); |
104 | 114 | }); |
105 | 115 | }); |
106 | 116 | }); |
|
0 commit comments