getBBoxCeil.test.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import getBBoxCeil from '../../../src/dimension/svg/getBBoxCeil';
  20. import createTextNode from '../../../src/dimension/svg/createTextNode';
  21. describe('getBBoxCeil(node, defaultDimension)', () => {
  22. describe('returns default dimension if getBBox() is not available', () => {
  23. it('returns default value for default dimension', () => {
  24. expect(getBBoxCeil(createTextNode())).toEqual({
  25. height: 20,
  26. width: 100,
  27. });
  28. });
  29. it('return specified value if specified', () => {
  30. expect(
  31. getBBoxCeil(createTextNode(), {
  32. height: 30,
  33. width: 400,
  34. }),
  35. ).toEqual({
  36. height: 30,
  37. width: 400,
  38. });
  39. });
  40. });
  41. describe('returns ceiling of the svg element', () => {
  42. it('converts to ceiling if value is not integer', () => {
  43. expect(
  44. getBBoxCeil(createTextNode(), { height: 10.6, width: 11.1 }),
  45. ).toEqual({
  46. height: 11,
  47. width: 12,
  48. });
  49. });
  50. it('does nothing if value is integer', () => {
  51. expect(getBBoxCeil(createTextNode())).toEqual({
  52. height: 20,
  53. width: 100,
  54. });
  55. });
  56. });
  57. });