default_appearance_spec.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 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 _default_appearance = require("../../core/default_appearance.js");
  24. describe("Default appearance", function () {
  25. describe("parseDefaultAppearance and createDefaultAppearance", function () {
  26. it("should parse and create default appearance", function () {
  27. const da = "/F1 12 Tf 0.1 0.2 0.3 rg";
  28. const result = {
  29. fontSize: 12,
  30. fontName: "F1",
  31. fontColor: new Uint8ClampedArray([26, 51, 76])
  32. };
  33. expect((0, _default_appearance.parseDefaultAppearance)(da)).toEqual(result);
  34. expect((0, _default_appearance.createDefaultAppearance)(result)).toEqual(da);
  35. expect((0, _default_appearance.parseDefaultAppearance)("0.1 0.2 0.3 rg /F1 12 Tf 0.3 0.2 0.1 rg /F2 13 Tf")).toEqual({
  36. fontSize: 13,
  37. fontName: "F2",
  38. fontColor: new Uint8ClampedArray([76, 51, 26])
  39. });
  40. });
  41. it("should parse default appearance with save/restore", function () {
  42. const da = "q Q 0.1 0.2 0.3 rg /F1 12 Tf q 0.3 0.2 0.1 rg /F2 13 Tf Q";
  43. expect((0, _default_appearance.parseDefaultAppearance)(da)).toEqual({
  44. fontSize: 12,
  45. fontName: "F1",
  46. fontColor: new Uint8ClampedArray([26, 51, 76])
  47. });
  48. });
  49. });
  50. });