Use only public API in CSSProperty-test (#10429)
* Use only public API in CSSProperty-test * Move test to ReactDOMServerIntegration * Add explanation
ksvitkovsky committed
Aug 16, 2017 at 12:09 UTC
488e7413caaa5a2813efc91bc320bf8cccc48c36
2 files changed
+37
-37
src/renderers/dom/shared/__tests__/CSSProperty-test.js
deleted
-37
@@ -1,37 +0,0 @@
1
-/**
2
- * Copyright 2014-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @emails react-core
10
- */
11
-
12
-'use strict';
13
-
14
-describe('CSSProperty', () => {
15
- var CSSProperty;
16
-
17
- beforeEach(() => {
18
- jest.resetModules();
19
- // TODO: can we express this test with only public API?
20
- CSSProperty = require('CSSProperty');
21
- });
22
-
23
- it('should generate browser prefixes for its `isUnitlessNumber`', () => {
24
- expect(CSSProperty.isUnitlessNumber.lineClamp).toBeTruthy();
25
- expect(CSSProperty.isUnitlessNumber.WebkitLineClamp).toBeTruthy();
26
- expect(CSSProperty.isUnitlessNumber.msFlexGrow).toBeTruthy();
27
- expect(CSSProperty.isUnitlessNumber.MozFlexGrow).toBeTruthy();
28
- expect(CSSProperty.isUnitlessNumber.msGridRow).toBeTruthy();
29
- expect(CSSProperty.isUnitlessNumber.msGridRowEnd).toBeTruthy();
30
- expect(CSSProperty.isUnitlessNumber.msGridRowSpan).toBeTruthy();
31
- expect(CSSProperty.isUnitlessNumber.msGridRowStart).toBeTruthy();
32
- expect(CSSProperty.isUnitlessNumber.msGridColumn).toBeTruthy();
33
- expect(CSSProperty.isUnitlessNumber.msGridColumnEnd).toBeTruthy();
34
- expect(CSSProperty.isUnitlessNumber.msGridColumnSpan).toBeTruthy();
35
- expect(CSSProperty.isUnitlessNumber.msGridColumnStart).toBeTruthy();
36
- });
37
-});
src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
+37
@@ -791,6 +791,43 @@ describe('ReactDOMServerIntegration', () => {
791
expect(e.style.width).toBe('');
792
expect(e.hasAttribute('style')).toBe(false);
793
});
794
+
795
+ itRenders('unitless-number rules with prefixes', async render => {
796
+ const {style} = await render(
797
+ <div
798
+ style={{
799
+ lineClamp: 10,
800
+ WebkitLineClamp: 10,
801
+ MozFlexGrow: 10,
802
+ msFlexGrow: 10,
803
+ msGridRow: 10,
804
+ msGridRowEnd: 10,
805
+ msGridRowSpan: 10,
806
+ msGridRowStart: 10,
807
+ msGridColumn: 10,
808
+ msGridColumnEnd: 10,
809
+ msGridColumnSpan: 10,
810
+ msGridColumnStart: 10,
811
+ }}
812
+ />,
813
+ );
814
+
815
+ expect(style.lineClamp).toBe('10');
816
+ expect(style.WebkitLineClamp).toBe('10');
817
+ expect(style.MozFlexGrow).toBe('10');
818
+ // jsdom is inconsistent in the style property name
819
+ // it uses on the client and when processing server markup.
820
+ // But it should be there either way.
821
+ expect(style.MsFlexGrow || style.msFlexGrow).toBe('10');
822
+ expect(style.MsGridRow || style.msGridRow).toBe('10');
823
+ expect(style.MsGridRowEnd || style.msGridRowEnd).toBe('10');
824
+ expect(style.MsGridRowSpan || style.msGridRowSpan).toBe('10');
825
+ expect(style.MsGridRowStart || style.msGridRowStart).toBe('10');
826
+ expect(style.MsGridColumn || style.msGridColumn).toBe('10');
827
+ expect(style.MsGridColumnEnd || style.msGridColumnEnd).toBe('10');
828
+ expect(style.MsGridColumnSpan || style.msGridColumnSpan).toBe('10');
829
+ expect(style.MsGridColumnStart || style.msGridColumnStart).toBe('10');
830
+ });
831
});
832
833
describe('aria attributes', function() {