forked from sindresorhus/is-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
28 lines (24 loc) · 815 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import test from 'ava';
import isHtml from '.';
test('detect HTML if it has doctype', t => {
t.true(isHtml('<!doctype html>'));
t.true(isHtml('\n\n<!doctype html><html>'));
});
test('detect HTML if it has <html>, <body> or <x-*>', t => {
t.true(isHtml('<html>'));
t.true(isHtml('<html></html>'));
t.true(isHtml('<html lang="en"></html>'));
t.true(isHtml('<html><body></html>'));
t.true(isHtml('<html><body class="no-js"></html>'));
t.true(isHtml('<x-unicorn>'));
});
test('detect HTML if it contains any of the standard HTML tags', t => {
t.true(isHtml('<p>foo</p>'));
t.true(isHtml('<a href="#">foo</a>'));
});
test('not match XML', t => {
t.false(isHtml('<cake>foo</cake>'));
t.false(isHtml('<any>rocks</any>'));
t.false(isHtml('<htmly>not</htmly>'));
t.false(isHtml('<bodyx>not</bodyx>'));
});