Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit a587ff0

Browse files
author
Dom Harrington
committed
Prettier
1 parent 04f1e63 commit a587ff0

File tree

19 files changed

+170
-87
lines changed

19 files changed

+170
-87
lines changed

packages/api-explorer/__tests__/GlossaryItem.test.jsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,12 @@ const { GlossaryItem } = require('../src/GlossaryItem');
66
test('should output a glossary item if the term exists', () => {
77
const term = 'acme';
88
const definition = 'This is a definition';
9-
const glossaryItem = shallow(
10-
<GlossaryItem
11-
term={term}
12-
terms={[{ term, definition }]}
13-
/>,
14-
);
9+
const glossaryItem = shallow(<GlossaryItem term={term} terms={[{ term, definition }]} />);
1510

1611
expect(glossaryItem.find('.glossary-item.highlight').text()).toBe(term);
1712
expect(glossaryItem.find('.tooltip-content-body').text()).toBe(`- ${term} - ${definition}`);
1813
});
1914

2015
test('should output nothing if the term does not exist', () => {
21-
expect(shallow(
22-
<GlossaryItem
23-
term="something"
24-
terms={[]}
25-
/>,
26-
).html()).toBe(null);
16+
expect(shallow(<GlossaryItem term="something" terms={[]} />).html()).toBe(null);
2717
});

packages/api-explorer/__tests__/Variable.test.jsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ describe('single variable', () => {
1717
});
1818

1919
test('should render default if value not set', () => {
20-
const variable = shallow(<Variable {...props} user={{}} defaults={[ { name: 'apiKey', default: 'default' }]} />);
20+
const variable = shallow(
21+
<Variable {...props} user={{}} defaults={[{ name: 'apiKey', default: 'default' }]} />,
22+
);
2123

2224
expect(variable.text()).toBe('default');
2325
});
@@ -29,7 +31,9 @@ describe('single variable', () => {
2931
});
3032

3133
test('should render auth dropdown if default and oauth enabled', () => {
32-
const variable = shallow(<Variable {...props} user={{}} defaults={[ { name: 'apiKey', default: 'default' }]} oauth />);
34+
const variable = shallow(
35+
<Variable {...props} user={{}} defaults={[{ name: 'apiKey', default: 'default' }]} oauth />,
36+
);
3337
variable.find('.variable-underline').simulate('click');
3438

3539
expect(variable.find('#loginDropdown').length).toBe(1);
@@ -80,14 +84,30 @@ describe('multiple variables', () => {
8084
const variable = shallow(
8185
<Variable
8286
{...props}
83-
user={{ keys: [{ name: 'project1', apiKey: '123' }, { name: 'project2', apiKey: '456' }, { name: 'project3'}]}}
87+
user={{
88+
keys: [
89+
{ name: 'project1', apiKey: '123' },
90+
{ name: 'project2', apiKey: '456' },
91+
{ name: 'project3' },
92+
],
93+
}}
8494
selected="project1"
8595
changeSelected={changeSelected}
8696
/>,
8797
);
8898

8999
variable.find('.variable-underline').simulate('click');
90-
variable.find('ul li').at(1).simulate('click', { target: { innerText: variable.find('ul li').at(1).text() } });
100+
variable
101+
.find('ul li')
102+
.at(1)
103+
.simulate('click', {
104+
target: {
105+
innerText: variable
106+
.find('ul li')
107+
.at(1)
108+
.text(),
109+
},
110+
});
91111
});
92112

93113
test('should render auth dropdown if default and oauth enabled');

packages/api-explorer/__tests__/lib/markdown.test.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,64 +19,86 @@ test('should strip out inputs', () => {
1919
});
2020

2121
test('tables', () => {
22-
expect(shallow(markdown(`
22+
expect(
23+
shallow(
24+
markdown(`
2325
| Tables | Are | Cool |
2426
| ------------- |:-------------:| -----:|
2527
| col 3 is | right-aligned | $1600 |
2628
| col 2 is | centered | $12 |
2729
| zebra stripes | are neat | $1 |
28-
`)).html()).toMatchSnapshot();
30+
`),
31+
).html(),
32+
).toMatchSnapshot();
2933
});
3034

3135
test('headings', () => {
32-
expect(shallow(markdown(`
36+
expect(
37+
shallow(
38+
markdown(`
3339
# h1
3440
## h2
3541
### h3
3642
#### h4
3743
##### h5
3844
###### h6
3945
# heading with some more CONTENT
40-
`)).html()).toMatchSnapshot();
46+
`),
47+
).html(),
48+
).toMatchSnapshot();
4149
});
4250

4351
test('anchors', () => {
44-
expect(shallow(markdown(`
52+
expect(
53+
shallow(
54+
markdown(`
4555
[link](http://example.com)
4656
[xss](javascript:alert)
4757
[doc](doc:slug)
4858
[ref](ref:slug)
4959
[blog](blog:slug)
5060
[page](page:slug)
51-
`)).html()).toMatchSnapshot();
61+
`),
62+
).html(),
63+
).toMatchSnapshot();
5264
});
5365

5466
test('emojis', () => {
55-
expect(shallow(markdown(`
67+
expect(
68+
shallow(
69+
markdown(`
5670
:joy:
5771
:fa-lock:
5872
:unknown-emoji:
59-
`)).html()).toMatchSnapshot();
73+
`),
74+
).html(),
75+
).toMatchSnapshot();
6076
});
6177

6278
test('code samples', () => {
63-
expect(shallow(markdown(`
79+
expect(
80+
shallow(
81+
markdown(`
6482
\`\`\`javascript
6583
var a = 1;
6684
\`\`\`
6785
6886
\`\`\`
6987
code-without-language
7088
\`\`\`
71-
`)).html()).toMatchSnapshot();
72-
})
89+
`),
90+
).html(),
91+
).toMatchSnapshot();
92+
});
7393

7494
test('should render nothing if nothing passed in', () => {
7595
expect(markdown('')).toBe(null);
7696
});
7797

7898
test('`correctnewlines` option', () => {
79-
expect(shallow(markdown('test\ntest\ntest', { correctnewlines: true })).html()).toBe('<p>test\ntest\ntest</p>');
99+
expect(shallow(markdown('test\ntest\ntest', { correctnewlines: true })).html()).toBe(
100+
'<p>test\ntest\ntest</p>',
101+
);
80102
expect(shallow(markdown('test\ntest\ntest', { correctnewlines: false })).html()).toBe(
81103
'<p>test<br/>\ntest<br/>\ntest</p>',
82104
);

packages/api-explorer/__tests__/lib/markdown/gemoji-parser.test.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ it('should output an image node for a known emoji', () => {
3131
],
3232
};
3333

34-
expect(remark().use(parser).data('settings', { position: false }).parse(markdown)).toEqual(ast);
34+
expect(
35+
remark()
36+
.use(parser)
37+
.data('settings', { position: false })
38+
.parse(markdown),
39+
).toEqual(ast);
3540
});
3641

3742
it('should output an <i> for a font awesome icon', () => {
@@ -59,7 +64,12 @@ it('should output an <i> for a font awesome icon', () => {
5964
],
6065
};
6166

62-
expect(remark().use(parser).data('settings', { position: false }).parse(markdown)).toEqual(ast);
67+
expect(
68+
remark()
69+
.use(parser)
70+
.data('settings', { position: false })
71+
.parse(markdown),
72+
).toEqual(ast);
6373
});
6474

6575
it('should output nothing for unknown emojis', () => {
@@ -70,12 +80,15 @@ it('should output nothing for unknown emojis', () => {
7080
children: [
7181
{
7282
type: 'paragraph',
73-
children: [
74-
{ type: 'text', value: markdown },
75-
],
83+
children: [{ type: 'text', value: markdown }],
7684
},
7785
],
7886
};
7987

80-
expect(remark().use(parser).data('settings', { position: false }).parse(markdown)).toEqual(ast);
88+
expect(
89+
remark()
90+
.use(parser)
91+
.data('settings', { position: false })
92+
.parse(markdown),
93+
).toEqual(ast);
8194
});

packages/api-explorer/__tests__/lib/markdown/variable-parser.test.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ it('should output a variable node', () => {
2525
],
2626
};
2727

28-
expect(remark().use(parser).data('settings', { position: false }).parse(markdown)).toEqual(ast);
28+
expect(
29+
remark()
30+
.use(parser)
31+
.data('settings', { position: false })
32+
.parse(markdown),
33+
).toEqual(ast);
2934
});
3035

3136
it('should output a glossary node', () => {
@@ -52,7 +57,12 @@ it('should output a glossary node', () => {
5257
],
5358
};
5459

55-
expect(remark().use(parser).data('settings', { position: false }).parse(markdown)).toEqual(ast);
60+
expect(
61+
remark()
62+
.use(parser)
63+
.data('settings', { position: false })
64+
.parse(markdown),
65+
).toEqual(ast);
5666
});
5767

5868
it('should allow whitespace in glossary names', () => {
@@ -79,7 +89,12 @@ it('should allow whitespace in glossary names', () => {
7989
],
8090
};
8191

82-
expect(remark().use(parser).data('settings', { position: false }).parse(markdown)).toEqual(ast);
92+
expect(
93+
remark()
94+
.use(parser)
95+
.data('settings', { position: false })
96+
.parse(markdown),
97+
).toEqual(ast);
8398
});
8499

85100
it('should allow escape variables to remain', () => {
@@ -98,5 +113,10 @@ it('should allow escape variables to remain', () => {
98113
],
99114
};
100115

101-
expect(remark().use(parser).data('settings', { position: false }).parse(markdown)).toEqual(ast);
116+
expect(
117+
remark()
118+
.use(parser)
119+
.data('settings', { position: false })
120+
.parse(markdown),
121+
).toEqual(ast);
102122
});

packages/api-explorer/src/GlossaryItem.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ function GlossaryItem({ term, terms }) {
2323

2424
GlossaryItem.propTypes = {
2525
term: PropTypes.string.isRequired,
26-
terms: PropTypes.arrayOf(PropTypes.shape({
27-
term: PropTypes.string.isRequired,
28-
definition: PropTypes.string.isRequired
29-
})).isRequired,
26+
terms: PropTypes.arrayOf(
27+
PropTypes.shape({
28+
term: PropTypes.string.isRequired,
29+
definition: PropTypes.string.isRequired,
30+
}),
31+
).isRequired,
3032
};
3133

32-
module.exports = (props) => (
34+
module.exports = props => (
3335
<GlossaryTermsContext.Consumer>
34-
{(terms) => <GlossaryItem {...props} terms={terms} />}
36+
{terms => <GlossaryItem {...props} terms={terms} />}
3537
</GlossaryTermsContext.Consumer>
3638
);
3739

packages/api-explorer/src/Variable.jsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Variable extends React.Component {
7878
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
7979
<li
8080
className={classNames({ active: this.props.selected === key.name })}
81-
onClick={(event) => this.props.changeSelected(event.target.innerText)}
81+
onClick={event => this.props.changeSelected(event.target.innerText)}
8282
key={key.name}
8383
>
8484
{key.name}
@@ -138,14 +138,21 @@ Variable.defaultProps = {
138138
oauth: false,
139139
};
140140

141-
module.exports = (props) => (
141+
module.exports = props => (
142142
<VariablesContext.Consumer>
143143
{({ user, defaults }) => (
144144
<OauthContext.Consumer>
145-
{(oauth) => (
145+
{oauth => (
146146
<SelectedAppContext.Consumer>
147-
{({selected, changeSelected}) => (
148-
<Variable {...props} user={user} defaults={defaults} oauth={oauth} selected={selected} changeSelected={changeSelected} />
147+
{({ selected, changeSelected }) => (
148+
<Variable
149+
{...props}
150+
user={user}
151+
defaults={defaults}
152+
oauth={oauth}
153+
selected={selected}
154+
changeSelected={changeSelected}
155+
/>
149156
)}
150157
</SelectedAppContext.Consumer>
151158
)}

packages/api-explorer/src/block-types/CallOut.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ const CallOut = ({ block, flags }) => {
3737
</span>
3838
)}
3939
{block.data &&
40-
block.data.body && (
41-
<div className="callout-body">{markdown(block.data.body, flags)}</div>
42-
)}
40+
block.data.body && <div className="callout-body">{markdown(block.data.body, flags)}</div>}
4341
</div>
4442
);
4543
};

packages/api-explorer/src/block-types/Image.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ const ImageBlock = ({ block, flags }) => {
2222
<img src={image.image[0]} alt={image.caption} />
2323
</a>
2424
</figure>
25-
{image.caption && (
26-
<figcaption>{markdown(image.caption, flags)}</figcaption>
27-
)}
25+
{image.caption && <figcaption>{markdown(image.caption, flags)}</figcaption>}
2826
</div>
2927
)}
3028
</div>

packages/api-explorer/src/block-types/Parameters.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ const Parameters = ({ block, flags }) => {
2323

2424
for (let c = 0; c < columns; c += 1) {
2525
tdCells.push(
26-
<div
27-
className="td"
28-
key={c}
29-
>{markdown(block.data.data[`${r}-${c}`] || '', flags)}</div>,
26+
<div className="td" key={c}>
27+
{markdown(block.data.data[`${r}-${c}`] || '', flags)}
28+
</div>,
3029
);
3130
}
3231
return tdCells;

packages/api-explorer/src/form-components/DescriptionField.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function DescriptionField(props) {
1212
}
1313
return (
1414
<div id={id} className="field-description">
15-
{typeof description === 'string'? markdown(description) : description}
15+
{typeof description === 'string' ? markdown(description) : description}
1616
</div>
1717
);
1818
}

0 commit comments

Comments
 (0)