You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.8 KiB
62 lines
1.8 KiB
/* eslint-disable */
|
|
/**
|
|
* @jest-environment jsdom
|
|
*/
|
|
|
|
import { mount, createLocalVue, shallowMount } from '@vue/test-utils'
|
|
import QBUTTON from './demo/QBtn-demo.vue'
|
|
import * as All from 'quasar'
|
|
// import langEn from 'quasar/lang/en-us' // change to any language you wish! => this breaks wallaby :(
|
|
const { Quasar, date } = All
|
|
|
|
const components = Object.keys(All).reduce((object, key) => {
|
|
const val = All[key]
|
|
if (val && val.component && val.component.name != null) {
|
|
object[key] = val
|
|
}
|
|
return object
|
|
}, {})
|
|
|
|
describe('Mount Quasar', () => {
|
|
const localVue = createLocalVue()
|
|
localVue.use(Quasar, { components }) // , lang: langEn
|
|
|
|
const wrapper = mount(QBUTTON, {
|
|
localVue
|
|
})
|
|
const vm = wrapper.vm
|
|
|
|
it('passes the sanity check and creates a wrapper', () => {
|
|
expect(wrapper.isVueInstance()).toBe(true)
|
|
})
|
|
|
|
it('has a created hook', () => {
|
|
expect(typeof vm.increment).toBe('function')
|
|
})
|
|
|
|
it('accesses the shallowMount', () => {
|
|
expect(vm.$el.textContent).toContain('rocket muffin')
|
|
expect(wrapper.text()).toContain('rocket muffin') // easier
|
|
expect(wrapper.find('p').text()).toContain('rocket muffin')
|
|
})
|
|
|
|
it('sets the correct default data', () => {
|
|
expect(typeof vm.counter).toBe('number')
|
|
const defaultData2 = QBUTTON.data()
|
|
expect(defaultData2.counter).toBe(0)
|
|
})
|
|
|
|
it('correctly updates data when button is pressed', () => {
|
|
const button = wrapper.find('button')
|
|
button.trigger('click')
|
|
expect(vm.counter).toBe(1)
|
|
})
|
|
|
|
it('formats a date without throwing exception', () => {
|
|
// test will automatically fail if an exception is thrown
|
|
// MMMM and MMM require that a language is 'installed' in Quasar
|
|
let formattedString = date.formatDate(Date.now(), 'YYYY MMMM MMM DD')
|
|
console.log('formattedString', formattedString)
|
|
})
|
|
})
|