@pie-lib/test-utils 0.2.33 → 0.3.0-beta.1
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.
- package/CHANGELOG.md +12 -24
- package/NEXT.CHANGELOG.json +1 -0
- package/package.json +2 -2
- package/src/__tests__/index.test.js +45 -0
- package/.travis.yml +0 -7
- package/README.md +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# [0.3.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.33...@pie-lib/test-utils@0.3.0-beta.1) (2025-07-20)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
# [0.3.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.33...@pie-lib/test-utils@0.3.0-beta.0) (2025-07-20)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
17
17
|
|
|
@@ -19,62 +19,50 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
# [0.4.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.33...@pie-lib/test-utils@0.4.0-beta.0) (2025-07-15)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
25
25
|
|
|
26
|
+
# [0.3.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.33...@pie-lib/test-utils@0.3.0-beta.0) (2025-07-15)
|
|
26
27
|
|
|
28
|
+
**Note:** Version bump only for package @pie-lib/test-utils
|
|
27
29
|
|
|
30
|
+
## [0.2.33](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.32...@pie-lib/test-utils@0.2.33) (2023-06-24)
|
|
28
31
|
|
|
32
|
+
**Note:** Version bump only for package @pie-lib/test-utils
|
|
29
33
|
|
|
30
|
-
## [0.2.
|
|
34
|
+
## [0.2.32](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.30...@pie-lib/test-utils@0.2.32) (2023-01-31)
|
|
31
35
|
|
|
32
36
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
33
37
|
|
|
38
|
+
## [0.2.30](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.29...@pie-lib/test-utils@0.2.30) (2023-01-31)
|
|
34
39
|
|
|
40
|
+
**Note:** Version bump only for package @pie-lib/test-utils
|
|
35
41
|
|
|
42
|
+
## [0.2.29](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.28...@pie-lib/test-utils@0.2.29) (2023-01-31)
|
|
36
43
|
|
|
44
|
+
**Note:** Version bump only for package @pie-lib/test-utils
|
|
37
45
|
|
|
38
46
|
## [0.2.28](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.27...@pie-lib/test-utils@0.2.28) (2023-01-31)
|
|
39
47
|
|
|
40
48
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
50
|
## [0.2.27](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.24...@pie-lib/test-utils@0.2.27) (2023-01-31)
|
|
47
51
|
|
|
48
52
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
54
|
## [0.2.24](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.22...@pie-lib/test-utils@0.2.24) (2023-01-31)
|
|
55
55
|
|
|
56
56
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
58
|
## [0.2.22](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.20...@pie-lib/test-utils@0.2.22) (2023-01-31)
|
|
63
59
|
|
|
64
60
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
62
|
## [0.2.20](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.19...@pie-lib/test-utils@0.2.20) (2022-11-23)
|
|
71
63
|
|
|
72
64
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
66
|
## [0.2.19](https://github.com/pie-framework/pie-lib/compare/@pie-lib/test-utils@0.2.17...@pie-lib/test-utils@0.2.19) (2021-06-25)
|
|
79
67
|
|
|
80
68
|
**Note:** Version bump only for package @pie-lib/test-utils
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/test-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"enzyme": "^3.8.0",
|
|
14
14
|
"react": "^16.8.1"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "e2aa3ddac60f49bcb8c2562370f496323642f453",
|
|
17
17
|
"scripts": {}
|
|
18
18
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shallowChild } from '../index';
|
|
3
|
+
import Enzyme from 'enzyme';
|
|
4
|
+
import Adapter from 'enzyme-adapter-react-16';
|
|
5
|
+
|
|
6
|
+
Enzyme.configure({ adapter: new Adapter() });
|
|
7
|
+
|
|
8
|
+
describe('test-utils', () => {
|
|
9
|
+
describe('shallowChild', () => {
|
|
10
|
+
function simpleHoC(WrappedComponent) {
|
|
11
|
+
return class extends React.Component {
|
|
12
|
+
render() {
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<WrappedComponent oneMoreProp="hello" {...this.props} />
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class SimpleComponent extends React.Component {
|
|
23
|
+
render() {
|
|
24
|
+
return <span>My simple component will get wrapped</span>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
it('moves past HoC and returns shallow rendered component using enzyme', () => {
|
|
29
|
+
const wrapper = shallowChild(simpleHoC(SimpleComponent), null, 1);
|
|
30
|
+
const shallowComponent = wrapper();
|
|
31
|
+
|
|
32
|
+
expect(shallowComponent.find(SimpleComponent).length).toEqual(1);
|
|
33
|
+
expect(shallowComponent.props().children.props.oneMoreProp).toEqual('hello');
|
|
34
|
+
expect(shallowComponent.html().includes('span')).toEqual(true);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('overwrites specific props when passed into the closure', () => {
|
|
38
|
+
const wrapper = shallowChild(simpleHoC(SimpleComponent), null, 1);
|
|
39
|
+
const shallowComponent = wrapper({ oneMoreProp: 'helloToo' });
|
|
40
|
+
|
|
41
|
+
expect(shallowComponent.find(SimpleComponent).length).toEqual(1);
|
|
42
|
+
expect(shallowComponent.props().children.props.oneMoreProp).toEqual('helloToo');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
package/.travis.yml
DELETED
package/README.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# test-utils
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`test-utils` is a small collection of tools and helper functions that facilitate testing for components of the PIE framework.
|
|
5
|
-
|
|
6
|
-
## Usage
|
|
7
|
-
|
|
8
|
-
### Install
|
|
9
|
-
|
|
10
|
-
npm install --save @pie-lib/test-utils
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
### Import
|
|
14
|
-
|
|
15
|
-
import { shallowChild } from '@pie-lib/test-utils';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Use it for testing HoC wrapped components
|
|
19
|
-
|
|
20
|
-
const wrapper = shallowChild(ComponentX, defaultProps, 1); // 1 being nest level, for instance Material-UI styles wrapper HoC
|
|
21
|
-
const componentWithSpecificProps = wrapper(specificProps);
|
|
22
|
-
|
|
23
|
-
expect(componentWithSpecificProps.find('div').length).toEqual(1);
|