Skip to content

Commit

Permalink
Update tests/unit/utils/isSlotPopulated.spec.js
Browse files Browse the repository at this point in the history
Co-authored-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Raimund Schlüßler <raimund.schluessler+github@mailbox.org>
  • Loading branch information
raimund-schluessler and ShGKme authored Sep 13, 2023
1 parent 8a2295d commit 35d4177
Showing 1 changed file with 42 additions and 64 deletions.
106 changes: 42 additions & 64 deletions tests/unit/utils/isSlotPopulated.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,83 +13,61 @@ const IsSlotPopulatedTest = {
},
}

let wrapper
describe('isSlotPopulated.js', () => {
'use strict'
describe('when default slot contains empty array', () => {
it('shows empty slot', () => {
wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: [],
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
it('is not populated when a slot contains an empty array', () => {
const wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: [],
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
})

describe('when default slot contains empty string', () => {
it('shows empty slot', () => {
wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: '',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
it('is not populated when a slot with an empty string', () => {
const wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: '',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
})

describe('when default slot contains string', () => {
it('shows populated slot', () => {
wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: 'Test',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(true)
it('is populated when a slot contains a string', () => {
const wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: 'Test',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(true)
})

describe('when default slot contains string with whitespace only', () => {
it('shows empty slot', () => {
wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: ' ',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
it('is not populated when a slot contains a string with whitespace only', () => {
const wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: ' ',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
})

describe('when default slot contains array containing string', () => {
it('shows populated slot', () => {
wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: ['Test'],
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(true)
it('is populated when a slot contains an array containing a string', () => {
const wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: ['Test'],
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(true)
})

describe('when default slot contains comment and text', () => {
it('shows populated slot', () => {
wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: '<!-- Commment -->Test',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(true)
it('is populated when a slot contains a comment and a text', () => {
const wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: '<!-- Commment -->Test',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(true)
})

describe('when default slot contains comment only', () => {
it('shows empty slot', () => {
wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: '<!-- Commment -->',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
it('is not populated when a slot contains a comment only', () => {
const wrapper = mount(IsSlotPopulatedTest, {
slots: {
default: '<!-- Commment -->',
},
})
expect(wrapper.vm.isDefaultPopulated).toBe(false)
})
})

0 comments on commit 35d4177

Please sign in to comment.