Created
April 1, 2020 19:24
-
-
Save iErik/891b98fef561a7ce8449fb95f4e28140 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { shallowMount } from '@vue/test-utils' | |
import FAccordion from './FAccordion' | |
const WRAPPER_PROPS = { title: 'Test' } | |
describe('FAccordion tests', () => { | |
let WRAPPER | |
beforeEach( | |
() => (WRAPPER = shallowMount(FAccordion, { propsData: WRAPPER_PROPS })) | |
) | |
test('Componente existe', () => { | |
expect(WRAPPER.exists()).toBe(true) | |
}) | |
test('Componente não alterado', () => { | |
expect(WRAPPER.html()).toMatchSnapshot() | |
}) | |
describe('Teste de computeds', () => { | |
describe('Computed contentClasses', () => { | |
test('Computed contentClasses quando hideContent: true', () => { | |
WRAPPER.setData({ hideContent: true }) | |
const expectData = [ | |
'BasicAccordion__content', | |
{ | |
'BasicAccordion__content--hidden': true | |
} | |
] | |
expect(WRAPPER.vm.contentClasses).toStrictEqual(expectData) | |
}) | |
test('Computed contentClasses quando hideContent: false', () => { | |
WRAPPER.setData({ hideContent: false }) | |
const expectData = [ | |
'BasicAccordion__content', | |
{ | |
'BasicAccordion__content--hidden': false | |
} | |
] | |
expect(WRAPPER.vm.contentClasses).toStrictEqual(expectData) | |
}) | |
}) | |
describe('Computed iconClasses', () => { | |
test('Computed iconClasses quando hideContent: true', () => { | |
WRAPPER.setData({ hideContent: true }) | |
const expectData = [ | |
'BasicAccordion__header__icon', | |
{ | |
'BasicAccordion__header__icon--rotate': true | |
} | |
] | |
expect(WRAPPER.vm.iconClasses).toStrictEqual(expectData) | |
}) | |
test('Computed iconClasses quando hideContent: false', () => { | |
WRAPPER.setData({ hideContent: false }) | |
const expectData = [ | |
'BasicAccordion__header__icon', | |
{ | |
'BasicAccordion__header__icon--rotate': false | |
} | |
] | |
expect(WRAPPER.vm.iconClasses).toStrictEqual(expectData) | |
}) | |
}) | |
}) | |
describe('Teste de métodos', () => { | |
test('Método toggleContent', () => { | |
expect(WRAPPER.vm.hideContent).toBe(false) | |
WRAPPER.vm.toggleContent() | |
expect(WRAPPER.vm.hideContent).toBe(true) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment