Skip to content

Commit

Permalink
chore(tests): remove createContainer helper
Browse files Browse the repository at this point in the history
createContainer function is now implemented by VTU mimicking this
behaviour when you pass `attachTo: document.body`
  • Loading branch information
xanf committed Dec 18, 2021
1 parent 7ad43e1 commit d113cc7
Show file tree
Hide file tree
Showing 46 changed files with 376 additions and 389 deletions.
8 changes: 4 additions & 4 deletions src/components/button-toolbar/button-toolbar.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import { createContainer, waitNT } from '../../../tests/utils'
import { waitNT } from '../../../tests/utils'
import { BButton } from '../button/button'
import { BButtonGroup } from '../button-group/button-group'
import { BButtonToolbar } from './button-toolbar'
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('button-toolbar', () => {

it('has correct structure', async () => {
const wrapper = mount(App, {
attachTo: createContainer()
attachTo: document.body
})

await waitNT(wrapper.vm)
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('button-toolbar', () => {

it('focuses first button when tabbed into', async () => {
const wrapper = mount(App, {
attachTo: createContainer()
attachTo: document.body
})

await waitNT(wrapper.vm)
Expand All @@ -173,7 +173,7 @@ describe('button-toolbar', () => {

it('keyboard navigation works', async () => {
const wrapper = mount(App, {
attachTo: createContainer()
attachTo: document.body
})

await waitNT(wrapper.vm)
Expand Down
28 changes: 14 additions & 14 deletions src/components/calendar/calendar.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import { createContainer, waitNT, waitRAF } from '../../../tests/utils'
import { waitNT, waitRAF } from '../../../tests/utils'
import { BCalendar } from './calendar'
import { formatYMD } from '../../utils/date'

Expand All @@ -8,7 +8,7 @@ import { formatYMD } from '../../utils/date'
describe('calendar', () => {
it('has expected base structure', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer()
attachTo: document.body
})

expect(wrapper.vm).toBeDefined()
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('calendar', () => {

it('has expected structure when value is set', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-02-15' // Leap year
}
Expand All @@ -62,7 +62,7 @@ describe('calendar', () => {

it('reacts to changes in value', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-01-01' // Leap year
}
Expand All @@ -88,7 +88,7 @@ describe('calendar', () => {

it('clicking a date selects date', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-01-01' // Leap year
}
Expand Down Expand Up @@ -122,7 +122,7 @@ describe('calendar', () => {

it('date navigation buttons work', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
showDecadeNav: true,
value: '2020-02-15' // Leap year
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('calendar', () => {

it('focus and blur methods work', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-02-15' // Leap year
}
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('calendar', () => {

it('clicking output header focuses grid', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-02-15' // Leap year
}
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('calendar', () => {

it('has correct header tag when "header-tag" prop is set', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-02-15', // Leap year,
headerTag: 'div'
Expand All @@ -266,7 +266,7 @@ describe('calendar', () => {

it('keyboard navigation works', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-02-15' // Leap year
}
Expand Down Expand Up @@ -362,7 +362,7 @@ describe('calendar', () => {

it('should disable key navigation when `no-key-nav` prop set', () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
noKeyNav: true,
navButtonVariant: 'primary'
Expand All @@ -381,7 +381,7 @@ describe('calendar', () => {

it('`nav-button-variant` changes nav button class', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
navButtonVariant: 'primary'
}
Expand All @@ -400,7 +400,7 @@ describe('calendar', () => {

it('disables dates based on `date-disabled-fn` prop', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-01-01',
dateDisabledFn(ymd) {
Expand Down Expand Up @@ -433,7 +433,7 @@ describe('calendar', () => {

it('applies classes on dates based on `date-info-fn` prop', async () => {
const wrapper = mount(BCalendar, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
value: '2020-01-01',
dateInfoFn(ymd) {
Expand Down
38 changes: 19 additions & 19 deletions src/components/carousel/carousel.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'
import { createContainer, waitNT, waitRAF } from '../../../tests/utils'
import { waitNT, waitRAF } from '../../../tests/utils'
import { BCarousel } from './carousel'
import { BCarouselSlide } from './carousel-slide'

Expand Down Expand Up @@ -34,7 +34,7 @@ const App = {
describe('carousel', () => {
it('has expected default structure', async () => {
const wrapper = mount(BCarousel, {
attachTo: createContainer()
attachTo: document.body
})

expect(wrapper.vm).toBeDefined()
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('carousel', () => {

it('has prev/next controls when prop controls is set', async () => {
const wrapper = mount(BCarousel, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
controls: true
}
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('carousel', () => {

it('has indicators showing when prop indicators is set', async () => {
const wrapper = mount(BCarousel, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
indicators: true
}
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('carousel', () => {

it('should have class "carousel-fade" when prop "fade" is "true"', async () => {
const wrapper = mount(BCarousel, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
fade: true
}
Expand All @@ -230,7 +230,7 @@ describe('carousel', () => {

it('should not have class "fade" or "slide" when prop "no-animation" is "true"', async () => {
const wrapper = mount(BCarousel, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
noAnimation: true
}
Expand All @@ -249,7 +249,7 @@ describe('carousel', () => {

it('should not have class "fade" or "slide" when prop "no-animation" and "fade" are "true"', async () => {
const wrapper = mount(BCarousel, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
fade: true,
noAnimation: true
Expand All @@ -269,7 +269,7 @@ describe('carousel', () => {

it('should not automatically scroll to next slide when "interval" is "0"', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0
}
Expand All @@ -296,7 +296,7 @@ describe('carousel', () => {

it('should scroll to next/prev slide when next/prev clicked', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
controls: true
Expand Down Expand Up @@ -358,7 +358,7 @@ describe('carousel', () => {

it('should scroll to next/prev slide when next/prev space keypress', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
controls: true
Expand Down Expand Up @@ -420,7 +420,7 @@ describe('carousel', () => {

it('should scroll to specified slide when indicator clicked', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
controls: true
Expand Down Expand Up @@ -482,7 +482,7 @@ describe('carousel', () => {

it('should scroll to specified slide when indicator keypress space/enter', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
controls: true
Expand Down Expand Up @@ -544,7 +544,7 @@ describe('carousel', () => {

it('should scroll to next/prev slide when key next/prev pressed', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
controls: true
Expand Down Expand Up @@ -603,7 +603,7 @@ describe('carousel', () => {

it('should emit paused and unpaused events when "interval" changed to 0', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0
}
Expand Down Expand Up @@ -682,7 +682,7 @@ describe('carousel', () => {

it('should scroll to specified slide when value (v-model) changed', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
value: 0
Expand Down Expand Up @@ -761,7 +761,7 @@ describe('carousel', () => {

it('changing slides works when "no-animation" set', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
noAnimation: true
Expand Down Expand Up @@ -825,7 +825,7 @@ describe('carousel', () => {

it('setting new slide when sliding is active, schedules the new slide to happen after finished', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0
}
Expand Down Expand Up @@ -902,7 +902,7 @@ describe('carousel', () => {

it('next/prev slide wraps to end/start when "no-wrap is "false"', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
noAnimation: true,
Expand Down Expand Up @@ -967,7 +967,7 @@ describe('carousel', () => {

it('next/prev slide does not wrap to end/start when "no-wrap" is "true"', async () => {
const wrapper = mount(App, {
attachTo: createContainer(),
attachTo: document.body,
propsData: {
interval: 0,
// Transitions (or fallback timers) are not used when no-animation set
Expand Down
Loading

0 comments on commit d113cc7

Please sign in to comment.