From 35f14ffa46d2bc74a2874125e35da2b15dbc83a3 Mon Sep 17 00:00:00 2001 From: Nick Ford Date: Sun, 27 Sep 2020 13:52:34 -0400 Subject: [PATCH] fix tests --- .../src/components/VueFreezeframe.vue | 2 +- .../tests/unit/example.spec.ts | 12 ------ .../tests/unit/vue-freezeframe.spec.ts | 42 +++++++++++++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) delete mode 100644 packages/vue-freezeframe/tests/unit/example.spec.ts create mode 100644 packages/vue-freezeframe/tests/unit/vue-freezeframe.spec.ts diff --git a/packages/vue-freezeframe/src/components/VueFreezeframe.vue b/packages/vue-freezeframe/src/components/VueFreezeframe.vue index cb8a7d1..78c8382 100644 --- a/packages/vue-freezeframe/src/components/VueFreezeframe.vue +++ b/packages/vue-freezeframe/src/components/VueFreezeframe.vue @@ -22,7 +22,7 @@ export default class VueFreezeframe extends Vue { options?: FreezeframeOptions // data - ready = false + ready = true isPlaying = false $freezeframe?: Freezeframe diff --git a/packages/vue-freezeframe/tests/unit/example.spec.ts b/packages/vue-freezeframe/tests/unit/example.spec.ts deleted file mode 100644 index f2db74a..0000000 --- a/packages/vue-freezeframe/tests/unit/example.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { shallowMount } from '@vue/test-utils' -import HelloWorld from '@/components/HelloWorld.vue' - -describe('HelloWorld.vue', () => { - it('renders props.msg when passed', () => { - const msg = 'new message' - const wrapper = shallowMount(HelloWorld, { - propsData: { msg }, - }) - expect(wrapper.text()).toMatch(msg) - }) -}) diff --git a/packages/vue-freezeframe/tests/unit/vue-freezeframe.spec.ts b/packages/vue-freezeframe/tests/unit/vue-freezeframe.spec.ts new file mode 100644 index 0000000..e637c77 --- /dev/null +++ b/packages/vue-freezeframe/tests/unit/vue-freezeframe.spec.ts @@ -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: [``], + } + }) + 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: [ + `` + ], + } + }) + const imgs = wrapper.findAll('img') + expect(imgs.length).toBe(3) + expect(imgs.at(0).attributes('src')).toEqual(src) + expect(wrapper.classes()).toContain('vue-freezeframe') + }) +})