Skip to content

Commit

Permalink
Updates to va-statement-of-truth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew565 committed Dec 19, 2024
1 parent 2af90f3 commit 7131458
Showing 1 changed file with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ describe('va-statement-of-truth', () => {
const page = await newE2EPage();
await page.setContent('<va-statement-of-truth />');
const vaCheckboxChangeSpy = await page.spyOnEvent('vaCheckboxChange');
const checkboxEl = await page.find('va-statement-of-truth >>> va-checkbox >>> label.usa-checkbox__label');
const checkboxEl = await page.find(
'va-statement-of-truth >>> va-checkbox >>> label',
);
await checkboxEl.click();
expect(vaCheckboxChangeSpy).toHaveReceivedEvent();
});
Expand All @@ -76,36 +78,50 @@ describe('va-statement-of-truth', () => {

it('sets an input aria described by message', async () => {
const page = await newE2EPage();
await page.setContent('<va-statement-of-truth input-message-aria-describedby="testing one two three"/>');
await page.setContent(
'<va-statement-of-truth input-message-aria-describedby="testing one two three"/>',
);
const span = await page.$('pierce/span#input-message');
const text = await page.evaluate(element => element.textContent, span);
expect(text).toContain('testing one two three');
});

it('permits prefilling the form', async () => {
const page = await newE2EPage();
await page.setContent('<va-statement-of-truth input-value="John Doe" checked/>');

const value = await page.$eval('va-statement-of-truth >>> va-text-input >>> input', (comp: HTMLInputElement) => comp.value);
await page.setContent(
'<va-statement-of-truth input-value="John Doe" checked/>',
);

const value = await page.$eval(
'va-statement-of-truth >>> va-text-input >>> input',
(comp: HTMLInputElement) => comp.value,
);
expect(value).toBe('John Doe');

const checked = await page.$eval('va-statement-of-truth >>> va-checkbox >>> input', (comp: HTMLInputElement) => comp.checked);
const checked = await page.$eval(
'va-statement-of-truth >>> va-checkbox >>> input',
(comp: HTMLInputElement) => comp.checked,
);
expect(checked).toBeTruthy();
});

it('adds custom label to va-text-input', async () => {
const page = await newE2EPage();
await page.setContent('<va-statement-of-truth input-label="test label" />');
const labelEl = await page.$('pierce/label.usa-label');
const text = await page.evaluate(element => element.textContent, labelEl);
expect(text).toContain('test label');
const textInputEl = await page.find(
'va-statement-of-truth >>> va-text-input',
);
const textInputLabel = await textInputEl.getProperty('label');
expect(textInputLabel).toBe('test label');
});

it('adds custom label to va-checkbox', async () => {
const page = await newE2EPage();
await page.setContent('<va-statement-of-truth checkbox-label="test label" />');
const labelEl = await page.$('pierce/label.usa-checkbox__label');
const text = await page.evaluate(element => element.textContent, labelEl);
expect(text).toContain('test label');
await page.setContent(
'<va-statement-of-truth checkbox-label="test label" />',
);
const checkboxEl = await page.find('va-statement-of-truth >>> va-checkbox');
const checkboxLabel = await checkboxEl.getProperty('label');
expect(checkboxLabel).toBe('test label');
});
})

0 comments on commit 7131458

Please sign in to comment.