Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Use toBe/toStrictEqual instead of toEqual #175

Merged
merged 1 commit into from Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/dom-parser.test.js
Expand Up @@ -15,7 +15,7 @@ describe('DOMParser', () => {
columnNumber: 1,
lineNumber: 1,
}
expect(options.locator).toEqual(expected)
expect(options.locator).toStrictEqual(expected)
})

test('should store passed options.xmlns for default mime type', () => {
Expand All @@ -25,7 +25,7 @@ describe('DOMParser', () => {
// TODO: is there a simpler way to test this that doesn't involve invoking parseFromString?
const actual = it.parseFromString('<xml/>')

expect(actual.toString()).toEqual('<xml xmlns="custom-default-ns"/>')
expect(actual.toString()).toBe('<xml xmlns="custom-default-ns"/>')
})

test('should store and modify passed options.xmlns for html mime type', () => {
Expand All @@ -35,7 +35,7 @@ describe('DOMParser', () => {
// TODO: is there a simpler way to test this that doesn't involve invoking parseFromString?
it.parseFromString('<xml/>', 'text/html')

expect(options.xmlns['']).toEqual('http://www.w3.org/1999/xhtml')
expect(options.xmlns['']).toBe('http://www.w3.org/1999/xhtml')
})
})

Expand All @@ -45,7 +45,7 @@ describe('DOMParser', () => {

const actual = new DOMParser().parseFromString(XML).toString()

expect(actual).toEqual(XML)
expect(actual).toBe(XML)
})

test('should provide access to textContent and attribute values', () => {
Expand All @@ -71,13 +71,13 @@ describe('DOMParser', () => {
*/
const textTags = document.getElementsByTagName('text')

expect(textTags.length).toEqual(3)
expect(textTags).toHaveLength(3)

const expectedText = ['first', 'second', 'last']
for (let i = 0; i < textTags.length; i++) {
const textTag = textTags[i]
expect(textTag.textContent).toEqual(expectedText[i])
expect(textTag.getAttribute('top')).toEqual(`${i}`)
expect(textTag.textContent).toBe(expectedText[i])
expect(textTag.getAttribute('top')).toBe(`${i}`)
}
})
})
Expand Down
8 changes: 4 additions & 4 deletions test/parse/parse-element.test.js
Expand Up @@ -9,7 +9,7 @@ describe('XML Node Parse', () => {
const actual = new DOMParser()
.parseFromString(input, 'text/xml')
.toString()
expect(actual).toEqual('<xml/>')
expect(actual).toBe('<xml/>')
})
})

Expand All @@ -24,7 +24,7 @@ describe('XML Node Parse', () => {
.parseFromString(input, 'text/xml')
.toString()

expect(actual).toEqual('<xml a="1" b="2"/>')
expect(actual).toBe('<xml a="1" b="2"/>')
})
})
describe('empty b', () => {
Expand All @@ -36,7 +36,7 @@ describe('XML Node Parse', () => {
])('%s', (input) => {
expect(
new DOMParser().parseFromString(input, 'text/xml').toString()
).toEqual('<xml a="1" b=""/>')
).toBe('<xml a="1" b=""/>')
})
})

Expand All @@ -61,7 +61,7 @@ describe('XML Node Parse', () => {
.parseFromString(input, 'text/xml')
.toString()

expect(actual).toEqual('<xml xmlns="1" xmlns:a="2" a:test="3"/>')
expect(actual).toBe('<xml xmlns="1" xmlns:a="2" a:test="3"/>')
})

it('unclosed root tag will be closed', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/xss.test.js
Expand Up @@ -68,7 +68,7 @@ describe('xss test', () => {

const actual = xss(html)

expect(actual).toEqual(
expect(actual).toBe(
'<div title="32323" xmlns="http://www.w3.org/1999/xhtml"></div>'
)
})
Expand Down