2
0

pdf_find_utils_spec.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 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.js");
  24. describe("pdf_find_utils", function () {
  25. describe("getCharacterType", function () {
  26. it("gets expected character types", function () {
  27. const 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. Ä: _pdf_find_utils.CharacterType.ALPHA_LETTER,
  33. ä: _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. ล: _pdf_find_utils.CharacterType.THAI_LETTER,
  47. 䀀: _pdf_find_utils.CharacterType.HAN_LETTER,
  48. 縷: _pdf_find_utils.CharacterType.HAN_LETTER,
  49. ダ: _pdf_find_utils.CharacterType.KATAKANA_LETTER,
  50. ぐ: _pdf_find_utils.CharacterType.HIRAGANA_LETTER,
  51. タ: _pdf_find_utils.CharacterType.HALFWIDTH_KATAKANA_LETTER
  52. };
  53. for (const character in characters) {
  54. const charCode = character.charCodeAt(0);
  55. const type = characters[character];
  56. expect((0, _pdf_find_utils.getCharacterType)(charCode)).toEqual(type);
  57. }
  58. });
  59. });
  60. });