Skip to content
Snippets Groups Projects
Commit ef25f30f authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-4948 Use data-test-id in test

parent 08640edc
No related branches found
No related tags found
No related merge requests found
......@@ -4,26 +4,31 @@
<div aria-describedby="absender-desc" class="grid-col-1 mb-2 mt-2 grid w-96 gap-1">
<text-field
inputId="absender-name"
data-test-id="absender-name"
label="Name"
[formControlName]="PostfachFormService.NAME_FIELD"
></text-field>
<text-field
inputId="absender-anschrift"
data-test-id="absender-anschrift"
label="Anschrift"
[formControlName]="PostfachFormService.ANSCHRIFT_FIELD"
></text-field>
<text-field
inputId="absender-dienst"
data-test-id="absender-dienst"
label="Dienst"
[formControlName]="PostfachFormService.DIENST_FIELD"
></text-field>
<text-field
inputId="absender-mandant"
data-test-id="absender-mandant"
label="Mandant"
[formControlName]="PostfachFormService.MANDANT_FIELD"
></text-field>
<text-field
inputId="absender-gemeindeschluessel"
data-test-id="absender-gemeindeschluessel"
label="Gemeindeschlüssel"
[formControlName]="PostfachFormService.GEMEINDESCHLUESSEL_FIELD"
></text-field>
......
......@@ -38,18 +38,29 @@ describe('PostfachFormComponent', () => {
});
describe('Absender section', () => {
test.each([
[PostfachFormService.NAME_FIELD, 'Name'],
[PostfachFormService.ANSCHRIFT_FIELD, 'Anschrift'],
[PostfachFormService.DIENST_FIELD, 'Dienst'],
[PostfachFormService.MANDANT_FIELD, 'Mandant'],
[PostfachFormService.GEMEINDESCHLUESSEL_FIELD, 'Gemeindeschlüssel'],
])('should have label for field "%s" with name "%s"', (fieldId, text) => {
const textFieldElement = getElementFromFixture(
fixture,
`text-field[inputId=absender-${fieldId}]`,
);
const fields = [
[PostfachFormService.NAME_FIELD, 'Name', 'absender-name'],
[PostfachFormService.ANSCHRIFT_FIELD, 'Anschrift', 'absender-anschrift'],
[PostfachFormService.DIENST_FIELD, 'Dienst', 'absender-dienst'],
[PostfachFormService.MANDANT_FIELD, 'Mandant', 'absender-mandant'],
[
PostfachFormService.GEMEINDESCHLUESSEL_FIELD,
'Gemeindeschlüssel',
'absender-gemeindeschluessel',
],
];
test.each(fields)(
'should have label for field "%s" with name "%s"',
(fieldName, text, inputId) => {
const textFieldElement = getElementFromFixture(fixture, getDataTestIdOf(inputId));
expect(textFieldElement.getAttribute('label')).toBe(text);
},
);
test.each(fields)('should have inputId for field "%s"', (fieldName, text, inputId) => {
const textFieldElement = getElementFromFixture(fixture, getDataTestIdOf(inputId));
expect(textFieldElement.getAttribute('inputId')).toBe(inputId);
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment