Skip to content

Commit

Permalink
cypress theme change updated
Browse files Browse the repository at this point in the history
  • Loading branch information
solmanter committed Jan 4, 2024
1 parent 34b41fe commit 4495069
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 9 additions & 3 deletions cypress/e2e/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ context('Basic', () => {
it('theme change', () => {
const toggle = cy.get('[data-test-id="toggle_theme"]')

toggle.click()
const prefersDark
= window.matchMedia
&& window.matchMedia('(prefers-color-scheme: dark)').matches

cy.get('html').should('have.class', 'van-theme-light')
const setting = localStorage.getItem('vueuse-color-scheme') || 'auto'
const isDark = setting === 'dark' || (setting === 'auto' && prefersDark)

toggle.click()

cy.get('html').should('have.class', 'van-theme-dark')
if (isDark)
cy.get('html').should('have.class', 'van-theme-light')
else
cy.get('html').should('have.class', 'van-theme-dark')
})
})
3 changes: 0 additions & 3 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ declare module 'vue' {
TheCounter: typeof import('./components/TheCounter.vue')['default']
TheFooter: typeof import('./components/TheFooter.vue')['default']
TheInput: typeof import('./components/TheInput.vue')['default']
VanButton: typeof import('vant/es')['Button']
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
VanField: typeof import('vant/es')['Field']
}
}

0 comments on commit 4495069

Please sign in to comment.