Skip to content

Commit

Permalink
fix(b-media): fix vertical align class when top or bottom selected (f…
Browse files Browse the repository at this point in the history
…ixes #4052) (#4055)

* fix(b-media): fix vertical align class when top or bottom selected (fixes #4052)

* Update media-aside.js

* Update media.spec.js

* Update media-aside.spec.js
  • Loading branch information
tmorehouse authored and jacobmllr95 committed Sep 9, 2019
1 parent c97e06f commit 9ccfe4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/components/media/media-aside.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ export const BMediaAside = /*#__PURE__*/ Vue.extend({
functional: true,
props,
render(h, { props, data, children }) {
const align =
props.verticalAlign === 'top'
? 'start'
: props.verticalAlign === 'bottom'
? 'end'
: props.verticalAlign
return h(
props.tag,
mergeData(data, {
staticClass: 'd-flex',
class: {
[`align-self-${props.verticalAlign}`]: props.verticalAlign
[`align-self-${align}`]: align
}
}),
children
Expand Down
8 changes: 4 additions & 4 deletions src/components/media/media-aside.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('media-aside', () => {

expect(wrapper.is('div')).toBe(true)
expect(wrapper.classes()).toContain('d-flex')
expect(wrapper.classes()).toContain('align-self-top')
expect(wrapper.classes()).toContain('align-self-start')
expect(wrapper.text()).toEqual('')
})

Expand All @@ -20,7 +20,7 @@ describe('media-aside', () => {

expect(wrapper.is('span')).toBe(true)
expect(wrapper.classes()).toContain('d-flex')
expect(wrapper.classes()).toContain('align-self-top')
expect(wrapper.classes()).toContain('align-self-start')
expect(wrapper.classes().length).toBe(2)
expect(wrapper.text()).toEqual('')
})
Expand All @@ -34,7 +34,7 @@ describe('media-aside', () => {

expect(wrapper.is('div')).toBe(true)
expect(wrapper.classes()).toContain('d-flex')
expect(wrapper.classes()).toContain('align-self-bottom')
expect(wrapper.classes()).toContain('align-self-end')
expect(wrapper.classes().length).toBe(2)
})

Expand All @@ -47,7 +47,7 @@ describe('media-aside', () => {

expect(wrapper.is('div')).toBe(true)
expect(wrapper.classes()).toContain('d-flex')
expect(wrapper.classes()).toContain('align-self-top')
expect(wrapper.classes()).toContain('align-self-start')
expect(wrapper.classes().length).toBe(2)
expect(wrapper.findAll('b').length).toBe(1)
expect(wrapper.find('b').text()).toBe('foobar')
Expand Down
2 changes: 1 addition & 1 deletion src/components/media/media.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('media', () => {
// Should have only two child elements
expect(wrapper.findAll('.media > *').length).toBe(2)
// Should have media aside with self align bottom
expect(wrapper.find('.d-flex').classes()).toContain('align-self-bottom')
expect(wrapper.find('.d-flex').classes()).toContain('align-self-end')
// Should have content in aside
expect(wrapper.find('.d-flex').text()).toEqual('foobar')
})
Expand Down

0 comments on commit 9ccfe4c

Please sign in to comment.