This repository was archived by the owner on Sep 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +50
-4
lines changed
packages/c-color-mode/tests Expand file tree Collapse file tree 2 files changed +50
-4
lines changed Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` should toggle colormode 1` ] = `
4
+ <DocumentFragment >
5
+ <div >
6
+ <div
7
+ data-testid = " colormode"
8
+ >
9
+ dark
10
+ </div >
11
+ <button
12
+ data-testid = " toggle"
13
+ >
14
+ Toggle color mode
15
+ </button >
16
+ </div >
17
+ </DocumentFragment >
18
+ ` ;
Original file line number Diff line number Diff line change 1
- import { CColorMode } from '../'
1
+ import { defineComponent , nextTick } from 'vue'
2
+ import { render , userEvent } from '../../test-utils/src'
3
+ import { useColorMode } from '../src'
2
4
5
+ const renderComponent = ( props ?: any ) => {
6
+ const base = defineComponent ( {
7
+ template : `
8
+ <div>
9
+ <div data-testid="colormode"> {{ colorMode }} </div>
10
+ <button data-testid="toggle" @click="toggleColorMode">Toggle color mode</button>
11
+ </div>
12
+ ` ,
13
+ setup ( ) {
14
+ const { colorMode, toggleColorMode } = useColorMode ( )
15
+ return {
16
+ colorMode,
17
+ toggleColorMode,
18
+ }
19
+ } ,
20
+ ...props ,
21
+ } )
22
+ return render ( base )
23
+ }
3
24
4
- it ( 'should be truthy' , ( ) => {
5
- expect ( 1 ) . toBe ( 1 )
6
- } )
25
+ it ( 'should toggle colormode' , async ( ) => {
26
+ const { getByTestId, asFragment } = renderComponent ( )
27
+ expect ( getByTestId ( 'colormode' ) . textContent ) . toBe ( 'light' )
28
+
29
+ await userEvent . click ( getByTestId ( 'toggle' ) )
30
+ await nextTick ( )
31
+ expect ( getByTestId ( 'colormode' ) . textContent ) . toBe ( 'dark' )
32
+
33
+ expect ( asFragment ( ) ) . toMatchSnapshot ( )
34
+ } )
You can’t perform that action at this time.
0 commit comments