standard.spec.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict'
  2. /* global describe, it, jsPDF, comparePdf */
  3. /**
  4. * Standard spec tests
  5. *
  6. * These tests return the datauristring so that reference files can be generated.
  7. * We compare the exact output.
  8. */
  9. describe('Drawing functions', () => {
  10. it('should draw a closed annotation', () => {
  11. const doc = jsPDF()
  12. doc.createAnnotation({
  13. type: 'text',
  14. title: 'note',
  15. bounds: {
  16. x: 10,
  17. y: 10,
  18. w: 200,
  19. h: 80
  20. },
  21. contents: 'This is text annotation (closed by default)',
  22. open: false
  23. })
  24. comparePdf(doc.output(), 'closed.pdf', 'annotations')
  25. })
  26. it('should draw an open annotation', () => {
  27. const doc = jsPDF()
  28. doc.createAnnotation({
  29. type: 'text',
  30. title: 'note',
  31. bounds: {
  32. x: 10,
  33. y: 10,
  34. w: 200,
  35. h: 80
  36. },
  37. contents: 'This is text annotation (open by default)',
  38. open: true
  39. })
  40. comparePdf(doc.output(), 'open.pdf', 'annotations')
  41. })
  42. it('should draw a free text annotation', () => {
  43. const doc = jsPDF()
  44. doc.createAnnotation({
  45. type: 'freetext',
  46. bounds: {
  47. x: 0,
  48. y: 10,
  49. w: 200,
  50. h: 20
  51. },
  52. contents: 'This is a freetext annotation',
  53. color: '#ff0000'
  54. })
  55. comparePdf(doc.output(), 'freetext.pdf', 'annotations')
  56. })
  57. })