Skip to content

Commit fb8b76b

Browse files
committed
Update package files and code clean up
Update development dependencies Clean up whitespace in all files to use spaces instead of tabs Clean up README files examples Remove strict check on node engine and npm version
1 parent 2ccafb3 commit fb8b76b

File tree

16 files changed

+6314
-1954
lines changed

16 files changed

+6314
-1954
lines changed

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,37 +31,37 @@ import { render } from 'react-dom';
3131
import Tags from 'react-tagging-input';
3232

3333
class Application extends Component{
34-
state = {
35-
tags: ['foo', 'bar']
36-
};
37-
38-
constructor(props){
39-
super(props);
40-
}
41-
42-
onTagAdded(tag) {
43-
this.setState({
44-
tags: [...this.state.tags, tag]
45-
});
46-
}
47-
48-
onTagRemoved(tag, index) {
49-
this.setState({
50-
tags: this.state.tags.filter((tag, i) => i !== index)
51-
});
52-
}
53-
54-
render(){
55-
return (
56-
<div>
57-
<Tags
58-
tags={this.state.tags}
59-
placeholder="Add a tag"
60-
onAdded={this.onTagAdded.bind(this)}
61-
onRemoved={this.onTagRemoved.bind(this)} />
62-
</div>
63-
);
64-
}
34+
state = {
35+
tags: ['foo', 'bar']
36+
};
37+
38+
constructor(props){
39+
super(props);
40+
}
41+
42+
onTagAdded(tag) {
43+
this.setState({
44+
tags: [...this.state.tags, tag]
45+
});
46+
}
47+
48+
onTagRemoved(tag, index) {
49+
this.setState({
50+
tags: this.state.tags.filter((tag, i) => i !== index)
51+
});
52+
}
53+
54+
render(){
55+
return (
56+
<div>
57+
<Tags
58+
tags={this.state.tags}
59+
placeholder="Add a tag"
60+
onAdded={this.onTagAdded.bind(this)}
61+
onRemoved={this.onTagRemoved.bind(this)} />
62+
</div>
63+
);
64+
}
6565
}
6666

6767
render(<Application />, document.getElementById('application'));
@@ -112,7 +112,7 @@ An `array` of keyCodes used to tell the tags component which delimiter to use to
112112
A `function` fired when a new tag is added - returns a `string` of the new tag
113113
```js
114114
onTagAdded(tag){
115-
console.log(`new tag: ${tags}`);
115+
console.log(`new tag: ${tags}`);
116116
}
117117

118118
<Tags onAdded={this.onTagAdded} />
@@ -123,7 +123,7 @@ onTagAdded(tag){
123123
A `function` fired when a new tag is deleted - returns a `string` of the tag that was deleted
124124
```js
125125
onTagRemoved(tag, index){
126-
console.log(`deleted tag: ${tag} at index ${index}`);
126+
console.log(`deleted tag: ${tag} at index ${index}`);
127127
}
128128

129129
<Tags onRemoved={this.onTagRemoved.bind(this)} />
@@ -148,9 +148,9 @@ A `boolean` that sets the tag component to read only mode. No adding or removing
148148
The `element` to be used for the delete icon
149149
```js
150150
const removeIcon = () => {
151-
return (
152-
<i class="my-custom-icon"></i>
153-
);
151+
return (
152+
<i class="my-custom-icon"></i>
153+
);
154154
}
155155

156156
<Tags removeTagsIcon={removeIcon()} />

__tests__/Tag-test.js

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -7,93 +7,93 @@ import Tag from '../src/component/js/Tag';
77
const TAG_NAME = 'foo';
88

99
describe('Tag', () => {
10-
it('should render', () => {
11-
const component = renderer.create(
12-
<Tag
13-
name={TAG_NAME} />
14-
).toJSON();
15-
16-
expect(component).toMatchSnapshot();
17-
});
10+
it('should render', () => {
11+
const component = renderer.create(
12+
<Tag
13+
name={TAG_NAME} />
14+
).toJSON();
15+
16+
expect(component).toMatchSnapshot();
17+
});
1818
});
1919

2020
describe('Tag - "readOnly"', () => {
21-
describe('when false', () => {
22-
it('should render the removeTagIcon', () => {
23-
const component = shallow(
24-
<Tag
25-
name={TAG_NAME}
26-
readOnly={false} />
27-
);
28-
29-
expect(component.find('a')).toHaveLength(1);
30-
expect(component.find('a').text()).toEqual(String.fromCharCode(215));
31-
32-
expect(toJson(component)).toMatchSnapshot();
33-
});
34-
});
35-
36-
describe('when true', () => {
37-
it('should not render the removeTagIcon', () => {
38-
const component = shallow(
39-
<Tag
40-
name={TAG_NAME}
41-
readOnly={true} />
42-
);
43-
44-
expect(component.find('a')).toHaveLength(0);
45-
46-
expect(toJson(component)).toMatchSnapshot();
47-
});
48-
});
21+
describe('when false', () => {
22+
it('should render the removeTagIcon', () => {
23+
const component = shallow(
24+
<Tag
25+
name={TAG_NAME}
26+
readOnly={false} />
27+
);
28+
29+
expect(component.find('a')).toHaveLength(1);
30+
expect(component.find('a').text()).toEqual(String.fromCharCode(215));
31+
32+
expect(toJson(component)).toMatchSnapshot();
33+
});
34+
});
35+
36+
describe('when true', () => {
37+
it('should not render the removeTagIcon', () => {
38+
const component = shallow(
39+
<Tag
40+
name={TAG_NAME}
41+
readOnly={true} />
42+
);
43+
44+
expect(component.find('a')).toHaveLength(0);
45+
46+
expect(toJson(component)).toMatchSnapshot();
47+
});
48+
});
4949
});
5050

5151
describe('Tag - "removeTagIcon"', () => {
52-
describe('when a custom element is passed in', () => {
53-
it('should render the element', () => {
54-
const customRemoveIcon = (
55-
<i className="icon-remove"></i>
56-
);
57-
58-
const component = renderer.create(
59-
<Tag
60-
name={TAG_NAME}
61-
removeTagIcon={customRemoveIcon} />
62-
).toJSON();
63-
64-
expect(component).toMatchSnapshot();
65-
});
66-
});
67-
68-
describe('when a custom string is passed in', () => {
69-
it('should render the string', () => {
70-
const customRemoveString = 'remove';
71-
72-
const component = renderer.create(
73-
<Tag
74-
name={TAG_NAME}
75-
removeTagIcon={customRemoveString} />
76-
).toJSON();
77-
78-
expect(component).toMatchSnapshot();
79-
});
80-
});
52+
describe('when a custom element is passed in', () => {
53+
it('should render the element', () => {
54+
const customRemoveIcon = (
55+
<i className="icon-remove"></i>
56+
);
57+
58+
const component = renderer.create(
59+
<Tag
60+
name={TAG_NAME}
61+
removeTagIcon={customRemoveIcon} />
62+
).toJSON();
63+
64+
expect(component).toMatchSnapshot();
65+
});
66+
});
67+
68+
describe('when a custom string is passed in', () => {
69+
it('should render the string', () => {
70+
const customRemoveString = 'remove';
71+
72+
const component = renderer.create(
73+
<Tag
74+
name={TAG_NAME}
75+
removeTagIcon={customRemoveString} />
76+
).toJSON();
77+
78+
expect(component).toMatchSnapshot();
79+
});
80+
});
8181
});
8282

8383
describe('Tag - "onRemoveTag"', () => {
84-
it('should be called when clicking the remove icon', () => {
85-
const onRemoveClick = jest.fn();
84+
it('should be called when clicking the remove icon', () => {
85+
const onRemoveClick = jest.fn();
8686

87-
const component = shallow(
88-
<Tag
89-
name={TAG_NAME}
90-
onRemoveTag={onRemoveClick} />
91-
);
87+
const component = shallow(
88+
<Tag
89+
name={TAG_NAME}
90+
onRemoveTag={onRemoveClick} />
91+
);
9292

93-
component.find('a').simulate('click', {
94-
preventDefault() {}
95-
});
93+
component.find('a').simulate('click', {
94+
preventDefault() {}
95+
});
9696

97-
expect(onRemoveClick).toBeCalled();
98-
});
97+
expect(onRemoveClick).toBeCalled();
98+
});
9999
});

0 commit comments

Comments
 (0)