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 @@ ...@@ -4,26 +4,31 @@
<div aria-describedby="absender-desc" class="grid-col-1 mb-2 mt-2 grid w-96 gap-1"> <div aria-describedby="absender-desc" class="grid-col-1 mb-2 mt-2 grid w-96 gap-1">
<text-field <text-field
inputId="absender-name" inputId="absender-name"
data-test-id="absender-name"
label="Name" label="Name"
[formControlName]="PostfachFormService.NAME_FIELD" [formControlName]="PostfachFormService.NAME_FIELD"
></text-field> ></text-field>
<text-field <text-field
inputId="absender-anschrift" inputId="absender-anschrift"
data-test-id="absender-anschrift"
label="Anschrift" label="Anschrift"
[formControlName]="PostfachFormService.ANSCHRIFT_FIELD" [formControlName]="PostfachFormService.ANSCHRIFT_FIELD"
></text-field> ></text-field>
<text-field <text-field
inputId="absender-dienst" inputId="absender-dienst"
data-test-id="absender-dienst"
label="Dienst" label="Dienst"
[formControlName]="PostfachFormService.DIENST_FIELD" [formControlName]="PostfachFormService.DIENST_FIELD"
></text-field> ></text-field>
<text-field <text-field
inputId="absender-mandant" inputId="absender-mandant"
data-test-id="absender-mandant"
label="Mandant" label="Mandant"
[formControlName]="PostfachFormService.MANDANT_FIELD" [formControlName]="PostfachFormService.MANDANT_FIELD"
></text-field> ></text-field>
<text-field <text-field
inputId="absender-gemeindeschluessel" inputId="absender-gemeindeschluessel"
data-test-id="absender-gemeindeschluessel"
label="Gemeindeschlüssel" label="Gemeindeschlüssel"
[formControlName]="PostfachFormService.GEMEINDESCHLUESSEL_FIELD" [formControlName]="PostfachFormService.GEMEINDESCHLUESSEL_FIELD"
></text-field> ></text-field>
......
...@@ -38,18 +38,29 @@ describe('PostfachFormComponent', () => { ...@@ -38,18 +38,29 @@ describe('PostfachFormComponent', () => {
}); });
describe('Absender section', () => { describe('Absender section', () => {
test.each([ const fields = [
[PostfachFormService.NAME_FIELD, 'Name'], [PostfachFormService.NAME_FIELD, 'Name', 'absender-name'],
[PostfachFormService.ANSCHRIFT_FIELD, 'Anschrift'], [PostfachFormService.ANSCHRIFT_FIELD, 'Anschrift', 'absender-anschrift'],
[PostfachFormService.DIENST_FIELD, 'Dienst'], [PostfachFormService.DIENST_FIELD, 'Dienst', 'absender-dienst'],
[PostfachFormService.MANDANT_FIELD, 'Mandant'], [PostfachFormService.MANDANT_FIELD, 'Mandant', 'absender-mandant'],
[PostfachFormService.GEMEINDESCHLUESSEL_FIELD, 'Gemeindeschlüssel'], [
])('should have label for field "%s" with name "%s"', (fieldId, text) => { PostfachFormService.GEMEINDESCHLUESSEL_FIELD,
const textFieldElement = getElementFromFixture( 'Gemeindeschlüssel',
fixture, 'absender-gemeindeschluessel',
`text-field[inputId=absender-${fieldId}]`, ],
); ];
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); 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