-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(VListItem): allow default color to change when inactive (#14207)
fixes #9285
- Loading branch information
Showing
5 changed files
with
117 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
87 changes: 82 additions & 5 deletions
87
packages/vuetify/src/mixins/routable/__tests__/routable.spec.ts
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 |
---|---|---|
@@ -1,17 +1,94 @@ | ||
import Routable from '../' | ||
import { mount } from '@vue/test-utils' | ||
import { createLocalVue, mount, Wrapper } from '@vue/test-utils' | ||
import Router from 'vue-router' | ||
import Vue, { VNode } from 'vue' | ||
|
||
describe('routable.ts', () => { | ||
let mountFunction: (options?: object) => Wrapper<Vue> | ||
let router: Router | ||
let localVue: typeof Vue | ||
|
||
beforeEach(() => { | ||
router = new Router() | ||
localVue = createLocalVue() | ||
localVue.use(Router) | ||
|
||
mountFunction = (options = {}) => { | ||
return mount({ | ||
mixins: [Routable], | ||
props: { | ||
activeClass: { | ||
default: 'active', | ||
}, | ||
exactActiveClass: { | ||
default: 'exact-active', | ||
}, | ||
}, | ||
render (h): VNode { | ||
const { tag, data } = this.generateRouteLink() | ||
|
||
data.attrs = { | ||
...data.attrs, | ||
} | ||
data.on = { | ||
...data.on, | ||
} | ||
|
||
return h(tag, data, this.$slots.default) | ||
}, | ||
}, { | ||
localVue, | ||
router, | ||
...options, | ||
}) | ||
} | ||
}) | ||
it('should generate exact route link with to="/" and undefined exact', async () => { | ||
const wrapper = mount({ | ||
mixins: [Routable], | ||
render: h => h('div'), | ||
}, { | ||
const wrapper = mountFunction({ | ||
propsData: { | ||
to: '/', | ||
}, | ||
}) | ||
|
||
expect(wrapper.vm.generateRouteLink().data.props.exact).toBe(true) | ||
}) | ||
|
||
it('should reflect the link state to isActive', async () => { | ||
const wrapper = mountFunction({ | ||
propsData: { | ||
to: '/', | ||
}, | ||
}) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.vm.isActive).toBe(true) | ||
|
||
// Simulate route changing | ||
wrapper.vm.$router.push('/foo') | ||
|
||
await wrapper.vm.$nextTick() | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.vm.isActive).toBe(false) | ||
|
||
wrapper.vm.$router.push('/') | ||
await wrapper.vm.$nextTick() | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.vm.isActive).toBe(true) | ||
}) | ||
|
||
it('should reflect the link state to isActive if not exact', async () => { | ||
const wrapper = mountFunction({ | ||
propsData: { | ||
to: '/foo', | ||
}, | ||
}) | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.vm.isActive).toBe(false) | ||
|
||
// Simulate route changing | ||
wrapper.vm.$router.push('/foo') | ||
|
||
await wrapper.vm.$nextTick() | ||
await wrapper.vm.$nextTick() | ||
expect(wrapper.vm.isActive).toBe(true) | ||
}) | ||
}) |
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