playwright-fluent
Version:
Fluent API around playwright
51 lines (50 loc) • 2.13 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const playwright_1 = require("playwright");
const SUT = tslib_1.__importStar(require("../index"));
describe('handle does not have class', () => {
let browser = undefined;
// eslint-disable-next-line @typescript-eslint/no-empty-function
beforeEach(() => { });
afterEach(async () => {
if (browser) {
await browser.close();
}
});
test('should return true when selector does not have class', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: true });
const browserContext = await browser.newContext({ viewport: null });
const page = await browserContext.newPage();
const url = `file:${path.join(__dirname, 'has-not-handle-class.test.html')}`;
await page.goto(url);
const selector = '#with-two-classes';
const handle = await page.$(selector);
// When
const result1 = await SUT.hasNotHandleClass(handle, 'foobar');
const result2 = await SUT.hasNotHandleClass(handle, 'barfoo');
// Then
expect(handle).toBeDefined();
expect(result1).toBe(true);
expect(result2).toBe(true);
});
test('should return false when selector has the class', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: true });
const browserContext = await browser.newContext({ viewport: null });
const page = await browserContext.newPage();
const url = `file:${path.join(__dirname, 'has-not-handle-class.test.html')}`;
await page.goto(url);
const selector = '#with-two-classes';
const handle = await page.$(selector);
// When
const result1 = await SUT.hasNotHandleClass(handle, 'foo');
const result2 = await SUT.hasNotHandleClass(handle, 'bar');
// Then
expect(handle).toBeDefined();
expect(result1).toBe(false);
expect(result2).toBe(false);
});
});
;