Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(forms): add support for tooltip-style feedback text (#2188)
* Update form-invalid-feedback.js enable tooltip style invalid feedback * Update form-valid-feedback.js enable tooltip style feedback support * Update form-group.js enable tooltip style feedback support * Update README.md * Update form-invalid-feedback.spec.js * Update form-valid-feedback.spec.js * Delete form-invalid-feedback.html * Delete form-invalid-feedback.js * Delete form-valid-feedback.html * Delete form-valid-feedback.js * Update README.md * lint * Update form-invalid-feedback.spec.js * Update form-valid-feedback.spec.js * Update form-invalid-feedback.spec.js * Update form-invalid-feedback.spec.js * Update form-valid-feedback.spec.js * Update form-invalid-feedback.spec.js needs context for functional components * Update form-valid-feedback.spec.js use context for functional components * Update form-invalid-feedback.spec.js * Update form-invalid-feedback.spec.js * Update form-invalid-feedback.spec.js * Update form-invalid-feedback.spec.js * Update form-invalid-feedback.spec.js * Update form-invalid-feedback.spec.js * Update form-group.js
- Loading branch information
1 parent
5bdc2e6
commit 5203436
Showing
11 changed files
with
183 additions
and
86 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,51 +1,94 @@ | ||
import { loadFixture, testVM } from '../../../tests/utils' | ||
import Feedback from './form-invalid-feedback' | ||
import { mount } from '@vue/test-utils' | ||
|
||
describe('form-invalid-feedback', async () => { | ||
beforeEach(loadFixture(__dirname, 'form-invalid-feedback')) | ||
testVM() | ||
|
||
it('default should have tag div', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default).toBeElement('div') | ||
const feedback = mount(Feedback) | ||
expect(feedback.is('div')).toBe(true) | ||
}) | ||
|
||
it('default should contain base class', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default).toHaveClass('invalid-feedback') | ||
const feedback = mount(Feedback) | ||
expect(feedback.classes()).toContain('invalid-feedback') | ||
}) | ||
|
||
it('default should not have class d-block', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default).not.toHaveClass('d-block') | ||
const feedback = mount(Feedback) | ||
expect(feedback.classes()).not.toContain('d-block') | ||
}) | ||
|
||
it('default should not have class invalid-tooltip', async () => { | ||
const feedback = mount(Feedback) | ||
expect(feedback.classes()).not.toContain('invalid-tooltip') | ||
}) | ||
|
||
it('default should not have id', async () => { | ||
const feedback = mount(Feedback) | ||
expect(feedback.attributes('id')).not.toBeDefined() | ||
}) | ||
|
||
it('default should have id', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default.getAttribute('id')).toBe('default') | ||
it('default should have user supplied id', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
id: 'foobar' | ||
} | ||
} | ||
}) | ||
expect(feedback.attributes('id')).toBe('foobar') | ||
}) | ||
|
||
it('tag should have tag small', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.tag).toBeElement('small') | ||
it('should have tag small when tag=small', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
tag: 'small' | ||
} | ||
} | ||
}) | ||
expect(feedback.is('small')).toBe(true) | ||
}) | ||
|
||
it('tag should contain base class', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.tag).toHaveClass('invalid-feedback') | ||
it('should contain class d-block when force-show is set', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
forceShow: true | ||
} | ||
} | ||
}) | ||
expect(feedback.classes()).toContain('d-block') | ||
}) | ||
|
||
it('show should have tag div', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.show).toBeElement('div') | ||
it('should contain class invalid-tooltip when tooltip is set', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
tooltip: true | ||
} | ||
} | ||
}) | ||
expect(feedback.classes()).toContain('invalid-tooltip') | ||
}) | ||
|
||
it('show should contain base class', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.show).toHaveClass('invalid-feedback') | ||
it('should not contain class invalid-feedback when tooltip is set', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
tooltip: true | ||
} | ||
} | ||
}) | ||
expect(feedback.classes()).not.toContain('invalid-feedback') | ||
}) | ||
|
||
it('show should contain class d-block', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.show).toHaveClass('d-block') | ||
it('should have children in the default slot when supplied', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
children: ['foo', '<span>bar</span>'] | ||
} | ||
}) | ||
expect(feedback.text()).toContain('foo') | ||
expect(feedback.text()).toContain('bar') | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,51 +1,84 @@ | ||
import { loadFixture, testVM } from '../../../tests/utils' | ||
import Feedback from './form-valid-feedback' | ||
import { mount } from '@vue/test-utils' | ||
|
||
describe('form-valid-feedback', async () => { | ||
beforeEach(loadFixture(__dirname, 'form-valid-feedback')) | ||
testVM() | ||
|
||
it('default should have tag div', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default).toBeElement('div') | ||
const feedback = mount(Feedback) | ||
expect(feedback.is('div')).toBe(true) | ||
}) | ||
|
||
it('default should contain base class', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default).toHaveClass('valid-feedback') | ||
const feedback = mount(Feedback) | ||
expect(feedback.classes()).toContain('valid-feedback') | ||
}) | ||
|
||
it('default should not have class d-block', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default).not.toHaveClass('d-block') | ||
const feedback = mount(Feedback) | ||
expect(feedback.classes()).not.toContain('d-block') | ||
}) | ||
|
||
it('default should not have class valid-tooltip', async () => { | ||
const feedback = mount(Feedback) | ||
expect(feedback.classes()).not.toContain('valid-tooltip') | ||
}) | ||
|
||
it('default should have id', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.default.getAttribute('id')).toBe('default') | ||
it('default should not have id', async () => { | ||
const feedback = mount(Feedback) | ||
expect(feedback.attributes('id')).not.toBeDefined() | ||
}) | ||
|
||
it('tag should have tag small', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.tag).toBeElement('small') | ||
it('default should have user supplied id', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
id: 'foobar' | ||
} | ||
} | ||
}) | ||
expect(feedback.attributes('id')).toBe('foobar') | ||
}) | ||
|
||
it('tag should contain base class', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.tag).toHaveClass('valid-feedback') | ||
it('should have tag small when tag=small', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
tag: 'small' | ||
} | ||
} | ||
}) | ||
expect(feedback.is('small')).toBe(true) | ||
}) | ||
|
||
it('show should have tag div', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.show).toBeElement('div') | ||
it('should contain class d-block when force-show is set', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
forceShow: true | ||
} | ||
} | ||
}) | ||
expect(feedback.classes()).toContain('d-block') | ||
}) | ||
|
||
it('show should contain base class', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.show).toHaveClass('valid-feedback') | ||
it('should contain class valid-tooltip when tooltip is set', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
tooltip: true | ||
} | ||
} | ||
}) | ||
expect(feedback.classes()).toContain('valid-tooltip') | ||
}) | ||
|
||
it('show should contain class d-block', async () => { | ||
const { app: { $refs } } = window | ||
expect($refs.show).toHaveClass('d-block') | ||
it('should not contain class alid-feedback when tooltip is set', async () => { | ||
const feedback = mount(Feedback, { | ||
context: { | ||
props: { | ||
tooltip: true | ||
} | ||
} | ||
}) | ||
expect(feedback.classes()).not.toContain('valid-feedback') | ||
}) | ||
}) |