@wordpress/element 4.0.1-next.5df0cd52b7.0 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +2 -2
  3. package/build/index.js +8 -8
  4. package/build/platform.android.js +3 -1
  5. package/build/platform.android.js.map +1 -1
  6. package/build/platform.ios.js +3 -1
  7. package/build/platform.ios.js.map +1 -1
  8. package/build/platform.js +2 -1
  9. package/build/platform.js.map +1 -1
  10. package/build/raw-html.js +19 -9
  11. package/build/raw-html.js.map +1 -1
  12. package/build/react.js +49 -45
  13. package/build/react.js.map +1 -1
  14. package/build/serialize.js +12 -7
  15. package/build/serialize.js.map +1 -1
  16. package/build-module/platform.android.js +3 -1
  17. package/build-module/platform.android.js.map +1 -1
  18. package/build-module/platform.ios.js +3 -1
  19. package/build-module/platform.ios.js.map +1 -1
  20. package/build-module/platform.js +2 -1
  21. package/build-module/platform.js.map +1 -1
  22. package/build-module/raw-html.js +19 -10
  23. package/build-module/raw-html.js.map +1 -1
  24. package/build-module/react.js +5 -1
  25. package/build-module/react.js.map +1 -1
  26. package/build-module/serialize.js +9 -4
  27. package/build-module/serialize.js.map +1 -1
  28. package/build-types/create-interpolate-element.d.ts +1 -1
  29. package/build-types/create-interpolate-element.d.ts.map +1 -1
  30. package/build-types/platform.d.ts +1 -0
  31. package/build-types/raw-html.d.ts +4 -3
  32. package/build-types/raw-html.d.ts.map +1 -1
  33. package/build-types/react.d.ts +3 -3
  34. package/build-types/react.d.ts.map +1 -1
  35. package/build-types/serialize.d.ts +2 -2
  36. package/build-types/serialize.d.ts.map +1 -1
  37. package/package.json +4 -4
  38. package/src/platform.android.js +2 -0
  39. package/src/platform.ios.js +2 -0
  40. package/src/platform.js +1 -0
  41. package/src/raw-html.js +16 -6
  42. package/src/test/raw-html.js +46 -11
  43. package/tsconfig.tsbuildinfo +1 -895
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { shallow } from 'enzyme';
4
+ import { render } from '@testing-library/react';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -11,20 +11,55 @@ import RawHTML from '../raw-html';
11
11
  describe( 'RawHTML', () => {
12
12
  it( 'is dangerous', () => {
13
13
  const html = '<p>So scary!</p>';
14
- const element = shallow( <RawHTML>{ html }</RawHTML> );
14
+ const { container } = render( <RawHTML>{ html }</RawHTML> );
15
+ const expected = '<div><p>So scary!</p></div>';
15
16
 
16
- expect( element.type() ).toBe( 'div' );
17
- expect( element.prop( 'dangerouslySetInnerHTML' ).__html ).toBe( html );
18
- expect( element.prop( 'children' ) ).toBe( undefined );
17
+ expect( container.innerHTML ).toBe( expected );
19
18
  } );
20
19
 
21
- it( 'creates wrapper if assigned other props', () => {
20
+ it( 'adds other props to container element', () => {
22
21
  const html = '<p>So scary!</p>';
23
- const element = shallow( <RawHTML className="foo">{ html }</RawHTML> );
22
+ const { container } = render(
23
+ <RawHTML className="foo">{ html }</RawHTML>
24
+ );
24
25
 
25
- expect( element.type() ).toBe( 'div' );
26
- expect( element.prop( 'className' ) ).toBe( 'foo' );
27
- expect( element.prop( 'dangerouslySetInnerHTML' ).__html ).toBe( html );
28
- expect( element.prop( 'children' ) ).toBe( undefined );
26
+ expect( container.innerHTML ).toBe(
27
+ '<div class="foo"><p>So scary!</p></div>'
28
+ );
29
+ } );
30
+
31
+ it( 'concatenates children if multiple children present', () => {
32
+ const html = '<p>So scary!</p>';
33
+ const html2 = '<p>Extra paragraph</p>';
34
+
35
+ const { container } = render(
36
+ <RawHTML>
37
+ { html }
38
+ { html2 }
39
+ </RawHTML>
40
+ );
41
+
42
+ const expected = '<div><p>So scary!</p><p>Extra paragraph</p></div>';
43
+ expect( container.innerHTML ).toBe( expected );
44
+ } );
45
+
46
+ it( 'renders an empty container if there are no children', () => {
47
+ const { container } = render( <RawHTML></RawHTML> );
48
+
49
+ const expected = '<div></div>';
50
+ expect( container.innerHTML ).toBe( expected );
51
+ } );
52
+
53
+ it( 'ignores non-string based children', () => {
54
+ const html = '<p>So scary!</p>';
55
+ const { container } = render(
56
+ <RawHTML>
57
+ { html }
58
+ <p>Ignore this!</p>
59
+ </RawHTML>
60
+ );
61
+
62
+ const expected = '<div><p>So scary!</p></div>';
63
+ expect( container.innerHTML ).toBe( expected );
29
64
  } );
30
65
  } );