diff --git a/javascripts/src/components/registration_page/NonprofitInfoPanel.spec.tsx b/javascripts/src/components/registration_page/NonprofitInfoPanel.spec.tsx new file mode 100644 index 00000000..4a07baf4 --- /dev/null +++ b/javascripts/src/components/registration_page/NonprofitInfoPanel.spec.tsx @@ -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( ) + 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() + // 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()) + // }) +}) \ No newline at end of file diff --git a/javascripts/src/components/registration_page/UserInfoPanel.spec.tsx b/javascripts/src/components/registration_page/UserInfoPanel.spec.tsx new file mode 100644 index 00000000..017ba172 --- /dev/null +++ b/javascripts/src/components/registration_page/UserInfoPanel.spec.tsx @@ -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( ) + 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() + // 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()) + // }) +}) \ No newline at end of file diff --git a/javascripts/src/components/registration_page/__snapshots__/NonprofitInfoPanel.spec.tsx.snap b/javascripts/src/components/registration_page/__snapshots__/NonprofitInfoPanel.spec.tsx.snap new file mode 100644 index 00000000..83314dae --- /dev/null +++ b/javascripts/src/components/registration_page/__snapshots__/NonprofitInfoPanel.spec.tsx.snap @@ -0,0 +1,1534 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`NonprofitInfoPanel includes correct elements and attributes 1`] = ` + + + +`; diff --git a/javascripts/src/components/registration_page/__snapshots__/UserInfoPanel.spec.tsx.snap b/javascripts/src/components/registration_page/__snapshots__/UserInfoPanel.spec.tsx.snap new file mode 100644 index 00000000..5d5067bd --- /dev/null +++ b/javascripts/src/components/registration_page/__snapshots__/UserInfoPanel.spec.tsx.snap @@ -0,0 +1,1534 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`UserInfoPanel includes correct elements and attributes 1`] = ` + + + +`;