pdf_find_utils_spec.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2019 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. "use strict";
  23. var _pdf_find_utils = require("../../web/pdf_find_utils");
  24. describe('pdf_find_utils', function () {
  25. describe('getCharacterType', function () {
  26. it('gets expected character types', function () {
  27. var characters = {
  28. 'A': _pdf_find_utils.CharacterType.ALPHA_LETTER,
  29. 'a': _pdf_find_utils.CharacterType.ALPHA_LETTER,
  30. '0': _pdf_find_utils.CharacterType.ALPHA_LETTER,
  31. '5': _pdf_find_utils.CharacterType.ALPHA_LETTER,
  32. '\xC4': _pdf_find_utils.CharacterType.ALPHA_LETTER,
  33. '\xE4': _pdf_find_utils.CharacterType.ALPHA_LETTER,
  34. '_': _pdf_find_utils.CharacterType.ALPHA_LETTER,
  35. ' ': _pdf_find_utils.CharacterType.SPACE,
  36. '\t': _pdf_find_utils.CharacterType.SPACE,
  37. '\r': _pdf_find_utils.CharacterType.SPACE,
  38. '\n': _pdf_find_utils.CharacterType.SPACE,
  39. '\xA0': _pdf_find_utils.CharacterType.SPACE,
  40. '-': _pdf_find_utils.CharacterType.PUNCT,
  41. ',': _pdf_find_utils.CharacterType.PUNCT,
  42. '.': _pdf_find_utils.CharacterType.PUNCT,
  43. ';': _pdf_find_utils.CharacterType.PUNCT,
  44. ':': _pdf_find_utils.CharacterType.PUNCT,
  45. "\u2122": _pdf_find_utils.CharacterType.ALPHA_LETTER,
  46. "\u0E25": _pdf_find_utils.CharacterType.THAI_LETTER,
  47. "\u4000": _pdf_find_utils.CharacterType.HAN_LETTER,
  48. "\uF950": _pdf_find_utils.CharacterType.HAN_LETTER,
  49. "\u30C0": _pdf_find_utils.CharacterType.KATAKANA_LETTER,
  50. "\u3050": _pdf_find_utils.CharacterType.HIRAGANA_LETTER,
  51. "\uFF80": _pdf_find_utils.CharacterType.HALFWIDTH_KATAKANA_LETTER
  52. };
  53. for (var character in characters) {
  54. var charCode = character.charCodeAt(0);
  55. var type = characters[character];
  56. expect((0, _pdf_find_utils.getCharacterType)(charCode)).toEqual(type);
  57. }
  58. });
  59. });
  60. });