Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickforddev committed Sep 27, 2020
1 parent ce161a2 commit 35f14ff
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/vue-freezeframe/src/components/VueFreezeframe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class VueFreezeframe extends Vue {
options?: FreezeframeOptions
// data
ready = false
ready = true
isPlaying = false
$freezeframe?: Freezeframe
Expand Down
12 changes: 0 additions & 12 deletions packages/vue-freezeframe/tests/unit/example.spec.ts

This file was deleted.

42 changes: 42 additions & 0 deletions packages/vue-freezeframe/tests/unit/vue-freezeframe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { shallowMount } from '@vue/test-utils'
import VueFreezeframe from '@/components/VueFreezeframe.vue'

const src = 'http://localhost:8080/foo.gif'

describe('VueFreezeframe.vue', () => {
it('renders image when url is passed into src prop', () => {
const wrapper = shallowMount(VueFreezeframe, {
propsData: { src },
})
const img = wrapper.find('img')
expect(img.exists()).toBe(true)
expect(img.attributes('src')).toEqual(src)
expect(wrapper.classes()).toContain('vue-freezeframe')
})

it('renders image when img is passed into default slot', () => {
const wrapper = shallowMount(VueFreezeframe, {
slots: {
default: [`<img src="${src}" />`],
}
})
const img = wrapper.find('img')
expect(img.exists()).toBe(true)
expect(img.attributes('src')).toEqual(src)
expect(wrapper.classes()).toContain('vue-freezeframe')
})

it('renders images when multiple imgs are passed into default slot', () => {
const wrapper = shallowMount(VueFreezeframe, {
slots: {
default: [
`<img src="${src}" /><img src="${src}" /><img src="${src}" />`
],
}
})
const imgs = wrapper.findAll('img')
expect(imgs.length).toBe(3)
expect(imgs.at(0).attributes('src')).toEqual(src)
expect(wrapper.classes()).toContain('vue-freezeframe')
})
})

0 comments on commit 35f14ff

Please sign in to comment.