Skip to content

Commit

Permalink
test: improve renderer testing (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode authored Mar 25, 2024
1 parent dd32d4c commit 1d91525
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/renderer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,25 @@ void test('render', () => {
const parsedInput: Components = parseInput(mistCSS)
const actual = render(name, parsedInput)
const expected: string = mistTSX

// Update fixtures if needed
if (process.env['UPDATE']) {
console.log('Updating fixtures')
fs.writeFileSync(`fixtures/${name}.mist.tsx`, render(name, parsedInput))
}

// Check that the generated file contains the expected content
assert.ok(actual.includes('// Generated by MistCSS'))
assert.ok(actual.includes('type FooProps'))
assert.ok(actual.includes('export function Foo'))
assert.ok(actual.includes('<div'))
assert.ok(actual.includes('className="foo"'))
assert.ok(actual.includes('data-fooSize={fooSize}'))
assert.ok(actual.includes('data-x={x}'))
assert.ok(actual.includes('{children}'))
assert.ok(actual.includes('type BarProps'))
assert.ok(actual.includes('export function Bar'))

// Do a full comparison as a sanity check
assert.strictEqual(actual, expected)
})

0 comments on commit 1d91525

Please sign in to comment.