-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Showing
37 changed files
with
1,582 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
["@babel/preset-env", { "targets": { "node": 8 }}] | ||
] | ||
} | ||
} | ||
} |
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
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
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,30 @@ | ||
import Content from '@/app/Content.js' | ||
import { mount } from '@vue/test-utils' | ||
import { getRouter, modeTestRunner } from '../util' | ||
|
||
function test (mode, localVue) { | ||
it(`${mode} - add custom class by default.`, () => { | ||
const wrapper = mount(Content, { | ||
localVue, | ||
router: getRouter() | ||
}) | ||
expect(wrapper.contains('.custom')).toBe(true) | ||
}) | ||
|
||
it(`${mode} - remove custom when custom set to false.`, () => { | ||
const wrapper = mount(Content, { | ||
// https://vue-test-utils.vuejs.org/api/options.html#context | ||
context: { | ||
props: { | ||
custom: false | ||
} | ||
}, | ||
localVue, | ||
router: getRouter() | ||
}) | ||
expect(wrapper.contains('.custom')).toBe(false) | ||
}) | ||
} | ||
|
||
modeTestRunner('Content', test) | ||
|
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,31 @@ | ||
import { mount, RouterLinkStub } from '@vue/test-utils' | ||
import DropdownLink from '@/default-theme/DropdownLink.vue' | ||
import { modeTestRunner } from '../util' | ||
|
||
function test (mode, localVue) { | ||
it(`$${mode} - renders dropdown link.`, () => { | ||
const item = { | ||
text: 'VuePress', | ||
items: [ | ||
{ | ||
text: 'Guide', | ||
link: '/guide/' | ||
}, | ||
{ | ||
text: 'Config Reference', | ||
link: '/config/' | ||
} | ||
] | ||
} | ||
const wrapper = mount(DropdownLink, { | ||
localVue, | ||
stubs: { | ||
'router-link': RouterLinkStub | ||
}, | ||
propsData: { item } | ||
}) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
} | ||
|
||
modeTestRunner('DropdownLink', test) |
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,34 @@ | ||
import { mount, RouterLinkStub } from '@vue/test-utils' | ||
import { modeTestRunner } from '../util' | ||
import NavLink from '@/default-theme/NavLink.vue' | ||
|
||
function test (mode, localVue) { | ||
it(`$${mode} - renders nav link with internal link`, () => { | ||
const item = { | ||
link: '/', | ||
text: 'VuePress' | ||
} | ||
const wrapper = mount(NavLink, { | ||
localVue, | ||
stubs: { | ||
'router-link': RouterLinkStub | ||
}, | ||
propsData: { item } | ||
}) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
|
||
it(`$${mode} - renders nav link with external link`, () => { | ||
const item = { | ||
link: 'http://vuejs.org/', | ||
text: 'Vue' | ||
} | ||
const wrapper = mount(NavLink, { | ||
localVue, | ||
propsData: { item } | ||
}) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
} | ||
|
||
modeTestRunner('NavLink', test) |
33 changes: 33 additions & 0 deletions
33
test/default-theme/__snapshots__/DropdownLink.spec.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[`DropdownLink $i18n - renders dropdown link. 1`] = ` | ||
<div class="dropdown-wrapper"> | ||
<a class="dropdown-title"><span class="title">VuePress</span> <span class="arrow right"></span></a> | ||
<ul class="nav-dropdown" style="display: none;" name="dropdown"> | ||
<li class="dropdown-item"> | ||
<!----> | ||
<a class="nav-link">Guide</a> | ||
</li> | ||
<li class="dropdown-item"> | ||
<!----> | ||
<a class="nav-link">Config Reference</a> | ||
</li> | ||
</ul> | ||
</div> | ||
`; | ||
|
||
exports[`DropdownLink $simple - renders dropdown link. 1`] = ` | ||
<div class="dropdown-wrapper"> | ||
<a class="dropdown-title"><span class="title">VuePress</span> <span class="arrow right"></span></a> | ||
<ul class="nav-dropdown" style="display: none;" name="dropdown"> | ||
<li class="dropdown-item"> | ||
<!----> | ||
<a class="nav-link">Guide</a> | ||
</li> | ||
<li class="dropdown-item"> | ||
<!----> | ||
<a class="nav-link">Config Reference</a> | ||
</li> | ||
</ul> | ||
</div> | ||
`; |
Oops, something went wrong.