astro-reactive-form/packages/form/test/RadioGroup.astro.test.js
Ayo Ayco 3d361fcb5b
refactor: form package cleanup (#135)
* refactor: form package cleanup

* refactor: organize components folder
2022-10-23 23:04:40 +02:00

34 lines
884 B
JavaScript

import { expect } from 'chai';
import { describe, beforeEach, it } from 'mocha';
import { getComponentOutput } from 'astro-component-tester';
import { cleanString } from './utils/index.js';
describe('RadioGroup.astro test', () => {
let component;
beforeEach(() => {
component = undefined;
});
it('Should render all radio options', async () => {
// arrange
const expectedOptions = 3;
const element = /radio-option/g;
const props = {
control: {
label: 'FAKE LABEL',
name: 'FAKE NAME',
type: 'radio',
value: ['one', 'two', 'three'],
},
showValidationHints: true,
};
// act
component = await getComponentOutput('./components/controls/RadioGroup.astro', props);
const actualResult = cleanString(component.html);
const matches = actualResult.match(element) || [];
// assert
expect(matches.length).to.equal(expectedOptions);
});
});