1 |
|
2 |
|
3 |
|
4 | import { stripFirstImage } from '../';
|
5 |
|
6 | describe( 'stripFirstImage', () => {
|
7 | test( 'should do nothing if no image is present', () => {
|
8 | expect( stripFirstImage( {}, { shortcode: { content: '' } } ) ).toEqual( '' );
|
9 | expect( stripFirstImage( {}, { shortcode: { content: 'Tucson' } } ) ).toEqual( 'Tucson' );
|
10 | expect( stripFirstImage( {}, { shortcode: { content: '<em>Tucson</em>' } } ) ).toEqual( '<em>Tucson</em>' );
|
11 | } );
|
12 |
|
13 | test( 'should strip out image when leading as expected', () => {
|
14 | expect( stripFirstImage( {}, { shortcode: { content: '<img>' } } ) ).toEqual( '' );
|
15 | expect( stripFirstImage( {}, { shortcode: { content: '<img>Image!' } } ) ).toEqual( 'Image!' );
|
16 | expect( stripFirstImage( {}, { shortcode: { content: '<img src="image.png">Image!' } } ) ).toEqual( 'Image!' );
|
17 | } );
|
18 |
|
19 | test( 'should strip out image when not in leading position as expected', () => {
|
20 | expect( stripFirstImage( {}, { shortcode: { content: 'Before<img>' } } ) ).toEqual( 'Before' );
|
21 | expect( stripFirstImage( {}, { shortcode: { content: 'Before<img>Image!' } } ) ).toEqual( 'BeforeImage!' );
|
22 | expect( stripFirstImage( {}, { shortcode: { content: 'Before<img src="image.png">Image!' } } ) ).toEqual( 'BeforeImage!' );
|
23 | } );
|
24 |
|
25 | test( 'should strip out only the first of many images', () => {
|
26 | expect( stripFirstImage( {}, { shortcode: { content: '<img><img>' } } ) ).toEqual( '<img>' );
|
27 | } );
|
28 |
|
29 | test( 'should strip out the first image and its wrapping parents', () => {
|
30 | expect( stripFirstImage( {}, { shortcode: { content: '<p><a><img></a></p><p><img></p>' } } ) ).toEqual( '<p><img></p>' );
|
31 | } );
|
32 | } );
|