Skip to content

Commit c57c746

Browse files
committed
version to test page
1 parent d51e060 commit c57c746

19 files changed

+736
-11
lines changed

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense para saber los atributos posibles.
3+
// Mantenga el puntero para ver las descripciones de los existentes atributos
4+
// Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"type": "chrome",
10+
"request": "launch",
11+
"name": "Lanzar Chrome contra localhost",
12+
"url": "http://localhost:8080",
13+
"webRoot": "${workspaceFolder}"
14+
}
15+
]
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`common/components/form/button specs should render as expected when passing required properties 1`] = `
4+
<button
5+
className="test className"
6+
onClick={[Function]}
7+
type="button"
8+
>
9+
test label
10+
</button>
11+
`;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`/common/components specs should render as expected when passing required and optional properties 1`] = `
4+
<div
5+
className="form-group has-error"
6+
>
7+
<label
8+
htmlFor="test name"
9+
>
10+
test label
11+
</label>
12+
<div
13+
className="field"
14+
>
15+
<input
16+
className="form-control"
17+
name="test name"
18+
onChange={[Function]}
19+
type="text"
20+
value="test value"
21+
/>
22+
</div>
23+
<div
24+
className="help-block"
25+
>
26+
test error
27+
</div>
28+
</div>
29+
`;
30+
31+
exports[`/common/components specs should render as expected when passing required properties 1`] = `
32+
<div
33+
className="form-group"
34+
>
35+
<label
36+
htmlFor="test name"
37+
>
38+
test label
39+
</label>
40+
<div
41+
className="field"
42+
>
43+
<input
44+
className="form-control"
45+
name="test name"
46+
onChange={[Function]}
47+
type="text"
48+
value="test value"
49+
/>
50+
</div>
51+
<div
52+
className="help-block"
53+
/>
54+
</div>
55+
`;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import * as React from 'react';
2+
import { shallow } from 'enzyme';
3+
import { Button } from './button';
4+
5+
describe('common/components/form/button specs', () => {
6+
it('should render as expected when passing required properties', () => {
7+
// Arrange
8+
const props = {
9+
label: 'test label',
10+
className:'test className',
11+
onClick: () => { },
12+
};
13+
14+
// Act
15+
const component = shallow(
16+
<Button
17+
{...props}
18+
/>,
19+
);
20+
21+
// Assert
22+
expect(component).toMatchSnapshot();
23+
});
24+
25+
it('should call onClick prop when simulate button click', () => {
26+
// Arrange
27+
const props = {
28+
label: 'test label',
29+
onClick: jest.fn(),
30+
className: 'test className',
31+
};
32+
33+
// Act
34+
const component = shallow(
35+
<Button
36+
{...props}
37+
/>,
38+
);
39+
component.simulate('click');
40+
41+
// Assert
42+
expect(props.onClick).toHaveBeenCalled();
43+
});
44+
45+
});
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import * as React from 'react';
2+
import { shallow } from 'enzyme';
3+
import { Input } from '.';
4+
5+
6+
describe('/common/components specs',()=>{
7+
8+
it('should render as expected when passing required properties', () => {
9+
// Arrange
10+
const props = {
11+
name: 'test name',
12+
label: 'test label',
13+
value: 'test value',
14+
onChange: () => { },
15+
};
16+
17+
// Act
18+
const component = shallow(
19+
<Input
20+
{...props}
21+
/>,
22+
);
23+
24+
// Assert
25+
expect(component).toMatchSnapshot();
26+
});
27+
it('should render as expected when passing required and optional properties', () => {
28+
// Arrange
29+
const props = {
30+
name: 'test name',
31+
label: 'test label',
32+
value: 'test value',
33+
onChange: () => { },
34+
onBlur: () => { },
35+
error: 'test error',
36+
type: 'test type',
37+
};
38+
39+
// Act
40+
const component = shallow(
41+
<Input
42+
{...props}
43+
/>,
44+
);
45+
46+
// Assert
47+
expect(component).toMatchSnapshot();
48+
});
49+
it('should call to onChange prop when simulate input onChange', () => {
50+
// Arrange
51+
const props = {
52+
name: 'test name',
53+
label: 'test label',
54+
value: 'test value',
55+
onChange: jest.fn(),
56+
onBlur: () => { },
57+
error: 'test error',
58+
type: 'test type',
59+
};
60+
61+
// Act
62+
const component = shallow(
63+
<Input
64+
{...props}
65+
/>,
66+
);
67+
68+
component.find('input').simulate('change', {
69+
target: {
70+
name: 'test name',
71+
value: 'updated value',
72+
},
73+
});
74+
75+
// Assert
76+
expect(props.onChange).toHaveBeenCalledWith('test name', 'updated value');
77+
});
78+
79+
});

0 commit comments

Comments
 (0)