playwright/tests/components/ct-angular/tests/unmount.spec.ts
2024-03-26 15:00:06 +01:00

24 lines
929 B
TypeScript

import { test, expect } from '@playwright/experimental-ct-angular';
import { ButtonComponent } from '@/components/button.component';
import { MultiRootComponent } from '@/components/multi-root.component';
test('unmount', async ({ page, mount }) => {
const component = await mount(ButtonComponent, {
props: {
title: 'Submit',
},
});
await expect(page.locator('#root')).toContainText('Submit');
await component.unmount();
await expect(page.locator('#root')).not.toContainText('Submit');
});
test('unmount a multi root component', async ({ mount, page }) => {
const component = await mount(MultiRootComponent);
await expect(page.locator('#root')).toContainText('root 1');
await expect(page.locator('#root')).toContainText('root 2');
await component.unmount();
await expect(page.locator('#root')).not.toContainText('root 1');
await expect(page.locator('#root')).not.toContainText('root 2');
});