Skip to content

Commit

Permalink
chore(tests): add is-node-in tests + rename
Browse files Browse the repository at this point in the history
  • Loading branch information
MarsiBarsi committed Oct 7, 2020
1 parent 3ff3b98 commit 8456e64
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions projects/cdk/utils/dom/test/is-node-in.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {isNodeIn} from '../is-node-in';

describe('isNodeIn', () => {
it('tag selector', () => {
const div = document.createElement('div');

document.body.appendChild(div);

expect(isNodeIn(div, 'div')).toEqual(true);
});

it('class selector', () => {
const div = document.createElement('div');

div.classList.add('hello');

document.body.appendChild(div);

expect(isNodeIn(div, '.hello')).toEqual(true);
});

it('works with text nodes', () => {
const p = document.createElement('p');
const textNode = document.createTextNode('hello');

p.appendChild(textNode);

document.body.appendChild(p);

expect(isNodeIn(textNode, 'p')).toEqual(true);
});
});

0 comments on commit 8456e64

Please sign in to comment.