Skip to content

Commit

Permalink
Merge pull request #24 from kevinkosterr/master
Browse files Browse the repository at this point in the history
Release new version
  • Loading branch information
kevinkosterr authored Dec 17, 2024
2 parents 89086d7 + 7e0b494 commit a3af826
Show file tree
Hide file tree
Showing 80 changed files with 6,745 additions and 6,188 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- run: yarn install --immutable
- run: pnpm install --frozen-lockfile
- name: Running tests
run: yarn run test
run: pnpm run test
- name: Building
run: yarn run build
- name: Running audit
run: yarn audit signatures
run: pnpm run build
- name: Semantic release
run: npx semantic-release
env:
Expand Down
8 changes: 4 additions & 4 deletions __tests__/components/fields/FieldButton.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { mountFormGenerator, generatePropsSingleField } from '@test/_resources/u
import { describe, it, expect } from 'vitest'
import { mount, config } from '@vue/test-utils'

import FieldButton from '@/fields/buttons/FieldButton.vue'
import FieldPassword from '@/fields/input/FieldPassword.vue'
import FieldCheckbox from '@/fields/input/FieldCheckbox.vue'
import FieldButton from '@/fields/core/FieldButton.vue'
import FieldPassword from '@/fields/core/FieldPassword.vue'
import FieldCheckbox from '@/fields/core/FieldCheckbox.vue'

const form = {
model: {
Expand Down Expand Up @@ -40,7 +40,7 @@ const form = {
const props = generatePropsSingleField(form)


describe('Test FieldButton', () => {
describe('FieldButton', () => {

it('Should render correctly', () => {
const wrapper = mount(FieldButton, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldCheckbox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generatePropsSingleField, generateSchemaSingleField, mountFormGenerator
import { describe, it, expect } from 'vitest'
import { mount, config } from '@vue/test-utils'

import FieldCheckbox from '@/fields/input/FieldCheckbox.vue'
import FieldCheckbox from '@/fields/core/FieldCheckbox.vue'

const form = generateSchemaSingleField(
'checkboxTestName',
Expand All @@ -15,7 +15,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldCheckbox', () => {
describe('FieldCheckbox', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldCheckbox, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldColor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mountFormGenerator, generatePropsSingleField, generateSchemaSingleField
import { mount, config } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'

import FieldColor from '@/fields/input/FieldColor.vue'
import FieldColor from '@/fields/core/FieldColor.vue'

const form = generateSchemaSingleField(
'testColor',
Expand All @@ -15,7 +15,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldColor', () => {
describe('FieldColor', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldColor, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldNumber.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest'
import { mountFormGenerator, generatePropsSingleField, generateSchemaSingleField } from '@test/_resources/utils.js'
import { mount, config } from '@vue/test-utils'

import FieldNumber from '@/fields/input/FieldNumber.vue'
import FieldNumber from '@/fields/core/FieldNumber.vue'

const form = generateSchemaSingleField(
'testNumber',
Expand All @@ -19,7 +19,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldNumber', () => {
describe('FieldNumber', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldNumber, { props })
Expand Down
6 changes: 4 additions & 2 deletions __tests__/components/fields/FieldPassword.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { mountFormGenerator, generateSchemaSingleField, generatePropsSingleField } from '@test/_resources/utils.js'
import { describe, it, expect } from 'vitest'
import { mount, config } from '@vue/test-utils'
import validators from '@/validators'

import FieldPassword from '@/fields/input/FieldPassword.vue'
import FieldPassword from '@/fields/core/FieldPassword.vue'

const form = generateSchemaSingleField(
'passwordTest',
Expand All @@ -20,7 +21,7 @@ const propsWithIndicator = {
field: { ...props.field, indicator: true }
}

describe('Test FieldPassword', () => {
describe('FieldPassword', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldPassword, { props })
Expand Down Expand Up @@ -101,6 +102,7 @@ describe('Test FieldPassword', () => {

it('Should give an error when required and empty', async () => {
const fieldProps = { ...props, field: { ...props.field, required: true } }
fieldProps.field.validator = [ validators.required ]
const wrapper = mount(FieldPassword, { props: fieldProps })

const input = wrapper.find('input[type=password]')
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldRadio.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mountFormGenerator, generatePropsSingleField, generateSchemaSingleField
import { describe, it, expect } from 'vitest'
import { mount, config } from '@vue/test-utils'

import FieldRadio from '@/fields/input/FieldRadio.vue'
import FieldRadio from '@/fields/core/FieldRadio.vue'

const form = generateSchemaSingleField(
'radioTest',
Expand Down Expand Up @@ -36,7 +36,7 @@ const checkRadioInputs = (radioInputs, wrapper) => {
}
}

describe('Test FieldRadio', () => {
describe('FieldRadio', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldRadio, { props })
Expand Down
8 changes: 4 additions & 4 deletions __tests__/components/fields/FieldReset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { mountFormGenerator } from '@test/_resources/utils.js'
import { describe, it, expect } from 'vitest'
import { mount, config } from '@vue/test-utils'

import FieldReset from '@/fields/buttons/FieldReset.vue'
import FieldCheckbox from '@/fields/input/FieldCheckbox.vue'
import FieldPassword from '@/fields/input/FieldPassword.vue'
import FieldReset from '@/fields/core/FieldReset.vue'
import FieldCheckbox from '@/fields/core/FieldCheckbox.vue'
import FieldPassword from '@/fields/core/FieldPassword.vue'

const form = {
model: {
Expand Down Expand Up @@ -41,7 +41,7 @@ const props = {
model: { ...form.model }
}

describe('Test FieldReset', () => {
describe('FieldReset', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldReset, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldSelect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generateSchemaSingleField, generatePropsSingleField, mountFormGenerator
import { mount, config } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'

import FieldSelect from '@/fields/input/FieldSelect.vue'
import FieldSelect from '@/fields/core/FieldSelect.vue'

const form = generateSchemaSingleField(
'testSelect',
Expand All @@ -23,7 +23,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldSelect', () => {
describe('FieldSelect', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldSelect, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldSelectNative.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generateSchemaSingleField, generatePropsSingleField, mountFormGenerator
import { mount, config } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'

import FieldSelect from '@/fields/input/FieldSelectNative.vue'
import FieldSelect from '@/fields/core/FieldSelectNative.vue'

const form = generateSchemaSingleField(
'testSelect',
Expand All @@ -23,7 +23,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldSelectNative', () => {
describe('FieldSelectNative', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldSelect, { props })
Expand Down
8 changes: 4 additions & 4 deletions __tests__/components/fields/FieldSubmit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { mountFormGenerator } from '@test/_resources/utils.js'
import { describe, it, expect } from 'vitest'
import { mount, config } from '@vue/test-utils'

import FieldCheckbox from '@/fields/input/FieldCheckbox.vue'
import FieldPassword from '@/fields/input/FieldPassword.vue'
import FieldSubmit from '@/fields/buttons/FieldSubmit.vue'
import FieldCheckbox from '@/fields/core/FieldCheckbox.vue'
import FieldPassword from '@/fields/core/FieldPassword.vue'
import FieldSubmit from '@/fields/core/FieldSubmit.vue'

const form = {
model: {
Expand Down Expand Up @@ -41,7 +41,7 @@ const props = {
model: { ...form.model }
}

describe('Test FieldSubmit', () => {
describe('FieldSubmit', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldSubmit, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldSwitch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generatePropsSingleField, generateSchemaSingleField, mountFormGenerator
import { describe, it, expect } from 'vitest'
import { mount, config } from '@vue/test-utils'

import FieldSwitch from '@/fields/input/FieldSwitch.vue'
import FieldSwitch from '@/fields/core/FieldSwitch.vue'

const form = generateSchemaSingleField(
'switchTest',
Expand All @@ -15,7 +15,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldSwitch', () => {
describe('FieldSwitch', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldSwitch, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldText.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generateSchemaSingleField, generatePropsSingleField, mountFormGenerator
import { mount, config } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'

import FieldText from '@/fields/input/FieldText.vue'
import FieldText from '@/fields/core/FieldText.vue'

const form = generateSchemaSingleField(
'textTest',
Expand All @@ -18,7 +18,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldText', () => {
describe('FieldText', () => {

it('Should render correctly', async () => {
const wrapper = mount(FieldText, { props })
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/fields/FieldTextarea.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generateSchemaSingleField, generatePropsSingleField, mountFormGenerator
import { mount, config } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'

import FieldTextarea from '@/fields/input/FieldTextarea.vue'
import FieldTextarea from '@/fields/core/FieldTextarea.vue'

const form = generateSchemaSingleField(
'textTest',
Expand All @@ -18,7 +18,7 @@ const form = generateSchemaSingleField(

const props = generatePropsSingleField(form)

describe('Test FieldTextarea', () => {
describe('FieldTextarea', () => {

it('Should render correctly', () => {
const wrapper = mount(FieldTextarea, { props })
Expand Down
88 changes: 88 additions & 0 deletions __tests__/composables/useFieldAttributes.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { describe, it, expect } from 'vitest'
import { useFieldAttributes } from '@/composables/useFieldAttributes'
import { ref } from 'vue'

const attributeAllSchema = (setValue) => {
return {
model: { password: '' },
fields: [
{
name: 'Password',
label: 'Password',
required: setValue,
disabled: setValue,
visible: setValue,
readonly: setValue,
model: 'password',
hint: 'This is a password'
}
]
}
}

const schemaAllTrueBool = attributeAllSchema(true)
const schemaAllFalseBool = attributeAllSchema(false)
const schemaAllTrueFn = attributeAllSchema((model, _field) => model.password === '')
const schemaAllFalseFn = attributeAllSchema((model, _field) => model.password !== '')

describe('useFieldAttributes', () => {

it('Attributes should attest to true, set by boolean', () => {
const attributes = useFieldAttributes(schemaAllTrueBool.model, schemaAllTrueBool.fields[0])
expect(attributes.isRequired.value).toBe(true)
expect(attributes.isDisabled.value).toBe(true)
expect(attributes.isVisible.value).toBe(true)
expect(attributes.isReadonly.value).toBe(true)
})

it('Attributes should attest to false, set by boolean', () => {
const attributes = useFieldAttributes(schemaAllFalseBool.model, schemaAllFalseBool.fields[0])
expect(attributes.isRequired.value).toBe(false)
expect(attributes.isDisabled.value).toBe(false)
expect(attributes.isVisible.value).toBe(false)
expect(attributes.isReadonly.value).toBe(false)
})

it('Attributes should attest to true, set by function', () => {
const attributes = useFieldAttributes(schemaAllTrueFn.model, schemaAllTrueFn.fields[0])
expect(attributes.isRequired.value).toBe(true)
expect(attributes.isDisabled.value).toBe(true)
expect(attributes.isVisible.value).toBe(true)
expect(attributes.isReadonly.value).toBe(true)
})

it('Attributes should attest to false, set by function', () => {
const attributes = useFieldAttributes(schemaAllFalseFn.model, schemaAllFalseFn.fields[0])
expect(attributes.isRequired.value).toBe(false)
expect(attributes.isDisabled.value).toBe(false)
expect(attributes.isVisible.value).toBe(false)
expect(attributes.isReadonly.value).toBe(false)
})

it('Hint should be set accordingly, by string', () => {
const attributes = useFieldAttributes(schemaAllTrueBool.model, schemaAllFalseBool.fields[0])
expect(attributes.hint.value).toBe('This is a password')
})

it('Hint should be set accordingly, by function', () => {
const schema = { ...schemaAllTrueBool }
schema.fields[0].hint = (model, field) => field.name + field.label
const attributes = useFieldAttributes(schema.model, schema.fields[0])
expect(attributes.hint.value).toBe('PasswordPassword')
})

it('Should update according to changes in the schema', () => {
const disabledIfPasswordHasValue = (model, _field) => model.password !== ''
const schema = ref({
model: { password: '' },
fields: [
{ name: 'password', label: 'Password', model: 'password', disabled: disabledIfPasswordHasValue }
]
})
const attributes = useFieldAttributes(schema.value.model, schema.value.fields[0])
expect(attributes.isDisabled.value).toBe(false)
schema.value.model.password = 'a'
expect(attributes.isDisabled.value).toBe(true)
})

})
12 changes: 12 additions & 0 deletions __tests__/composables/useFieldEmits.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { describe, it, expect } from 'vitest'
import { useFieldEmits } from '@/composables/useFieldEmits'

describe('useFieldEmits', () => {

it('Should return proper emits', () => {
const emits = useFieldEmits()
expect(emits.includes('onInput')).toBe(true)
expect(emits.includes('validated')).toBe(true)
})

})
17 changes: 17 additions & 0 deletions __tests__/composables/useFieldProps.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, it, expect } from 'vitest'
import { useFieldProps } from '@/composables/useFieldProps'

describe('useFieldProps', () => {

it('Returns the right props', () => {
const props = useFieldProps()
expect(props.id).toBeTruthy()
expect(props.field).toBeTruthy()
expect(props.formGenerator).toBeTruthy()
expect(props.model).toBeTruthy()

// Test for a random value
expect(props.validator).toBeFalsy()
})

})
Loading

0 comments on commit a3af826

Please sign in to comment.