Add tests to verify the basics of the panels are there
This commit is contained in:
parent
18d43b6258
commit
ab9e4f0e8a
4 changed files with 3229 additions and 0 deletions
|
@ -0,0 +1,81 @@
|
||||||
|
// License: LGPL-3.0-or-later
|
||||||
|
import * as React from 'react';
|
||||||
|
import 'jest';
|
||||||
|
|
||||||
|
|
||||||
|
import {Field, FieldDefinition, Form} from "mobx-react-form";
|
||||||
|
|
||||||
|
import {mountWithIntl, shallowWithIntl} from "../../lib/tests/helpers";
|
||||||
|
import {HoudiniForm} from "../../lib/houdini_form";
|
||||||
|
import {WizardState, WizardTabPanelState} from "../common/wizard/wizard_state";
|
||||||
|
|
||||||
|
import toJson from 'enzyme-to-json';
|
||||||
|
import NonprofitInfoPanel from "./NonprofitInfoPanel";
|
||||||
|
|
||||||
|
|
||||||
|
class EasyWizardState extends WizardState{
|
||||||
|
createForm(i: any): Form {
|
||||||
|
return new HoudiniForm(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe('NonprofitInfoPanel', () => {
|
||||||
|
|
||||||
|
|
||||||
|
let wiz:WizardState
|
||||||
|
test('includes correct elements and attributes', () => {
|
||||||
|
wiz = new EasyWizardState()
|
||||||
|
wiz.addTab('tab1', "label", {})
|
||||||
|
wiz.initialize()
|
||||||
|
|
||||||
|
let root = shallowWithIntl(<NonprofitInfoPanel buttonText={"Text"} tab={wiz.activeTab}/> )
|
||||||
|
expect(toJson(root)).toMatchSnapshot()
|
||||||
|
|
||||||
|
})
|
||||||
|
// beforeEach(() => {
|
||||||
|
// outerForm = new HoudiniForm({fields: createSubFormInitialization('none', NIF.FieldDefinitions)}, {
|
||||||
|
// validateOnInit: true,
|
||||||
|
// validateOnChange: true,
|
||||||
|
// retrieveOnlyDirtyValues: true,
|
||||||
|
// retrieveOnlyEnabledFields: true
|
||||||
|
// });
|
||||||
|
// form = outerForm.$('none')
|
||||||
|
// })
|
||||||
|
// afterEach(() => {
|
||||||
|
// wrapper.detach();
|
||||||
|
// })
|
||||||
|
// test('validations', async () => {
|
||||||
|
// wrapper = mountWithIntl(<NonprofitInfoForm form={form} buttonText={"none.none"}/>)
|
||||||
|
// let organization_name = form.$('organization_name')
|
||||||
|
// let city = form.$('city')
|
||||||
|
// let state = form.$('state')
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// //await organization_name.validate()
|
||||||
|
// }
|
||||||
|
// catch(e){
|
||||||
|
// console.log(e)
|
||||||
|
// }
|
||||||
|
// wrapper.find(`#${organization_name.id}`).simulate('focus')
|
||||||
|
// wrapper.find(`#${organization_name.id}`).simulate('blur')
|
||||||
|
// wrapper.find(`#${state.id}`).simulate('click')
|
||||||
|
// organization_name.focus()
|
||||||
|
// state.focus()
|
||||||
|
//
|
||||||
|
// //jest.runTimersToTime(100000);
|
||||||
|
// try {
|
||||||
|
// await organization_name.validate()
|
||||||
|
// }
|
||||||
|
// catch(e){
|
||||||
|
// console.log(e)
|
||||||
|
// }
|
||||||
|
// expect(organization_name.error).toBe(false)
|
||||||
|
// expect(state.hasError).toBe(true)
|
||||||
|
// expect(city.hasError).toBe(true)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// console.log(wrapper.html())
|
||||||
|
// })
|
||||||
|
})
|
|
@ -0,0 +1,80 @@
|
||||||
|
// License: LGPL-3.0-or-later
|
||||||
|
import * as React from 'react';
|
||||||
|
import 'jest';
|
||||||
|
|
||||||
|
|
||||||
|
import {Field, FieldDefinition, Form} from "mobx-react-form";
|
||||||
|
|
||||||
|
import {mountWithIntl, shallowWithIntl} from "../../lib/tests/helpers";
|
||||||
|
import {HoudiniForm} from "../../lib/houdini_form";
|
||||||
|
import {WizardState, WizardTabPanelState} from "../common/wizard/wizard_state";
|
||||||
|
import UserInfoPanel from "./UserInfoPanel";
|
||||||
|
import toJson from 'enzyme-to-json';
|
||||||
|
|
||||||
|
|
||||||
|
class EasyWizardState extends WizardState{
|
||||||
|
createForm(i: any): Form {
|
||||||
|
return new HoudiniForm(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
describe('UserInfoPanel', () => {
|
||||||
|
|
||||||
|
|
||||||
|
let wiz:WizardState
|
||||||
|
test('includes correct elements and attributes', () => {
|
||||||
|
wiz = new EasyWizardState()
|
||||||
|
wiz.addTab('tab1', "label", {})
|
||||||
|
wiz.initialize()
|
||||||
|
|
||||||
|
let root = shallowWithIntl(<UserInfoPanel buttonText={"Text"} tab={wiz.activeTab}/> )
|
||||||
|
expect(toJson(root)).toMatchSnapshot()
|
||||||
|
|
||||||
|
})
|
||||||
|
// beforeEach(() => {
|
||||||
|
// outerForm = new HoudiniForm({fields: createSubFormInitialization('none', NIF.FieldDefinitions)}, {
|
||||||
|
// validateOnInit: true,
|
||||||
|
// validateOnChange: true,
|
||||||
|
// retrieveOnlyDirtyValues: true,
|
||||||
|
// retrieveOnlyEnabledFields: true
|
||||||
|
// });
|
||||||
|
// form = outerForm.$('none')
|
||||||
|
// })
|
||||||
|
// afterEach(() => {
|
||||||
|
// wrapper.detach();
|
||||||
|
// })
|
||||||
|
// test('validations', async () => {
|
||||||
|
// wrapper = mountWithIntl(<NonprofitInfoForm form={form} buttonText={"none.none"}/>)
|
||||||
|
// let organization_name = form.$('organization_name')
|
||||||
|
// let city = form.$('city')
|
||||||
|
// let state = form.$('state')
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// //await organization_name.validate()
|
||||||
|
// }
|
||||||
|
// catch(e){
|
||||||
|
// console.log(e)
|
||||||
|
// }
|
||||||
|
// wrapper.find(`#${organization_name.id}`).simulate('focus')
|
||||||
|
// wrapper.find(`#${organization_name.id}`).simulate('blur')
|
||||||
|
// wrapper.find(`#${state.id}`).simulate('click')
|
||||||
|
// organization_name.focus()
|
||||||
|
// state.focus()
|
||||||
|
//
|
||||||
|
// //jest.runTimersToTime(100000);
|
||||||
|
// try {
|
||||||
|
// await organization_name.validate()
|
||||||
|
// }
|
||||||
|
// catch(e){
|
||||||
|
// console.log(e)
|
||||||
|
// }
|
||||||
|
// expect(organization_name.error).toBe(false)
|
||||||
|
// expect(state.hasError).toBe(true)
|
||||||
|
// expect(city.hasError).toBe(true)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// console.log(wrapper.html())
|
||||||
|
// })
|
||||||
|
})
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue