-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from 14nrv/dev
Merge Dev
- Loading branch information
Showing
8 changed files
with
109 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import matchers from 'jest-vue-matcher' | ||
import { mount } from '@vue/test-utils' | ||
import Label from '@/components/Fields/Label' | ||
|
||
const LABEL = 'the label' | ||
let wrapper | ||
|
||
describe('Label', () => { | ||
beforeEach(() => { | ||
wrapper = mount(Label, { | ||
propsData: { | ||
item: { | ||
label: LABEL | ||
} | ||
} | ||
}) | ||
expect.extend(matchers(wrapper)) | ||
}) | ||
|
||
afterEach(() => { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('shows a label', () => { | ||
expect('label').toHaveText(LABEL) | ||
}) | ||
|
||
it('shows an alternative label', async () => { | ||
const ALTERNATIVE_LABEL = 'an alternative label' | ||
|
||
await wrapper.setProps({ | ||
item: { | ||
label: LABEL, | ||
alternativeLabel: ALTERNATIVE_LABEL | ||
} | ||
}) | ||
|
||
expect('label').toHaveText(ALTERNATIVE_LABEL) | ||
expect('label').not.toHaveText(LABEL) | ||
}) | ||
|
||
it('hides the label', async () => { | ||
await wrapper.setProps({ | ||
item: { | ||
label: LABEL, | ||
showLabel: false | ||
} | ||
}) | ||
|
||
expect('label').not.toBeADomElement() | ||
}) | ||
|
||
it('has a for attribute by default', () => { | ||
expect('label').toHaveAttribute('for', 'the-label') | ||
}) | ||
|
||
it('has a custom for attribute', async () => { | ||
const ATTR_FOR = 'a-custom-for-attribute' | ||
|
||
await wrapper.setProps({ | ||
item: { | ||
label: LABEL, | ||
for: ATTR_FOR | ||
} | ||
}) | ||
|
||
expect('label').toHaveAttribute('for', ATTR_FOR) | ||
}) | ||
|
||
it('is mandatory by default', () => { | ||
expect('label').toHaveText('*') | ||
}) | ||
|
||
it('is not mandatory', async () => { | ||
await wrapper.setProps({ | ||
item: { | ||
label: LABEL, | ||
isRequired: false | ||
} | ||
}) | ||
|
||
expect('label').not.toHaveText('*') | ||
}) | ||
}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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