mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import test from 'supertape';
|
|
import {create} from 'auto-globals';
|
|
import tryCatch from 'try-catch';
|
|
|
|
import {isContainClass} from './dom-tree.js';
|
|
|
|
test('dom: isContainClass: no element', (t) => {
|
|
const [e] = tryCatch(isContainClass);
|
|
t.equal(e.message, 'element could not be empty!', 'should throw when no element');
|
|
t.end();
|
|
});
|
|
|
|
test('dom: isContainClass: no className', (t) => {
|
|
const [e] = tryCatch(isContainClass, {});
|
|
t.equal(e.message, 'className could not be empty!', 'should throw when no element');
|
|
t.end();
|
|
});
|
|
|
|
test('dom: isContainClass: contains', (t) => {
|
|
const el = create();
|
|
const {contains} = el.classList;
|
|
|
|
const className = 'hello';
|
|
isContainClass(el, className);
|
|
|
|
t.calledWith(contains, [className], 'should call contains');
|
|
t.end();
|
|
});
|
|
|
|
test('dom: isContainClass: contains: array', (t) => {
|
|
const el = create();
|
|
const {contains} = el.classList;
|
|
|
|
const className = 'hello';
|
|
isContainClass(el, [
|
|
'world',
|
|
className,
|
|
'hello',
|
|
]);
|
|
|
|
t.calledWith(contains, [className], 'should call contains');
|
|
t.end();
|
|
});
|
|
|