8
0

images.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import { testDataProcessor } from '../_utils/utils';
  6. describe( 'GFMDataProcessor', () => {
  7. describe( 'images', () => {
  8. it( 'should process images', () => {
  9. testDataProcessor(
  10. '![alt text](http://example.com/image.png "title text")',
  11. // GitHub is rendering as:
  12. // <p><a href="..." target="_blank"><img src="..." alt="..." title="..." data-canonical-src="..."></a></p>
  13. // We will handle images separately by features.
  14. '<p><img alt="alt text" src="http://example.com/image.png" title="title text"></img></p>'
  15. );
  16. } );
  17. it( 'should process images without title', () => {
  18. testDataProcessor(
  19. '![alt text](http://example.com/image.png)',
  20. '<p><img alt="alt text" src="http://example.com/image.png"></img></p>'
  21. );
  22. } );
  23. it( 'should process images without alt text', () => {
  24. testDataProcessor(
  25. '![](http://example.com/image.png "title text")',
  26. '<p><img alt="" src="http://example.com/image.png" title="title text"></img></p>'
  27. );
  28. } );
  29. it( 'should process referenced images', () => {
  30. testDataProcessor(
  31. '![alt text][logo]\n\n' +
  32. '[logo]: http://example.com/image.png "title text"',
  33. '<p><img alt="alt text" src="http://example.com/image.png" title="title text"></img></p>',
  34. // Referenced images when converting back are converted to direct links.
  35. '![alt text](http://example.com/image.png "title text")'
  36. );
  37. } );
  38. it( 'should process referenced images without title', () => {
  39. testDataProcessor(
  40. '![alt text][logo]\n\n' +
  41. '[logo]: http://example.com/image.png',
  42. '<p><img alt="alt text" src="http://example.com/image.png"></img></p>',
  43. // Referenced images when converting back are converted to direct links.
  44. '![alt text](http://example.com/image.png)'
  45. );
  46. } );
  47. it( 'should process referenced images without alt text', () => {
  48. testDataProcessor(
  49. '![][logo]\n\n' +
  50. '[logo]: http://example.com/image.png "title text"',
  51. '<p><img alt="" src="http://example.com/image.png" title="title text"></img></p>',
  52. // Referenced images when converting back are converted to direct links.
  53. '![](http://example.com/image.png "title text")'
  54. );
  55. } );
  56. } );
  57. } );