1.1.0 • Published 4 years ago

@solution5520/s-visual-test v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

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

Preview

Installation

npm i @solution5520/s-visual-test

Importing

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

nametypedefault valuedescription
componentObjectnullLoaded component. Required.
defaultAttrsObjectnullThe default attributes for all the tests except the empty one.
modelString, Section, ObjectnullThe name of the v-model property.
propsString, Section, Object, Arraynew ArrayThe names of the property to test.
eventsString, Section, Object, Arraynew ArrayThe names of events to test.
methodsString, Section, Object, Arraynew ArrayThe names of component's methods to test.
slotsString, Section, Object, Arraynew ArrayThe 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:

namedescription
placeholderTest the placeholder with a simple text and clear v-model.
readonlyTest the readonly property set to true.
disabledTest the disabled property set to true.
s-test--textTest a text property with a small text and a long text.
s-test--color_multipleTest a color property with 3 colors: Red, Green and Blue.
s-test--color_typeTest a color property with the color Magenta but writen differently: with the name, in hex, in rgb and in hsl.
s-test--fa_iconTest 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

nametypedescriptionexemple
nameStringThe name of the property/event/method/slot.'value', 'suffix'
labelStringTitle for this section. If empty show the name instead.'suffix section'
commandStringThe command to define which automatic test to run's-test--text'
testsTest, ArrayAll 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

nametypedescriptionexemple
labelStringSubtitle for this test.'normal', 'disabled'
attrsObjectCustom attributes to apply to the tested component.{disabled: true}
1.1.0

4 years ago

1.0.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.2

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago