Skip to content

Commit 074ca10

Browse files
ESlint tests template
1 parent 43551b3 commit 074ca10

File tree

1 file changed

+97
-97
lines changed

1 file changed

+97
-97
lines changed

tests/README.md

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Pull requests should conform to our [ESLint style definitions](https://github.co
3939

4040
Here is a well-commented sample test file which you can copy/paste into a new file to get started:
4141
```
42-
/* Adds all of the Mocha (eg `it` and `should`) and sinon testing global
42+
/* Adds all of the Mocha (eg `it` and `should`) and sinon testing global
4343
* variables to the global namespace for eslint purposes.
4444
*/
4545
/* eslint-env mocha */
@@ -78,110 +78,110 @@ chai.use(chaiEnzyme());
7878
* you will create in the React Storybook for manual testing.
7979
*/
8080
const DemoComponent = React.createClass({
81-
displayName: 'DemoComponent',
82-
propTypes: {},
83-
84-
getDefaultProps () {
85-
return {};
86-
},
87-
88-
getInitialState () {
89-
return {};
90-
},
91-
92-
// event handlers
93-
94-
render () {
95-
return (
96-
// JSX
97-
);
98-
}
81+
displayName: 'DemoComponent',
82+
propTypes: {
83+
sampleProp: PropTypes.string
84+
},
85+
86+
getDefaultProps () {
87+
return {};
88+
},
89+
90+
getInitialState () {
91+
return {};
92+
},
93+
94+
// event handlers
95+
96+
render () {
97+
return (
98+
// JSX
99+
<Tree />
100+
);
101+
}
99102
});
100103
101-
/* All tests for component being tested should be wrapped in a root `describe`,
104+
/* All tests for component being tested should be wrapped in a root `describe`,
102105
* which should be named after the component being tested.
103-
* When read aloud, the cumulative `describe` and `it` names should form a coherent
104-
* sentence, eg "Date Picker default structure and css is present with expected
105-
* attributes set". If you are having trouble constructing a cumulative short
106+
* When read aloud, the cumulative `describe` and `it` names should form a coherent
107+
* sentence, eg "Date Picker default structure and css is present with expected
108+
* attributes set". If you are having trouble constructing a cumulative short
106109
* sentence, this may be an indicator that your test is poorly structured.
107110
* String provided as first parameter names the `describe` section. Limit to nouns
108111
* as much as possible/appropriate.`
109112
*/
110113
describe('Component Name here', () => {
111-
112-
/* Below you will find some examples of minimum areas to be tested.
113-
* This should not be considered an exhaustive list. Please ensure
114-
* thorough testing of your code.
115-
*/
116-
117-
// BASIC STRUCTURE
118-
119-
describe('default structure and css', () => {
120-
// Test DOM with minimal props set
121-
122-
// String provided as first parameter names the `it` section.
123-
// Use short declarative sentences (sentence with "it").
124-
it('is present with expected attributes set', () => {});
125-
});
126-
127-
describe('assistive technology', () => {
128-
/* Detect if presence of accessibility features such as ARIA
129-
* roles and screen reader text is present in the DOM.
130-
* If your component has an ARIA role in application, and
131-
* does not use `tab-index`, test that the correct keyboard
132-
* navigation is present.
133-
*/
134-
});
135-
136-
137-
// PROPS AND CHILDREN
138-
139-
describe('Optional Props', () => {
140-
// What should be present in the DOM when style and className are applied?
141-
});
142-
143-
describe('Optional Children', () => {
144-
// What should be present when children are added?
145-
});
146-
147-
148-
// DATA PROPS
149-
150-
describe('Data', () => {
151-
/* Use exports from a corresponding `utilities/sample-data/[COMPONENT-NAME]`
152-
* file to provide data to your Storybook Stories and tests in JSON format.
153-
*/
154-
});
155-
156-
157-
// EVENTS
158-
159-
describe('Mouse and keyboard interactions', () => {
160-
/* Test event callback functions using Simulate. For more information, view
161-
* https://github.com/airbnb/enzyme/blob/master/docs/api/ReactWrapper/simulate.md
162-
*/
163-
164-
describe('onClick', () => {
165-
const itemClicked = sinon.spy();
166-
167-
beforeEach(mountComponent(
168-
<DemoComponent itemClicked={itemClicked} />
169-
));
170-
171-
afterEach(unmountComponent);
172-
173-
/* Please notice the of `function () {}` and not () => {}.
174-
* It allows access to the Mocha test context via `this`.
175-
*/
176-
it('calls event handler', function () {
177-
const item = this.wrapper.find('#example-tree-1').find('.slds-tree__item');
178-
// If applicable, use second parameter to pass the data object
179-
item.simulate('click', {});
180-
expect(itemClicked.callCount).to.equal(1);
181-
// If applicable, also test data object for correct contents.
182-
});
183-
});
184-
114+
/* Below you will find some examples of minimum areas to be tested.
115+
* This should not be considered an exhaustive list. Please ensure
116+
* thorough testing of your code.
117+
*/
118+
119+
// BASIC STRUCTURE
120+
121+
describe('default structure and css', () => {
122+
// Test DOM with minimal props set
123+
124+
// String provided as first parameter names the `it` section.
125+
// Use short declarative sentences (sentence with "it").
126+
it('is present with expected attributes set', () => {});
127+
});
128+
129+
describe('assistive technology', () => {
130+
/* Detect if presence of accessibility features such as ARIA
131+
* roles and screen reader text is present in the DOM.
132+
* If your component has an ARIA role in application, and
133+
* does not use `tab-index`, test that the correct keyboard
134+
* navigation is present.
135+
*/
136+
});
137+
138+
// PROPS AND CHILDREN
139+
140+
describe('Optional Props', () => {
141+
// What should be present in the DOM when style and className are applied?
142+
});
143+
144+
describe('Optional Children', () => {
145+
// What should be present when children are added?
146+
});
147+
148+
// DATA PROPS
149+
150+
describe('Data', () => {
151+
/* Use exports from a corresponding `utilities/sample-data/[COMPONENT-NAME]`
152+
* file to provide data to your Storybook Stories and tests in JSON format.
153+
*/
154+
});
155+
156+
157+
// EVENTS
158+
159+
describe('Mouse and keyboard interactions', () => {
160+
/* Test event callback functions using Simulate. For more information, view
161+
* https://github.com/airbnb/enzyme/blob/master/docs/api/ReactWrapper/simulate.md
162+
*/
163+
164+
describe('onClick', () => {
165+
const itemClicked = sinon.spy();
166+
167+
beforeEach(mountComponent(
168+
<DemoComponent itemClicked={itemClicked} />
169+
));
170+
171+
afterEach(unmountComponent);
172+
173+
/* Please notice the of `function () {}` and not () => {}.
174+
* It allows access to the Mocha test context via `this`.
175+
*/
176+
it('calls event handler', function () {
177+
const item = this.wrapper.find('#example-tree-1').find('.slds-tree__item');
178+
// If applicable, use second parameter to pass the data object
179+
item.simulate('click', {});
180+
expect(itemClicked.callCount).to.equal(1);
181+
// If applicable, also test data object for correct contents.
182+
});
185183
});
184+
});
186185
});
186+
187187
```

0 commit comments

Comments
 (0)