Skip to content

Commit

Permalink
test: Use toBe/toStrictEqual instead of toEqual (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
karfau committed Jan 17, 2021
1 parent 23608d9 commit ad773c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
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

0 comments on commit ad773c9

Please sign in to comment.