Skip to content

Commit

Permalink
revisions to Flash and Flash tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VanAnderson committed Mar 4, 2021
1 parent c69d1d4 commit 6773c27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
9 changes: 0 additions & 9 deletions src/Flash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import {COMMON, get, SystemCommonProps} from './constants'
import sx, {SxProp} from './sx'
import theme from './theme'

const variantAliases = {
default: 'info',
info: 'info',
warning: 'warn',
danger: 'error',
success: 'success'
}

const variants = variant({
variants: {
default: {
Expand Down Expand Up @@ -69,7 +61,6 @@ const Flash = styled.div<
}
svg {
color: ${props => get(`colors.alert.${variantAliases[props.variant || 'default']}.icon`)(props.theme)};
margin-right: ${get('space.2')};
}
Expand Down
11 changes: 5 additions & 6 deletions src/__tests__/Flash.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react'
import {Flash} from '..'
import {COMMON} from '../constants'
import theme, {colors} from '../theme'
import {default as primitives} from '@primer/primitives'
import theme from '../theme'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand Down Expand Up @@ -32,16 +31,16 @@ describe('Flash', () => {
it('respects the "variant" prop', () => {
expect(render(<Flash variant="warning" theme={theme} />)).toHaveStyleRule(
'background-color',
primitives.colors.light.alert.warn.bg
theme.colors.alert.warn.bg
)
expect(render(<Flash variant="danger" theme={theme} />)).toHaveStyleRule(
'background-color',
primitives.colors.light.alert.error.bg
theme.colors.alert.error.bg
)
expect(render(<Flash variant="success" theme={theme} />)).toHaveStyleRule(
'background-color',
primitives.colors.light.alert.success.bg
theme.colors.alert.success.bg
)
expect(render(<Flash theme={theme} />)).toHaveStyleRule('background-color', primitives.colors.light.alert.info.bg)
expect(render(<Flash theme={theme} />)).toHaveStyleRule('background-color', theme.colors.alert.info.bg)
})
})
5 changes: 4 additions & 1 deletion src/__tests__/__snapshots__/Flash.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ exports[`Flash renders consistently 1`] = `
}
.c0 svg {
color: rgba(4,66,137,0.6);
margin-right: 8px;
}
.c0 svg {
color: rgba(4,66,137,0.6);
}
<div
className="c0"
/>
Expand Down

0 comments on commit 6773c27

Please sign in to comment.