Skip to content

Commit

Permalink
Merge pull request #109 from SFDigitalServices/release-6.3.0
Browse files Browse the repository at this point in the history
Release 6.3.0
  • Loading branch information
shawnbot authored Oct 5, 2020
2 parents 9965ebd + acbddf0 commit 28bd75f
Show file tree
Hide file tree
Showing 31 changed files with 2,970 additions and 644 deletions.
2,154 changes: 2,154 additions & 0 deletions __tests__/__snapshots__/snapshots.js.snap

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions __tests__/snapshots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/* eslint-env jest */
import { createForm, destroyForm } from '../lib/test-helpers'
import '../dist/formio-sfds.standalone.js'

const { FormioUtils } = window

const components = [
{ type: 'address' },
{ type: 'button' },
{ type: 'checkbox' },
{
type: 'columns',
columns: [
{
width: 3,
components: [{ type: 'textfield', key: 'left', label: 'Left' }]
},
{
width: 3,
components: [{ type: 'textfield', key: 'right', label: 'Right' }]
}
]
},
{ type: 'container' },
{ type: 'day' },
{ type: 'datetime' },
{ type: 'html', tag: 'h1', content: 'Hello, world!' },
{ type: 'number' },
{
type: 'radio',
values: [
{ label: 'One', value: 1 },
{ label: 'Two', value: 2 },
{ label: 'Three', value: 3 }
]
},
{
type: 'selectboxes',
values: [
{ label: 'A', value: 'a' },
{ label: 'B', value: 'b' },
{ label: 'C', value: 'c' }
]
},
{ type: 'textfield' },
{
type: 'panel',
components: [
{ type: 'textfield', label: 'Your name' }
]
}
]

describe('component snapshots', () => {
const scenarios = {
basic: {},
required: {
validate: {
required: true
}
}
}

const { getRandomComponentId } = FormioUtils

for (const comp of components) {
describe(`component "${comp.type}"`, () => {
for (const [name, props] of Object.entries(scenarios)) {
describe(`scenario: ${name}`, () => {
it('matches the snapshot', async () => {
let i = 0
FormioUtils.getRandomComponentId = () => `${comp.type}-${name}-${i++}`

const form = await createForm({
components: [
Object.assign(
{
label: `This is the ${comp.type} label`,
description: `This is the ${comp.type} description`
},
comp,
props
)
]
})

form.element.id = `form-${comp.type}-${name}`
const html = form.element.outerHTML
expect(html).toMatchSnapshot()

destroyForm(form)

FormioUtils.getRandomComponentId = getRandomComponentId
})
})
}
})
}
})
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
setupFiles: ['<rootDir>/lib/test-setup.js']
setupFiles: ['<rootDir>/lib/test-setup.js'],
snapshotSerializers: ['jest-serializer-html']
}
Loading

1 comment on commit 28bd75f

@vercel
Copy link

@vercel vercel bot commented on 28bd75f Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.