/** @jsx builder */ import builder, {Block} from '../src'; import compiler from 'canner-compiler'; import serializer from './serializer'; expect.addSnapshotSerializer(serializer); const {Traverser, Parser} = compiler; function compile(schema, visitors) { const parser = new Parser(); const tree = parser.parse(schema); const traverser = new Traverser(tree); visitors.forEach(visitor => { traverser.addVisitor(visitor); }); const componentTree = traverser.traverse(); return componentTree; } describe('integration with qa-compiler, test object', () => { it(`integration 1`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(`integration 2`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(`integration 3`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(`integration 4`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(`integration 5`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(` integration 6`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(`integration 7`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(`integration 8`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it(`integration 9`, () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); }); describe('array', () => { it('integration 1', () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }) it('integration 2', () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }) }) describe('complex schema', () => { it('integration 1', () => { const {schema, visitors} = ; expect(compile(schema, visitors)).toMatchSnapshot(); }); it('integration 2', () => { var contactInfo = [ { key: 'phones', options: [{ text: 'Home', value: 'HOME' }, { text: 'Company', value: 'COMPANY' }, { text: 'Mobile', value: 'MOBILE' }] }, { key: 'addresses', options: [{ text: 'Home', value: 'HOME' }, { text: 'Company', value: 'COMPANY' }] }, { key: 'emails', options: [] } ] const Img = ({attributes}) => ( ); const {schema, visitors} = {/* */} { contactInfo.map(info => ( { info && } )) } ; expect(compile(schema, visitors)).toMatchSnapshot(); }) })