sdenv/test/documentAll.test.js

24 lines
887 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const getDocumentAll = require('../bin/documentAll.node').getDocumentAll;
describe('模拟document.all检测', () => {
const da = getDocumentAll({ length: 1 });
console.log(
'运行getDocumentAll({ length: 1 }),返回:', da,
'\n运行getDocumentAll({ length: 1 }) == undefined返回', da == undefined,
'\n运行getDocumentAll({ length: 1 })(),返回:', da(),
'\n运行typeof getDocumentAll({ length: 1 }),返回:', typeof da,
);
test('getDocumentAll({ length: 1 }).length === 1', () => {
expect(da.length).toBe(1);
});
test('getDocumentAll({ length: 1 }) == undefined', () => {
expect(da == undefined).toBe(true);
});
test('typeof getDocumentAll({ length: 1 })', () => {
expect(typeof da).toBe('undefined');
});
test('getDocumentAll({ length: 1 })() === null', () => {
expect(da()).toBe(null);
});
});