import * as t from '@rekajs/types'; import { Stringifier } from '../stringifier'; import { Writer } from '../writer'; describe('Stringifier', () => { it('should be able to stringify expressions', () => { expect(Stringifier.toString(t.literal({ value: 10 }))).toEqual('10'); expect(Stringifier.toString(t.literal({ value: 'string' }))).toEqual( '"string"' ); expect( Stringifier.toString( t.binaryExpression({ left: t.literal({ value: 10 }), operator: '+', right: t.binaryExpression({ left: t.identifier({ name: 'counter', }), operator: '+', right: t.literal({ value: 1, }), }), }) ) ).toEqual('10 + (counter + 1)'); }); describe('Template', () => { it('should be able to parse various template types', () => { expect( Stringifier.toString( t.tagTemplate({ tag: 'div', props: { color: t.literal({ value: 'red' }) }, children: [], }) ) ).toEqual('
'); expect( Stringifier.toString( t.componentTemplate({ component: t.identifier({ name: 'Button' }), props: { color: t.literal({ value: 'red' }) }, children: [], }) ) ).toEqual('