Skip to content

Commit f8fc462

Browse files
committed
test: use the jest matchers for verbose failures
1 parent 19841f9 commit f8fc462

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

test/toRedactor.test.ts

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,25 @@ describe("Testing json to html conversion", () => {
99
let jsonValue = expectedValue["2"].json
1010

1111
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
12-
let testResult = isEqual(htmlValue, expectedValue['2'].html)
13-
expect(testResult).toBe(true)
12+
expect(htmlValue).toBe(expectedValue['2'].html)
1413
})
1514
it("table conversion", () => {
1615
let jsonValue = expectedValue["3"].json
1716

1817
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
19-
let testResult = isEqual(htmlValue, expectedValue['3'].html)
20-
expect(testResult).toBe(true)
18+
expect(htmlValue).toBe(expectedValue['3'].html)
2119
})
2220
it("basic formating, block and code conversion", () => {
2321
let jsonValue = expectedValue["4"].json
2422

2523
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
26-
let testResult = isEqual(htmlValue, expectedValue['4'].html)
27-
expect(testResult).toBe(true)
24+
expect(htmlValue).toBe(expectedValue['4'].html)
2825
})
2926
it("List and alignment conversion", () => {
3027
let jsonValue = expectedValue["5"].json
3128

3229
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
33-
let testResult = isEqual(htmlValue, expectedValue['5'].html)
34-
expect(testResult).toBe(true)
30+
expect(htmlValue).toBe(expectedValue['5'].html)
3531
})
3632
it.each(["6", "RT-154"])("Image and iframe conversion", (index) => {
3733
let jsonValue = expectedValue[index].json
@@ -43,31 +39,27 @@ describe("Testing json to html conversion", () => {
4339

4440
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
4541

46-
let testResult = isEqual(htmlValue, expectedValue['7'].html)
47-
expect(testResult).toBe(true)
42+
expect(htmlValue).toBe(expectedValue['7'].html)
4843
})
4944
it("Embed entry as link", () => {
5045
let jsonValue = expectedValue["8"].json
5146

5247
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
5348

5449

55-
let testResult = isEqual(htmlValue, expectedValue['8'].htmlUpdated)
56-
expect(testResult).toBe(true)
50+
expect(htmlValue).toBe(expectedValue['8'].htmlUpdated)
5751
})
5852
it("Embedded entry as inline block", () => {
5953
let jsonValue = expectedValue["9"].json
6054

6155
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
62-
let testResult = isEqual(htmlValue, expectedValue['9'].htmlUpdated)
63-
expect(testResult).toBe(true)
56+
expect(htmlValue).toBe(expectedValue['9'].htmlUpdated)
6457
})
6558
it("Embedded entry as block", () => {
6659
let jsonValue = expectedValue["10"].json
6760

6861
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
69-
let testResult = isEqual(htmlValue, expectedValue['10'].htmlValue)
70-
expect(testResult).toBe(true)
62+
expect(htmlValue).toBe(expectedValue['10'].htmlValue)
7163
})
7264
it("Custom ELEMENT_TYPES",() => {
7365
let cases = ["15","16","18"]
@@ -76,8 +68,7 @@ describe("Testing json to html conversion", () => {
7668
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: json },{customElementTypes:expectedValue[index].customElementTypes})
7769
//console.log(htmlValue)
7870
//console.log(expectedValue[index].html)
79-
let testResult = isEqual(htmlValue, expectedValue[index].html)
80-
expect(testResult).toBe(true)
71+
expect(htmlValue).toBe(expectedValue[index].html)
8172
})
8273
})
8374
it("Custom TEXT_WRAPPER",() => {
@@ -87,8 +78,7 @@ describe("Testing json to html conversion", () => {
8778
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: json },{customTextWrapper:expectedValue[index].customTextWrapper})
8879
//console.log(htmlValue)
8980
//console.log(expectedValue[index].html)
90-
let testResult = isEqual(htmlValue, expectedValue[index].html)
91-
expect(testResult).toBe(true)
81+
expect(htmlValue).toBe(expectedValue[index].html)
9282
})
9383
})
9484
it("Conversion with allowNonStandardTags", () => {
@@ -98,28 +88,21 @@ describe("Testing json to html conversion", () => {
9888
console.warn = mockFunction
9989
let json = expectedValue[index]?.json
10090
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: json },{allowNonStandardTypes:true,customTextWrapper:expectedValue[index].customTextWrapper})
101-
let testResult = isEqual(htmlValue, expectedValue[index].html)
102-
if(!testResult){
103-
//console.log(htmlValue)
104-
//console.log(expectedValue[index].html)
105-
}
106-
expect(testResult).toBe(true)
91+
expect(htmlValue).toBe(expectedValue[index].html)
10792
expect(mockFunction).toHaveBeenCalledTimes(expectedValue[index].nonStandardTags)
10893

10994
})
11095
})
11196
it('"\n" to <br/> conversion', () => {
11297
let jsonValue = expectedValue["'\n' to <br>"].json
11398
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
114-
let testResult = isEqual(htmlValue, expectedValue["'\n' to <br>"].html)
115-
expect(testResult).toBe(true)
99+
expect(htmlValue).toBe(expectedValue["'\n' to <br>"].html)
116100
})
117101

118102
it("Inline classname and id", () => {
119103
let jsonValue = expectedValue["inline-classname-and-id"].json
120104
let htmlValue = toRedactor({ type: "doc", attrs: {}, children: jsonValue })
121-
let testResult = isEqual(htmlValue, expectedValue["inline-classname-and-id"].html)
122-
expect(testResult).toBe(true)
105+
expect(htmlValue).toBe(expectedValue["inline-classname-and-id"].html)
123106
})
124107

125108
describe("Nested attrs", () => {

0 commit comments

Comments
 (0)