astro-reactive-form/packages/form/test/FieldSet.astro.test.ts
Fazza Razaq Amiarso 59d76181db
test(migrate): migrate test tooling from chai + mocha to vitest (#203)
* test(migrate): migrate test tooling from chai + mocha to vitest

* fix: fix wrong vitest cli command for watch
2022-11-21 13:15:58 +01:00

37 lines
869 B
TypeScript

import { beforeEach, describe, it, expect } from 'vitest';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils';
describe('FieldSet.astro test', () => {
let component;
const control = {
name: 'test',
label: 'Test',
type: 'text',
};
beforeEach(() => {
component = undefined;
});
it('Should render fieldset tag', async () => {
// arrange
const expectedName = 'TestFieldSet';
const props = {
group: {
name: expectedName,
controls: [control],
},
showValidationHints: false,
};
// act
component = await getComponentOutput('./components/FieldSet.astro', props);
const actualResult = cleanString(component.html);
// assert
expect(actualResult).to.contain('<fieldset', 'fieldset tag not found');
expect(actualResult).to.contain(`<legend>${expectedName}</legend>`);
});
});