-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.test.js
32 lines (27 loc) · 1.02 KB
/
index.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
29
30
31
32
import { fireEvent, getByText } from '@testing-library/dom'
import '@testing-library/jest-dom/extend-expect'
import { JSDOM } from 'jsdom'
import fs from 'fs'
import path from 'path'
import "html-validate/jest"
import '../extend-expect-cm523'
const html = fs.readFileSync(path.resolve('', './src/index.html'), 'utf8'),
dom = new JSDOM( html ),
container = dom.window.document.body;
describe('index.html', () => {
test('All HTML is valid', () => {
expect( html ).toHTMLValidate( {
extends: ["html-validate:standard"],
root: true
} );
} );
test('Has a paragraph at the beginning of the page containing "Hello, world!"', () => {
expect( container.querySelector( 'p' ).textContent ).toBe( 'Hello, world!' );
} );
test('Has at least two paragraph (<p>) tags', () => {
expect( container.querySelectorAll( 'p' ).length ).toBeGreaterThanOrEqual( 2 );
} );
test('Uses the code example from the template (hint: make sure you have a <code> tag)', () => {
expect( container.querySelector( 'code' ) ).not.toBeNull();
} );
})