Skip to content

Commit

Permalink
add nodeName/Type tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Sep 17, 2021
1 parent 0d8afe5 commit 730b56e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
17 changes: 10 additions & 7 deletions tests/element/element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ test('element', async ({ page }) => {

await page.waitForSelector('.completed');

const test0 = page.locator('#test0');
await expect(test0).toHaveText('H1');
const testElementNameType = page.locator('#testElementNameType');
await expect(testElementNameType).toHaveText('DIV 1');

const testGetBoundingClientRectY = page.locator('#testGetBoundingClientRectY');
const y = await testGetBoundingClientRectY.textContent();
const yInt = parseFloat(y);
expect(yInt).toBeGreaterThan(4);

const testQSH1 = page.locator('#testQSH1');
await expect(testQSH1).toHaveText('H1');

const testQSLength = page.locator('#testQSLength');
await expect(testQSLength).toHaveText('2');
Expand All @@ -32,11 +40,6 @@ test('element', async ({ page }) => {
const testSetAttribute = page.locator('#testSetAttribute');
await expect(testSetAttribute).toHaveText('1985');

const testGetBoundingClientRectY = page.locator('#testGetBoundingClientRectY');
const y = await testGetBoundingClientRectY.textContent();
const yInt = parseFloat(y);
expect(yInt).toBeGreaterThan(4);

const testAnchor = page.locator('#testAnchor');
await expect(testAnchor).toHaveText('/element/some/other/path');

Expand Down
15 changes: 13 additions & 2 deletions tests/element/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@
<body mph="88">
<h1>Element</h1>
<ul>
<li>
<strong>element, nodeName/Type</strong>
<code id="testElementNameType"></code>
<script type="text/partytown">
(function () {
const elm = document.createElement('div');
document.getElementById('testElementNameType').textContent = elm.nodeName + ' ' + elm.nodeType;
})();
</script>
</li>

<li>
<strong>getBoundingClientRect()</strong>
<code id="testGetBoundingClientRectY"></code>
Expand All @@ -72,11 +83,11 @@ <h1>Element</h1>

<li>
<strong>querySelector('h1')</strong>
<code id="test0"></code>
<code id="testQSH1"></code>
<script type="text/partytown">
(function () {
const elm = document.querySelector('h1');
document.getElementById('test0').innerHTML = elm.tagName;
document.getElementById('testQSH1').innerHTML = elm.tagName;
})();
</script>
</li>
Expand Down
11 changes: 11 additions & 0 deletions tests/node/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@
<body>
<h1 class="title">Node</h1>
<ul>
<li>
<strong>node, nodeName/Type</strong>
<code id="testNodeNameType"></code>
<script type="text/partytown">
(function () {
const text = document.createTextNode('Hello');
document.getElementById('testNodeNameType').textContent = text.nodeName + ' ' + text.nodeType;
})();
</script>
</li>

<li>
<strong>createElement() / appendChild()</strong>
<code id="testInput"></code>
Expand Down
3 changes: 3 additions & 0 deletions tests/node/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ test('node', async ({ page }) => {

await page.waitForSelector('.completed');

const testNodeNameType = page.locator('#testNodeNameType');
await expect(testNodeNameType).toHaveText('#text 3');

const testCheckbox = page.locator('#testCheckbox');
await expect(testCheckbox).toBeChecked();

Expand Down

1 comment on commit 730b56e

@vercel
Copy link

@vercel vercel bot commented on 730b56e Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.