Fixed prettier issue (#15471)

Fixed prettier CI issue that caused build failures
This commit is contained in:
Torkel Ödegaard 2019-02-16 15:45:19 +01:00 committed by GitHub
parent 1adc1a6097
commit 2d5fd7fdfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 16 deletions

View File

@ -121,7 +121,7 @@
"jest": "jest --notify --watch",
"api-tests": "jest --notify --watch --config=tests/api/jest.js",
"storybook": "cd packages/grafana-ui && yarn storybook",
"prettier:check": "prettier -- --list-different \"**/*.{ts,tsx,scss}\""
"prettier:check": "prettier --list-different \"**/*.{ts,tsx,scss}\""
},
"husky": {
"hooks": {

View File

@ -16,9 +16,21 @@ describe('<LogMessageAnsi />', () => {
const wrapper = shallow(<LogMessageAnsi value={value} />);
expect(wrapper.find('span')).toHaveLength(1);
expect(wrapper.find('span').first().prop('style')).toMatchObject(expect.objectContaining({
color: expect.any(String)
}));
expect(wrapper.find('span').first().text()).toBe('ipsum');
expect(
wrapper
.find('span')
.first()
.prop('style')
).toMatchObject(
expect.objectContaining({
color: expect.any(String),
})
);
expect(
wrapper
.find('span')
.first()
.text()
).toBe('ipsum');
});
});

View File

@ -46,15 +46,15 @@ export class LogMessageAnsi extends PureComponent<Props, State> {
const parsed = ansicolor.parse(props.value);
return {
chunks: parsed.spans.map((span) => {
return span.css ?
{
style: convertCSSToStyle(span.css),
text: span.text
} :
{ text: span.text };
chunks: parsed.spans.map(span => {
return span.css
? {
style: convertCSSToStyle(span.css),
text: span.text,
}
: { text: span.text };
}),
prevValue: props.value
prevValue: props.value,
};
}
@ -62,9 +62,14 @@ export class LogMessageAnsi extends PureComponent<Props, State> {
const { chunks } = this.state;
return chunks.map(
(chunk, index) => chunk.style ?
<span key={index} style={chunk.style}>{chunk.text}</span> :
chunk.text
(chunk, index) =>
chunk.style ? (
<span key={index} style={chunk.style}>
{chunk.text}
</span>
) : (
chunk.text
)
);
}
}