-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html.test.js
49 lines (39 loc) · 1.52 KB
/
index.html.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 { assert } from 'console'
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
let dom
let container
let user = "[email protected]"
let psw = "test_pass123"
describe('index.html', () => {
it('renders a button element', () => {
dom = new JSDOM(html)
container = dom.window.document.body
expect(container.querySelector('button')).toBeInTheDocument()
})
it('renders a button element with text "Login"', () => {
dom = new JSDOM(html)
container = dom.window.document.body
expect(container.querySelector('button').textContent).toBe('Sign in')
})
it('renders a button element', () => {
expect(container.querySelector('button')).not.toBeNull()
expect(getByText(container, 'Sign in')).toBeInTheDocument()
})
it('renders a button element with text "Login"', () => {
expect(container.querySelector('button').textContent).toBe('Sign in')
})
it('correct user credentials', ()=> {
dom = new JSDOM(html)
container = dom.window.document.body
if (dom.window.document.getElementById("inputEmail").value == user && dom.window.document.getElementById("inputPassword").value == psw)
{
expect(user).toMatch(/[email protected]/);
expect(psw).toMatch(/test_pass123/);
}
})
})