| 1 |
// Copyright 2012 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 |
|
| 16 |
goog.provide('goog.i18n.uChar.LocalNameFetcherTest'); |
| 17 |
goog.setTestOnly('goog.i18n.uChar.LocalNameFetcherTest'); |
| 18 |
|
| 19 |
goog.require('goog.i18n.uChar.LocalNameFetcher'); |
| 20 |
goog.require('goog.testing.jsunit'); |
| 21 |
goog.require('goog.testing.recordFunction'); |
| 22 |
|
| 23 |
var nameFetcher = null; |
| 24 |
|
| 25 |
function setUp() { |
| 26 |
nameFetcher = new goog.i18n.uChar.LocalNameFetcher(); |
| 27 |
} |
| 28 |
|
| 29 |
function testGetName_exists() { |
| 30 |
var callback = goog.testing.recordFunction(function(name) { |
| 31 |
assertEquals('Space', name); |
| 32 |
}); |
| 33 |
nameFetcher.getName(' ', callback); |
| 34 |
assertEquals(1, callback.getCallCount()); |
| 35 |
} |
| 36 |
|
| 37 |
function testGetName_variationSelector() { |
| 38 |
var callback = goog.testing.recordFunction(function(name) { |
| 39 |
assertEquals('Variation Selector - 1', name); |
| 40 |
}); |
| 41 |
nameFetcher.getName('\ufe00', callback); |
| 42 |
assertEquals(1, callback.getCallCount()); |
| 43 |
} |
| 44 |
|
| 45 |
function testGetName_missing() { |
| 46 |
var callback = |
| 47 |
goog.testing.recordFunction(function(name) { assertNull(name); }); |
| 48 |
nameFetcher.getName('P', callback); |
| 49 |
assertEquals(1, callback.getCallCount()); |
| 50 |
} |
| 51 |
|
| 52 |
function testIsNameAvailable_withAvailableName() { |
| 53 |
assertTrue(nameFetcher.isNameAvailable(' ')); |
| 54 |
} |
| 55 |
|
| 56 |
function testIsNameAvailable_withoutAvailableName() { |
| 57 |
assertFalse(nameFetcher.isNameAvailable('a')); |
| 58 |
} |