import { describe, expect, it } from 'vitest' import { print } from './utils'; import { nodeType } from '../core'; describe('LML - List-based Markup Language', () => { describe('Text Nodes', () => { it('should support simple text nodes', async () => { expect(print("Hello World")).toMatchObject([ "Hello World" ]); }); it('should support list of text nodes', async () => { expect(print(["Hello", " World"])).toMatchObject([ "Hello", " World" ]); 1 }); }); describe('Node types', () => { it('should be text', async () => { expect(nodeType("Hello")).toBe("text"); }); it('should be element', async () => { expect(nodeType(["#span", "Hello"])).toBe("element"); }); it('should be component', async () => { expect(nodeType(["*cpt", "Hello"])).toBe("component"); }); it('should be fragment', async () => { expect(nodeType([])).toBe("fragment"); expect(nodeType(["a"])).toBe("fragment"); expect(nodeType(["", ["#span", "b"]])).toBe("fragment"); expect(nodeType([["#span", "b"]])).toBe("fragment"); expect(nodeType(["a", "b"])).toBe("fragment"); }); it('should be invalid', async () => { expect(nodeType(["!x", "Hello"])).toBe("invalid"); expect(nodeType(["@x", "Hello"])).toBe("invalid"); expect(nodeType(123 as any)).toBe("invalid"); expect(nodeType({} as any)).toBe("invalid"); }); }); describe('Elements', () => { it('should support empty elements', async () => { expect(print(["#div"])).toMatchObject([ "
" ]); }); it('should support empty elements', async () => { expect(print(["#foo-bar"])).toMatchObject([ "