Skip to content

Commit 258bfcb

Browse files
test return values in fidelity tests.
1 parent 90156fa commit 258bfcb

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

test/fidelity.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
describe("Tests to ensure that idiomorph merges properly", function () {
22
setup();
33

4-
function expectFidelity(actual, expected) {
5-
if (actual.outerHTML !== expected) {
6-
console.log("HTML after morph: " + actual.outerHTML);
7-
console.log("Expected: " + expected);
8-
}
9-
actual.outerHTML.should.equal(expected);
10-
}
11-
124
function testFidelity(start, end) {
13-
let initial = make(start);
14-
let final = make(end);
15-
Idiomorph.morph(initial, final);
16-
17-
expectFidelity(initial, end);
5+
getWorkArea().innerHTML = start;
6+
let startElement = getWorkArea().firstElementChild;
7+
let ret = Idiomorph.morph(startElement, end);
8+
getWorkArea().innerHTML.should.equal(end);
9+
ret.map((e) => e.outerHTML).should.eql([end]);
1810
}
1911

2012
// bootstrap test
@@ -37,10 +29,10 @@ describe("Tests to ensure that idiomorph merges properly", function () {
3729
const initial = make(a);
3830

3931
Idiomorph.morph(initial, expectedB);
40-
expectFidelity(initial, b);
32+
initial.outerHTML.should.equal(b);
4133

4234
Idiomorph.morph(initial, expectedA);
43-
expectFidelity(initial, a);
35+
initial.outerHTML.should.equal(a);
4436
});
4537

4638
it("morphs children", function () {
@@ -78,21 +70,11 @@ describe("Tests to ensure that idiomorph merges properly", function () {
7870
});
7971

8072
it("should wrap an IDed node", function () {
81-
getWorkArea().innerHTML = `<hr id="a">`;
82-
let initial = getWorkArea().firstElementChild;
83-
let finalSrc = `<div><hr id="a"></div>`;
84-
let ret = Idiomorph.morph(initial, finalSrc);
85-
getWorkArea().innerHTML.should.equal(finalSrc);
86-
// ret.map(e=>e.outerHTML).should.eql([finalSrc]);
73+
testFidelity(`<hr id="a">`, `<div><hr id="a"></div>`);
8774
});
8875

8976
it("should wrap an anonymous node", function () {
90-
getWorkArea().innerHTML = `<hr>`;
91-
let initial = getWorkArea().firstElementChild;
92-
let finalSrc = `<div><hr></div>`;
93-
let ret = Idiomorph.morph(initial, finalSrc);
94-
getWorkArea().innerHTML.should.equal(finalSrc);
95-
// ret.map(e=>e.outerHTML).should.eql([finalSrc]);
77+
testFidelity(`<hr>`, `<div><hr></div>`);
9678
});
9779

9880
it("should append a node", function () {

0 commit comments

Comments
 (0)