File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change
1
+ import Vue from 'vue'
1
2
import mountTemplate from 'test/utils/mountTemplate'
2
3
import MdDivider from './MdDivider.vue'
3
4
@@ -9,8 +10,30 @@ test('should render the divider', async () => {
9
10
} )
10
11
11
12
test ( 'should render the theme class' , async ( ) => {
12
- const template = '<md-divider md-theme="alt">Lorem ipsum </md-divider>'
13
+ const template = '<md-divider md-theme="alt"></md-divider>'
13
14
const wrapper = await mountTemplate ( MdDivider , template )
14
15
15
16
expect ( wrapper . hasClass ( 'md-theme-alt' ) ) . toBe ( true )
16
17
} )
18
+
19
+ test ( 'should render a <li> tag when inside lists' , async ( ) => {
20
+ Vue . component ( 'MdList' , {
21
+ template : '<div><slot></slot></div>'
22
+ } )
23
+ const template = `
24
+ <md-list>
25
+ <md-divider></md-divider>
26
+ </md-list>`
27
+ const wrapper = await mountTemplate ( MdDivider , template )
28
+ const divider = wrapper . find ( MdDivider ) [ 0 ]
29
+
30
+ expect ( divider . vm . $el . tagName . toLowerCase ( ) ) . toBe ( 'li' )
31
+ } )
32
+
33
+ test ( 'should render a <hr> tag when inside any other element' , async ( ) => {
34
+ const template = `<md-divider></md-divider>`
35
+ const wrapper = await mountTemplate ( MdDivider , template )
36
+ const divider = wrapper . find ( MdDivider ) [ 0 ]
37
+
38
+ expect ( divider . vm . $el . tagName . toLowerCase ( ) ) . toBe ( 'hr' )
39
+ } )
Original file line number Diff line number Diff line change 1
1
<template >
2
- <hr class =" md-divider" :class =" [$mdActiveTheme]" >
2
+ <li class =" md-divider" :class =" [$mdActiveTheme]" v-if =" insideList" ></li >
3
+ <hr class =" md-divider" :class =" [$mdActiveTheme]" v-else >
3
4
</template >
4
5
5
6
<script >
6
7
import MdComponent from ' core/MdComponent'
7
8
8
9
export default new MdComponent ({
9
- name: ' MdDivider'
10
+ name: ' MdDivider' ,
11
+ computed: {
12
+ insideList () {
13
+ return this .$parent .$options ._componentTag === ' md-list'
14
+ }
15
+ }
10
16
})
11
17
</script >
12
18
You can’t perform that action at this time.
0 commit comments