localnamefetcher_test.js 1.8 KB

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