Skip to content

Commit

Permalink
Change a console.warn to console.error for reporting bad rule inserti…
Browse files Browse the repository at this point in the history
…on attempt in speedy mode (emotion-js#1811)
  • Loading branch information
Andarist authored Mar 16, 2020
1 parent 116b617 commit 3d38b09
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/css/test/sheet.dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('sheet', () => {

test('throws', () => {
sheet.speedy(true)
const spy = jest.spyOn(global.console, 'warn')
const spy = jest.spyOn(global.console, 'error')
sheet.insert('.asdfasdf4###112121211{')
expect(spy).toHaveBeenCalled()
})
Expand Down
10 changes: 5 additions & 5 deletions packages/sheet/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ describe('StyleSheet', () => {

it('should throw when inserting a bad rule in speedy mode', () => {
const sheet = new StyleSheet({ ...defaultOptions, speedy: true })
const oldConsoleWarn = console.warn
const oldConsoleError = console.error
// $FlowFixMe
console.warn = jest.fn()
console.error = jest.fn()
sheet.insert('.asdfasdf4###112121211{')
expect(console.warn).toHaveBeenCalledTimes(1)
expect((console.warn: any).mock.calls[0][0]).toBe(
expect(console.error).toHaveBeenCalledTimes(1)
expect((console.error: any).mock.calls[0][0]).toBe(
'There was a problem inserting the following rule: ".asdfasdf4###112121211{"'
)
// $FlowFixMe
console.warn = oldConsoleWarn
console.error = oldConsoleError
sheet.flush()
})

Expand Down
2 changes: 1 addition & 1 deletion packages/sheet/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class StyleSheet {
)
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
console.warn(
console.error(
`There was a problem inserting the following rule: "${rule}"`,
e
)
Expand Down

0 comments on commit 3d38b09

Please sign in to comment.