Skip to content
This repository was archived by the owner on Mar 7, 2019. It is now read-only.

Commit a935f8a

Browse files
authored
Changed codestyle to standard 🔥 (#21)
1 parent 1255988 commit a935f8a

22 files changed

+466
-461
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Build Status](https://travis-ci.org/chrishelgert/react-handler.svg?branch=master)](https://travis-ci.org/chrishelgert/react-handler)
55
[![Build status](https://ci.appveyor.com/api/projects/status/c5qo9wa0n4uwakfj?svg=true)](https://ci.appveyor.com/project/chrishelgert/react-handler/branch/master)
66
[![codecov](https://codecov.io/gh/chrishelgert/react-handler/branch/master/graph/badge.svg)](https://codecov.io/gh/chrishelgert/react-handler)
7+
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
78

89
> A react-component for handling typical react/redux-states (loading, error, ...)
910

__tests__/__snapshots__/index.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`react-handler should contain the Handler-Component 1`] = `[Function]`;
3+
exports[`react-handler contains the Handler-Component 1`] = `[Function]`;
44

5-
exports[`react-handler should contain the SupHandler´s 1`] = `
5+
exports[`react-handler contains the the SupHandler´s 1`] = `
66
Object {
77
"EmptyHandler": [Function],
88
"ErrorEmptyHandler": [Function],
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import React, { PropTypes } from 'react';
2-
import renderer from 'react-test-renderer';
3-
import EmptyHandler from '../../src/components/EmptyHandler';
1+
import React, { PropTypes } from 'react'
2+
import renderer from 'react-test-renderer'
3+
import EmptyHandler from '../../src/components/EmptyHandler'
44

5-
const TestComponent = () => <h1>Test</h1>;
6-
const EmptyComponent = ({ children }) => <h2 className="empty">{children}</h2>;
7-
EmptyComponent.propTypes = { children: PropTypes.string };
8-
const componentPropsFilled = { list: ['abc', 'def'] };
9-
const componentPropsEmpty = { list: [] };
10-
const emptyMessage = 'no results found';
5+
const TestComponent = () => <h1>Test</h1>
6+
const EmptyComponent = ({ children }) => <h2 className='empty'>{children}</h2>
7+
EmptyComponent.propTypes = { children: PropTypes.string }
8+
const componentPropsFilled = { list: ['abc', 'def'] }
9+
const componentPropsEmpty = { list: [] }
10+
const emptyMessage = 'no results found'
1111

1212
describe('EmptyHandler', () => {
13-
it('should return null when called without Component and is not empty', () => {
13+
test('returns null when called without Component and is not empty', () => {
1414
const tree = renderer.create(
1515
<EmptyHandler
1616
checkedProperty={componentPropsFilled.list}
1717
message={emptyMessage}
1818
/>,
19-
);
20-
expect(tree).toMatchSnapshot();
21-
});
19+
)
20+
expect(tree).toMatchSnapshot()
21+
})
2222

23-
it('should return the component when the element in componentProps is not empty', () => {
23+
test('returns the component when the element in componentProps is not empty', () => {
2424
const tree = renderer.create(
2525
<EmptyHandler
2626
checkedProperty={componentPropsFilled.list}
2727
message={emptyMessage}
2828
>
2929
<TestComponent />
3030
</EmptyHandler>,
31-
);
32-
expect(tree.toJSON()).toMatchSnapshot();
33-
});
31+
)
32+
expect(tree.toJSON()).toMatchSnapshot()
33+
})
3434

35-
it('should return the EmptyComponent, when the list is empty and called with EmptyComponent', () => {
35+
test('returns the EmptyComponent, when the list is empty and called with EmptyComponent', () => {
3636
const tree = renderer.create(
3737
<EmptyHandler
3838
EmptyComponent={EmptyComponent}
@@ -41,26 +41,26 @@ describe('EmptyHandler', () => {
4141
>
4242
<TestComponent />
4343
</EmptyHandler>,
44-
);
45-
expect(tree.toJSON()).toMatchSnapshot();
46-
});
44+
)
45+
expect(tree.toJSON()).toMatchSnapshot()
46+
})
4747

48-
it('should return the EmptyMessage, when the list is empty', () => {
48+
test('returns the EmptyMessage, when the list is empty', () => {
4949
const tree = renderer.create(
5050
<EmptyHandler
5151
checkedProperty={componentPropsEmpty.list}
5252
message={emptyMessage}
5353
/>,
54-
);
55-
expect(tree.toJSON()).toMatchSnapshot();
56-
});
54+
)
55+
expect(tree.toJSON()).toMatchSnapshot()
56+
})
5757

58-
it('should return the EmptyMessage, when called without checkedProperty', () => {
58+
test('returns the EmptyMessage, when called without checkedProperty', () => {
5959
const tree = renderer.create(
6060
<EmptyHandler message={emptyMessage}>
6161
<TestComponent />
6262
</EmptyHandler>,
63-
);
64-
expect(tree.toJSON()).toMatchSnapshot();
65-
});
66-
});
63+
)
64+
expect(tree.toJSON()).toMatchSnapshot()
65+
})
66+
})
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import React from 'react';
2-
import renderer from 'react-test-renderer';
3-
import ErrorEmptyHandler from '../../src/components/ErrorEmptyHandler';
1+
import React from 'react'
2+
import renderer from 'react-test-renderer'
3+
import ErrorEmptyHandler from '../../src/components/ErrorEmptyHandler'
44

5-
const Component = () => <div>Test</div>;
6-
const checkedProperty = ['test'];
5+
const Component = () => <div>Test</div>
6+
const checkedProperty = ['test']
77

88
describe('ErrorEmptyHandler', () => {
9-
it('should display the error-message', () => {
9+
test('displays the error-message', () => {
1010
const tree = renderer.create(
11-
<ErrorEmptyHandler errorMessage="failed to load articles" emptyMessage="0 Articles found">
11+
<ErrorEmptyHandler errorMessage='failed to load articles' emptyMessage='0 Articles found'>
1212
<Component />
1313
</ErrorEmptyHandler>,
14-
);
14+
)
1515

16-
expect(tree.toJSON()).toMatchSnapshot();
17-
});
16+
expect(tree.toJSON()).toMatchSnapshot()
17+
})
1818

19-
it('should display the empty-message', () => {
19+
test('displays the empty-message', () => {
2020
const tree = renderer.create(
2121
<ErrorEmptyHandler
2222
checkedProperty={{}}
23-
emptyPropertyKey="articles"
24-
emptyMessage="0 Articles found"
23+
emptyPropertyKey='articles'
24+
emptyMessage='0 Articles found'
2525
>
2626
<Component />
2727
</ErrorEmptyHandler>,
28-
);
28+
)
2929

30-
expect(tree.toJSON()).toMatchSnapshot();
31-
});
30+
expect(tree.toJSON()).toMatchSnapshot()
31+
})
3232

33-
it('should display the Component', () => {
33+
test('displays the Component', () => {
3434
const tree = renderer.create(
35-
<ErrorEmptyHandler checkedProperty={checkedProperty} emptyMessage="0 Articles found">
35+
<ErrorEmptyHandler checkedProperty={checkedProperty} emptyMessage='0 Articles found'>
3636
<Component />
3737
</ErrorEmptyHandler>,
38-
);
38+
)
3939

40-
expect(tree.toJSON()).toMatchSnapshot();
41-
});
42-
});
40+
expect(tree.toJSON()).toMatchSnapshot()
41+
})
42+
})
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
import React, { PropTypes } from 'react';
2-
import renderer from 'react-test-renderer';
3-
import ErrorHandler from '../../src/components/ErrorHandler';
1+
import React, { PropTypes } from 'react'
2+
import renderer from 'react-test-renderer'
3+
import ErrorHandler from '../../src/components/ErrorHandler'
44

5-
const TestComponent = () => <h1>Test</h1>;
6-
const ErrorComponent = ({ children }) => <h2 className="error">{children}</h2>;
7-
ErrorComponent.propTypes = { children: PropTypes.string };
8-
const errorMessage = 'failed to call api';
5+
const TestComponent = () => <h1>Test</h1>
6+
const ErrorComponent = ({ children }) => <h2 className='error'>{children}</h2>
7+
ErrorComponent.propTypes = { children: PropTypes.string }
8+
const errorMessage = 'failed to call api'
99

1010
describe('ErrorHandler', () => {
11-
it('should return the component when called without errorMessage', () => {
11+
test('returns the component when called without errorMessage', () => {
1212
const tree = renderer.create(
1313
<ErrorHandler>
1414
<TestComponent />
1515
</ErrorHandler>,
16-
);
17-
expect(tree.toJSON()).toMatchSnapshot();
18-
});
16+
)
17+
expect(tree.toJSON()).toMatchSnapshot()
18+
})
1919

20-
it('should return null when called without errorMessage and component', () => {
21-
const tree = renderer.create(<ErrorHandler />);
22-
expect(tree).toMatchSnapshot();
23-
});
20+
test('returns null when called without errorMessage and component', () => {
21+
const tree = renderer.create(<ErrorHandler />)
22+
expect(tree).toMatchSnapshot()
23+
})
2424

25-
it('should return the ErrorComponent', () => {
25+
test('returns the ErrorComponent', () => {
2626
const tree = renderer.create(
2727
<ErrorHandler
2828
ErrorComponent={ErrorComponent}
2929
message={errorMessage}
3030
>
3131
<TestComponent />
3232
</ErrorHandler>,
33-
);
34-
expect(tree.toJSON()).toMatchSnapshot();
35-
});
33+
)
34+
expect(tree.toJSON()).toMatchSnapshot()
35+
})
3636

37-
it('should return the ErrorMessage when called without ErrorComponent', () => {
37+
test('returns the ErrorMessage when called without ErrorComponent', () => {
3838
const tree = renderer.create(
3939
<ErrorHandler message={errorMessage}>
4040
<TestComponent />
4141
</ErrorHandler>,
42-
);
43-
expect(tree.toJSON()).toMatchSnapshot();
44-
});
45-
});
42+
)
43+
expect(tree.toJSON()).toMatchSnapshot()
44+
})
45+
})
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
import React from 'react';
2-
import renderer from 'react-test-renderer';
3-
import Handler from '../../src/components/Handler';
1+
import React from 'react'
2+
import renderer from 'react-test-renderer'
3+
import Handler from '../../src/components/Handler'
44

5-
const Component = () => <div>Test</div>;
6-
const checkedProperty = ['test'];
5+
const Component = () => <div>Test</div>
6+
const checkedProperty = ['test']
77

88
describe('Handler', () => {
9-
it('should return the loading-message and the component', () => {
9+
test('returns the loading-message and the component', () => {
1010
const tree = renderer.create(
11-
<Handler checkedProperty={checkedProperty} emptyMessage="0 Articles found">
11+
<Handler checkedProperty={checkedProperty} emptyMessage='0 Articles found'>
1212
<Component />
1313
</Handler>,
14-
);
14+
)
1515

16-
expect(tree.toJSON()).toMatchSnapshot();
17-
});
16+
expect(tree.toJSON()).toMatchSnapshot()
17+
})
1818

19-
it('should only return the loading-message, wen showComponentWhileLoading is false', () => {
19+
test('returns only the loading-message when showComponentWhileLoading is false', () => {
2020
const tree = renderer.create(
21-
<Handler showComponentWhileLoading={false} checkedProperty={checkedProperty} emptyMessage="0 Articles found">
21+
<Handler showComponentWhileLoading={false} checkedProperty={checkedProperty} emptyMessage='0 Articles found'>
2222
<Component />
2323
</Handler>,
24-
);
24+
)
2525

26-
expect(tree.toJSON()).toMatchSnapshot();
27-
});
26+
expect(tree.toJSON()).toMatchSnapshot()
27+
})
2828

29-
it('should only return the Component, when loading and showComponentWhileLoading is false', () => {
29+
test('returns the Component when loading and showComponentWhileLoading is false', () => {
3030
const tree = renderer.create(
3131
<Handler
3232
showComponentWhileLoading={false}
3333
loading={false}
3434
checkedProperty={checkedProperty}
35-
emptyMessage="0 Articles found"
35+
emptyMessage='0 Articles found'
3636
>
3737
<Component />
3838
</Handler>,
39-
);
39+
)
4040

41-
expect(tree.toJSON()).toMatchSnapshot();
42-
});
43-
});
41+
expect(tree.toJSON()).toMatchSnapshot()
42+
})
43+
})
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
import React from 'react';
2-
import renderer from 'react-test-renderer';
3-
import LoadingHandler from '../../src/components/LoadingHandler';
1+
import React from 'react'
2+
import renderer from 'react-test-renderer'
3+
import LoadingHandler from '../../src/components/LoadingHandler'
44

5-
const TestComponent = () => <h1>Test</h1>;
6-
const LoadingComponent = () => <img src="/img/spinner.svg" alt="loading..." />;
5+
const TestComponent = () => <h1>Test</h1>
6+
const LoadingComponent = () => <img src='/img/spinner.svg' alt='loading...' />
77

88
describe('LoadingHandler', () => {
9-
it('should return the component when called with loading false', () => {
9+
test('returns the component when called with loading false', () => {
1010
const tree = renderer.create(
1111
<LoadingHandler loading={false}>
1212
<TestComponent />
1313
</LoadingHandler>,
14-
);
15-
expect(tree.toJSON()).toMatchSnapshot();
16-
});
14+
)
15+
expect(tree.toJSON()).toMatchSnapshot()
16+
})
1717

18-
it('should return null when called with loading false and no component', () => {
18+
test('returns null when called with loading false and no component', () => {
1919
const tree = renderer.create(
2020
<LoadingHandler loading={false} />,
21-
);
22-
expect(tree).toMatchSnapshot();
23-
});
21+
)
22+
expect(tree).toMatchSnapshot()
23+
})
2424

25-
it('should return the LoadingComponent', () => {
25+
test('returns the LoadingComponent', () => {
2626
const tree = renderer.create(
2727
<LoadingHandler LoadingComponent={LoadingComponent}>
2828
<TestComponent />
2929
</LoadingHandler>,
30-
);
31-
expect(tree.toJSON()).toMatchSnapshot();
32-
});
30+
)
31+
expect(tree.toJSON()).toMatchSnapshot()
32+
})
3333

34-
it('should return the LoadingMessage with given loading message', () => {
34+
test('returns the LoadingMessage with given loading message', () => {
3535
const tree = renderer.create(
36-
<LoadingHandler message="keep keep loading">
36+
<LoadingHandler message='keep keep loading'>
3737
<TestComponent />
3838
</LoadingHandler>,
39-
);
40-
expect(tree.toJSON()).toMatchSnapshot();
41-
});
39+
)
40+
expect(tree.toJSON()).toMatchSnapshot()
41+
})
4242

43-
it('should return the LoadingMessage when called without LoadingComponent', () => {
43+
test('returns the LoadingMessage when called without LoadingComponent', () => {
4444
const tree = renderer.create(
4545
<LoadingHandler>
4646
<TestComponent />
4747
</LoadingHandler>,
48-
);
49-
expect(tree.toJSON()).toMatchSnapshot();
50-
});
51-
});
48+
)
49+
expect(tree.toJSON()).toMatchSnapshot()
50+
})
51+
})

0 commit comments

Comments
 (0)