forked from chakra-ui/chakra-ui-vue
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f203fe3
commit a01ea6d
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/chakra-ui-core/src/utils/__snapshots__/component.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`createStyledAttrsMixin baseStyle should be overiden by props 1`] = ` | ||
<DocumentFragment> | ||
.emotion-0 { | ||
background: var(--colors-blue-200); | ||
color: var(--colors-gray-200); | ||
} | ||
<div | ||
class="emotion-0" | ||
data-chakra-component="FakeComponent" | ||
> | ||
Fake component | ||
</div> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`createStyledAttrsMixin baseStyle should use theme.baseStyle if given 1`] = ` | ||
<DocumentFragment> | ||
.emotion-0 { | ||
background: var(--colors-red-400); | ||
color: var(--colors-gray-200); | ||
} | ||
<div | ||
class="emotion-0" | ||
data-chakra-component="FakeComponent" | ||
> | ||
Fake component | ||
</div> | ||
</DocumentFragment> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import defaultTheme from '@chakra-ui/theme-vue' | ||
import { toCSSVar } from '@chakra-ui/styled-system' | ||
import { createStyledAttrsMixin } from './components' | ||
import { render } from '@/tests/test-utils' | ||
|
||
describe('createStyledAttrsMixin', () => { | ||
const FakeComponent = { | ||
name: 'FakeComponent', | ||
mixins: [createStyledAttrsMixin('FakeComponent', true)], | ||
render (h) { | ||
return h( | ||
'div', | ||
{ | ||
class: this.className, | ||
attrs: this.computedAttrs | ||
}, | ||
'Fake component' | ||
) | ||
} | ||
} | ||
|
||
describe('baseStyle', () => { | ||
const renderFakeComponent = ({ theme, ...props }) => { | ||
const inlineAttrs = (props && props.inlineAttrs) || '' | ||
return render({ | ||
template: `<FakeComponent ${inlineAttrs} />`, | ||
components: { | ||
FakeComponent | ||
}, | ||
provide: () => ({ | ||
$chakraTheme: () => toCSSVar(theme), | ||
$chakraColorMode: () => 'light' | ||
}), | ||
...props | ||
}) | ||
} | ||
|
||
it('should use theme.baseStyle if given', () => { | ||
const { asFragment } = renderFakeComponent({ | ||
theme: { | ||
...defaultTheme, | ||
baseStyle: { | ||
FakeComponent: { | ||
bg: 'red.400', | ||
color: 'gray.200' | ||
} | ||
} | ||
} | ||
}) | ||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
|
||
it('should be overiden by props', () => { | ||
const { asFragment } = renderFakeComponent({ | ||
inlineAttrs: 'bg="blue.200"', | ||
theme: { | ||
...defaultTheme, | ||
baseStyle: { | ||
FakeComponent: { | ||
bg: 'red.400', | ||
color: 'gray.200' | ||
} | ||
} | ||
} | ||
}) | ||
expect(asFragment()).toMatchSnapshot() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters