mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-10-23 15:59:02 +08:00
aed09be687
- Setup projects for e2e, integration, and unit tests in Jest configuration - Setup /tests/e2e/ tests for Jest+PlayWright - Setup /tests/integration/ tests for Jest - Setup /tests/unit/ tests for Jest - Setup eslint for Jest and Jest+Playwright environments - Move e2e configuration files into separate folder - Update e2e example tests - Update unit example tests - Update HTML fixtures
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
// Suite
|
|
// -----------------------------------------------------------------------------
|
|
describe(`Example Tests`, function() {
|
|
// Tests
|
|
// ---------------------------------------------------------------------------
|
|
test('javascript (node)', async () => {
|
|
function add(...addends) {
|
|
return addends.reduce(
|
|
(accumulator, currentValue) => accumulator + currentValue
|
|
);
|
|
}
|
|
const testValue = add(1, 2, 3);
|
|
|
|
expect(testValue).toBe(6);
|
|
});
|
|
|
|
test('dom manipulation (jsdom)', async () => {
|
|
const testText = 'This is a test';
|
|
const testHTML = `<h1>Test</h1><p>${testText}</p>`;
|
|
|
|
// Inject HTML
|
|
document.body.innerHTML = testHTML;
|
|
|
|
// Add class to <body> element and verify
|
|
document.body.classList.add('foo');
|
|
|
|
// Test HTML
|
|
expect(document.body.getAttribute('class')).toEqual('foo');
|
|
expect(document.body.textContent).toMatch(/Test/);
|
|
expect(document.querySelectorAll('p')).toHaveLength(1);
|
|
expect(document.querySelector('p').textContent).toBe(testText);
|
|
expect(document.querySelector('table')).toBeNull();
|
|
});
|
|
});
|