Skip to content

Commit 294952e

Browse files
authored
Merge pull request #716 from VividLemon/master
test: breadcrumb-item
2 parents 9153b43 + 5dc4269 commit 294952e

File tree

3 files changed

+152
-4
lines changed

3 files changed

+152
-4
lines changed

packages/bootstrap-vue-3/src/components/BBreadcrumb/breadcrumb-item.spec.ts

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('breadcrumb-item', () => {
5252
expect($blink.emitted()).toHaveProperty('click')
5353
})
5454

55-
it('does not emit click event when prop disabled', async () => {
55+
it('does not emit click event when prop disabled and blink clicked', async () => {
5656
const wrapper = mount(BBreadcrumbItem, {
5757
props: {disabled: true},
5858
})
@@ -61,6 +61,15 @@ describe('breadcrumb-item', () => {
6161
expect(wrapper.emitted('click')).toBeUndefined()
6262
})
6363

64+
it('does not emit click event when prop active and span clicked', async () => {
65+
const wrapper = mount(BBreadcrumbItem, {
66+
props: {active: true},
67+
})
68+
const $span = wrapper.get('span')
69+
await $span.trigger('click')
70+
expect(wrapper.emitted('click')).toBeUndefined()
71+
})
72+
6473
it('emits a MouseEvent when clicked', async () => {
6574
const wrapper = mount(BBreadcrumbItem)
6675
const $blink = wrapper.getComponent(BLink)
@@ -77,4 +86,93 @@ describe('breadcrumb-item', () => {
7786
const $span = wrapper.get('span')
7887
expect($span.text()).toBe('foobar')
7988
})
89+
90+
it('renders prop text in child when child is span', () => {
91+
const wrapper = mount(BBreadcrumbItem, {
92+
props: {active: true, text: 'foobar'},
93+
})
94+
const $span = wrapper.get('span')
95+
expect($span.text()).toBe('foobar')
96+
})
97+
98+
it('renders prop text in child when child is span', () => {
99+
const wrapper = mount(BBreadcrumbItem, {
100+
props: {active: true, text: 'props'},
101+
slots: {default: 'slots'},
102+
})
103+
const $span = wrapper.get('span')
104+
expect($span.text()).toBe('slots')
105+
})
106+
107+
it('does not give prop active to child', () => {
108+
const wrapper = mount(BBreadcrumbItem, {
109+
props: {active: true},
110+
})
111+
const $span = wrapper.get('span')
112+
expect($span.attributes('active')).toBeUndefined()
113+
})
114+
115+
it('does not give prop ariaCurrent to child', () => {
116+
const wrapper = mount(BBreadcrumbItem, {
117+
props: {active: true, ariaCurrent: 'foobar'},
118+
})
119+
const $span = wrapper.get('span')
120+
expect($span.attributes('ariaCurrent')).toBeUndefined()
121+
})
122+
123+
it('does not give prop disabled to child', () => {
124+
const wrapper = mount(BBreadcrumbItem, {
125+
props: {active: true, disabled: true},
126+
})
127+
const $span = wrapper.get('span')
128+
expect($span.attributes('disabled')).toBeUndefined()
129+
})
130+
131+
it('does not give prop text to child', () => {
132+
const wrapper = mount(BBreadcrumbItem, {
133+
props: {active: true, text: 'foobar'},
134+
})
135+
const $span = wrapper.get('span')
136+
expect($span.attributes('text')).toBeUndefined()
137+
})
138+
139+
it('gives prop active to child when blink', () => {
140+
const wrapper = mount(BBreadcrumbItem, {
141+
props: {active: false},
142+
})
143+
const $blink = wrapper.getComponent(BLink)
144+
expect($blink.props('active')).toBe(false)
145+
})
146+
147+
it('does not give prop ariaCurrent to child when blink', () => {
148+
const wrapper = mount(BBreadcrumbItem, {
149+
props: {active: false, ariaCurrent: 'foobar'},
150+
})
151+
const $blink = wrapper.getComponent(BLink)
152+
expect($blink.props('ariaCurrent')).toBeUndefined()
153+
})
154+
155+
it('gives prop disabled to child when blink', () => {
156+
const wrapper = mount(BBreadcrumbItem, {
157+
props: {active: false, disabled: true},
158+
})
159+
const $blink = wrapper.getComponent(BLink)
160+
expect($blink.props('disabled')).toBe(true)
161+
})
162+
163+
it('does not give prop text to child when blink', () => {
164+
const wrapper = mount(BBreadcrumbItem, {
165+
props: {active: false, text: 'foobar'},
166+
})
167+
const $blink = wrapper.getComponent(BLink)
168+
expect($blink.props('text')).toBeUndefined()
169+
})
170+
171+
it('gives prop activeClass to blink', () => {
172+
const wrapper = mount(BBreadcrumbItem, {
173+
props: {activeClass: 'foobar'},
174+
})
175+
const $blink = wrapper.getComponent(BLink)
176+
expect($blink.props('activeClass')).toBe('foobar')
177+
})
80178
})

packages/bootstrap-vue-3/src/components/BBreadcrumb/breadcrumb.spec.ts

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('breadcrumb', () => {
9292
expect(wrapper.text()).toBe('prependfoodefault')
9393
})
9494

95-
it('bbreadcrumbitem contains items as props', () => {
95+
it('bbreadcrumbitem exists when items array item is object', () => {
9696
const wrapper = mount(BBreadcrumb, {
9797
global: {provide: {[BREADCRUMB_SYMBOL as unknown as symbol]: {}}},
9898
props: {
@@ -103,10 +103,60 @@ describe('breadcrumb', () => {
103103
slots: {default: 'default', prepend: 'prepend'},
104104
})
105105
const $bbreadcrumbitem = wrapper.findComponent(BBreadcrumbItem)
106+
expect($bbreadcrumbitem.exists()).toBe(true)
107+
})
108+
109+
it('bbreadcrumbitem contains items as props', () => {
110+
const wrapper = mount(BBreadcrumb, {
111+
global: {provide: {[BREADCRUMB_SYMBOL as unknown as symbol]: {}}},
112+
props: {
113+
items: [
114+
{text: 'foo', active: true, disabled: true, href: 'href', to: 'to'},
115+
] as Array<BreadcrumbItem>,
116+
},
117+
slots: {default: 'default', prepend: 'prepend'},
118+
})
119+
const $bbreadcrumbitem = wrapper.getComponent(BBreadcrumbItem)
106120
expect($bbreadcrumbitem.props('text')).toBe('foo')
107121
expect($bbreadcrumbitem.props('active')).toBe(true)
108122
expect($bbreadcrumbitem.props('disabled')).toBe(true)
109123
expect($bbreadcrumbitem.props('href')).toBe('href')
110124
expect($bbreadcrumbitem.props('to')).toBe('to')
111125
})
126+
127+
it('breadcrumbitem exists when items array item is string', () => {
128+
const wrapper = mount(BBreadcrumb, {
129+
global: {provide: {[BREADCRUMB_SYMBOL as unknown as symbol]: {}}},
130+
props: {items: ['foobar']},
131+
})
132+
const $bbreadcrumbitem = wrapper.findComponent(BBreadcrumbItem)
133+
expect($bbreadcrumbitem.exists()).toBe(true)
134+
})
135+
136+
it('breadcrumbitem has prop text to be string when prop items array item is string', () => {
137+
const wrapper = mount(BBreadcrumb, {
138+
global: {provide: {[BREADCRUMB_SYMBOL as unknown as symbol]: {}}},
139+
props: {items: ['foobar']},
140+
})
141+
const $bbreadcrumbitem = wrapper.getComponent(BBreadcrumbItem)
142+
expect($bbreadcrumbitem.props('text')).toBe('foobar')
143+
})
144+
145+
it('breadcrumbitem components have prop href to be # when their index is less than items length', () => {
146+
const wrapper = mount(BBreadcrumb, {
147+
global: {provide: {[BREADCRUMB_SYMBOL as unknown as symbol]: {}}},
148+
props: {items: ['foo', 'bar']},
149+
})
150+
const [$bbreadcrumbitem] = wrapper.findAllComponents(BBreadcrumbItem)
151+
expect($bbreadcrumbitem.props('href')).toBe('#')
152+
})
153+
154+
it('breadcrumbitem components dont have prop href to be # when their index is items length', () => {
155+
const wrapper = mount(BBreadcrumb, {
156+
global: {provide: {[BREADCRUMB_SYMBOL as unknown as symbol]: {}}},
157+
props: {items: ['foo', 'bar']},
158+
})
159+
const [, $bbreadcrumbitem] = wrapper.findAllComponents(BBreadcrumbItem)
160+
expect($bbreadcrumbitem.props('href')).toBeUndefined()
161+
})
112162
})

packages/bootstrap-vue-3/src/components/BInputGroup/input-group-addon.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ describe('input-group-addon', () => {
2222
expect($inputgrouptext.exists()).toBe(true)
2323
})
2424

25-
it('renders default sloot when not prop isText', () => {
25+
it('renders default slot when not prop isText', () => {
2626
const wrapper = mount(BInputGroupAddon, {
2727
slots: {default: 'foobar'},
2828
})
2929
expect(wrapper.text()).toBe('foobar')
3030
})
3131

32-
it('renders default sloot when not prop isText', () => {
32+
it('renders default slot in BInputGroupText when not prop isText', () => {
3333
const wrapper = mount(BInputGroupAddon, {
3434
slots: {default: 'foobar'},
3535
props: {isText: true},

0 commit comments

Comments
 (0)