it('should allow for default functions to be ignored', function () {

        const Injected     = injector.inject(Target2Test, propTypes);
        const valueManager = ValueManager({ 'other': 'stuff', more: 'd' });
        const inst         = intoWithContext(<Injected path="hello"/>, {
            valueManager

        }, true);

        const et = byComponent(inst, Target2Test);
        expect(et.prop('onChange')).to.not
                                   .eql(Target2Test.defaultProps.onChange);

    });
Example #2
0
    it('should set dataType', function () {
        class TargetTest extends Component {
            render() {
                return <span>{this.props.type}</span>
            }
        }
        const Injected = injector.inject(TargetTest, propTypes, defaultProps);
        const inst = intoWithContext(<Injected />, {}, true);

        const et = byComponent(inst, TargetTest);
        const node = findNode(et);
        expect(et.props.type).toBe('text');

    });
Example #3
0
    it('should follow change lifecyle', function () {
        const Injected = injector.inject(TargetTest, propTypes, defaultProps);
        const valueManager = ValueManager({'other': 'stuff', more: 'd'});
        const inst = intoWithContext(<Injected path="hello"/>, {
            valueManager

        }, true);

        const et = byComponent(inst, TargetTest);
        const node = findNode(et);
        expect(et.props.type).toBe('text');
        change(et, 'world');
        expect(valueManager.path('hello')).toBe('world');
    });
Example #4
0
    it('should set dataType by defaultProps overrider by component with overrides with defaults and configs', function () {
        class TargetTest extends Component {
            static propTypes = propTypes;

            render() {
                return <span>{this.props.type}</span>
            }
        }
        const Injected = injector.inject(TargetTest, propTypes, {dataType: 'other'});
        const inst = intoWithContext(<Injected/>, {}, true);

        const et = byComponent(inst, TargetTest);
        expect(et.props.type).toBe('other');

    });
Example #5
0
    it('should set dataType by defaultProps overrider by component', function () {
        class TargetTest extends Component {
            static propTypes = propTypes;
            static defaultProps = defaultProps;

            render() {
                return <span>{this.props.type}</span>
            }
        }
        const Injected = injector.inject(TargetTest);
        const inst = intoWithContext(<Injected dataType="stuff"/>, {}, true);

        const et = byComponent(inst, TargetTest);
        expect(et.props.type).toBe('stuff');

    });
        function () {

            const Injected     = injector.inject(Target2Test, propTypes);
            const valueManager = ValueManager({ 'other': 'stuff', more: 'd' });
            const f            = () => {
            };
            const inst         = intoWithContext(<Injected path="hello"
                                                           onChange={f}/>, {
                valueManager

            }, true);

            const et = byComponent(inst, Target2Test);
            expect(et.prop('onChange')).to.eql(f);

        });
Example #7
0
    it('should set type and not have dataType', function () {
        class TargetTest extends Component {
            render() {
                return <span>{this.props.type}</span>
            }
        }
        const Injected = injector.inject(TargetTest, {
            someType: PropTypes.dataType
        }, defaultProps);
        const inst = intoWithContext(<Injected someType="text"/>, {}, true);

        const et = byComponent(inst, TargetTest);
        const node = findNode(et);
        expect(et.props.type).toBe('text');
        expect(et.props.someType).toNotExist('dataType should not be passed');

    });
Example #8
0
    it('should render legacy components', function () {
        const Subschema = newSubschemaContext();
        const {loader} = Subschema;
        loader.addType({Legacy});

        const form = into(<Form value={ {name:'Hello'} } schema={{
            legacy:{
                type:"Legacy",
                expression:"{name}"
            }
        }} loader={loader}/>);
        expect(form).toExist();
        const legacy = byComponent(form, Legacy);
        const dom = findNode(legacy);
        expect(dom.innerHTML).toBe('Hello');

    })
 it('should load default className with stuff', function () {
     loader.addStyle({
         Some                : {
             more: 'ghi'
         },
         Global              : {
             found: 'here'
         },
         TestContainerDefault: {
             whatever: 'the hell'
         }
     });
     const Injected = injector.inject(TestContainerDefault);
     const inst     = byComponent(
         intoWithContext(<Injected />, {loader,injector}, true),
         TestContainerDefault);
     expect(inst.prop('className')).to.eql('the hell ghi here missing');
 })
Example #10
0
    it('should inject default type and template', function () {
        const Subschema = newSubschemaContext();
        const {loader, injector} = Subschema;
        const Wrap = injector.inject(ResolverFieldTest);

        const valueManager = ValueManager();

        const inst = intoWithContext(<Wrap/>, {
            valueManager,
            loader,
            injector
        }, true, PropTypes.contextTypes)

        const test = byComponent(inst, ResolverFieldTest);
        const f = test.props.field;
        expect(f.template.Template.displayName).toMatch(/EditorTemplate\$Wrapper/);
        expect(f.Type.displayName).toMatch(/Text\$Wrapper/);

    });
Example #11
0
    it('should create a new form with a wizard and stuff', function (done) {
        const { Form, loader, valueManager } = newContext();

        function onSubmit(...args) {
            done();
        }

        const root   = into(<Form template="WizardTemplate" loader={loader}
                                  valueManager={valueManager}
                                  onSubmit={onSubmit} schema={{
            schema   : {
                c1: {
                    type      : 'Checkbox',
                    validators: ['required']
                },
                c2: {
                    type      : 'Checkbox',
                    validators: ['required']
                },
            },
            fieldsets: [{
                legend: "C1",
                fields: "c1"
            }, {
                legend: "C2",
                fields: "c2"
            }]
        }}/>, true);
        let template = byComponent(root, WizardTemplate);
        expect(template, 'should have the template').to.have.length(1);
        click(template.find('button'));
        check(template.find('input[type="checkbox"]'), true);
        click(template.find('button'));
        setTimeout(function () {
            check(root.find('input[type="checkbox"]'), true);
            click(root.find('button').at(0));
            done();
        }, 1000);
        //  click(byTags(template, 'button')[1]);
        //  click(byTag(template, 'input'));


    });
Example #12
0
 const checkbox = (checked = true) => check(
     byComponent(form, Checkbox), checked);
Example #13
0
 const text     = (value) => change(byComponent(form, Text), value);