1.1.0 • Published 5 years ago
@solution5520/s-visual-test v1.1.0
s-visual-test
Helper component to test if the visual of a specific components look well with different property values, it's also test specified events and methods

Installation
npm i @solution5520/s-visual-testImporting
Css style
In main.js:
import '@solution5520/s-visual-test/dist/s-visual-test.css'Locally
Install per component as needed
import VisualTest from "@solution5520/s-visual-test"
export default {
components: { VisualTest },
// ... rest of component config
}import {VisualTest, Section, Test} from "@solution5520/s-visual-test"
export default {
components: { VisualTest },
data() {
return {
props: [
new Section('value', 'value section',[
new Test(),
new Test('with text', {
value: 'some text'
})
])
]
}
}
// ... rest of component config
}Usage
With all options
In template:
<template>
<VisualTest
:component="component"
:defaultAttrs="defaultAttrs"
:props="props"
:events="events"
:methods="methods"
:slots="slots"
/>
</template>In script:
import {VisualTest, Section, Test} from "@solution5520/s-visual-test"
import CustomInput from "@/components/CustomInput.vue";
export default {
components: {
VisualTest
},
data() {
return {
component: CustomInput,
defaultAttrs: {
value: "some text",
class: "shadow",
inputClass: "form-control"
},
props: [
new Section("value", "s-test--text"),
new Section("inputClass", "input class", [
new Test("color", {
inputClass: "text-info"
}),
new Test("form & color", {
inputClass: "form-control text-info"
})
]),
"readonly"
]
events: ["input", "change"],
methods: ["focus"],
slots: ["", "error"]
};
}
};Section and Test classes are used to define custom attributes.
Props
| name | type | default value | description |
|---|---|---|---|
| component | Object | null | Loaded component. Required. |
| defaultAttrs | Object | null | The default attributes for all the tests except the empty one. |
| model | String, Section, Object | null | The name of the v-model property. |
| props | String, Section, Object, Array | new Array | The names of the property to test. |
| events | String, Section, Object, Array | new Array | The names of events to test. |
| methods | String, Section, Object, Array | new Array | The names of component's methods to test. |
| slots | String, Section, Object, Array | new Array | The names of the slots. A simple <div> is inserted there. "" is for default slot. |
Automatic testing
If you define the name, use one of the command as the label and you don't specify custom test, it will generate the tests for you.
Usage
props = {
"placeholder",
new Section("value", "s-test--text"),
{
label: "s-test--fa_icon",
name: "icon"
}
}Availables commands:
| name | description |
|---|---|
placeholder | Test the placeholder with a simple text and clear v-model. |
readonly | Test the readonly property set to true. |
disabled | Test the disabled property set to true. |
s-test--text | Test a text property with a small text and a long text. |
s-test--color_multiple | Test a color property with 3 colors: Red, Green and Blue. |
s-test--color_type | Test a color property with the color Magenta but writen differently: with the name, in hex, in rgb and in hsl. |
s-test--fa_icon | Test a icon property with the name of the fa-icon and with an array to define the style: "search" and ["fas", "search"]. |
SectionClass
Usage
new Section('readonly')
new Section("value", "s-test--text"),
new Section('prefix', new Test())
new Section('suffix', 'suffix section')
new Section('icon', 'icon tests', [
new Test(),
new Test()
])Props
| name | type | description | exemple |
|---|---|---|---|
| name | String | The name of the property/event/method/slot. | 'value', 'suffix' |
| label | String | Title for this section. If empty show the name instead. | 'suffix section' |
| command | String | The command to define which automatic test to run | 's-test--text' |
| tests | Test, Array | All tests for this section. Accept Test like Object. | new Test('disabled') |
Overloads
new Section(name)
new Section(name, label)
new Section(name, command)
new Section(name, test)
new Section(name, tests)
new Section(name, label, command)
new Section(name, label, tests)
new Section(tests)TestClass
Usage
new Test('disabled')
new Test('disabled', {
disabled: true
})Props
| name | type | description | exemple |
|---|---|---|---|
| label | String | Subtitle for this test. | 'normal', 'disabled' |
| attrs | Object | Custom attributes to apply to the tested component. | {disabled: true} |