Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbasso committed Jul 13, 2020
1 parent f9261c5 commit 075ea6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/cpp/domRecycler.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const recycler = {
return node;
},
createText(text) {
const list = recycler.nodes['#text'];
const list = recycler.nodes['#TEXT'];
if (list !== undefined) {
const node = list.pop();
if (node !== undefined) {
Expand All @@ -21,7 +21,7 @@ const recycler = {
return document.createTextNode(text);
},
createComment(comment) {
const list = recycler.nodes['#comment'];
const list = recycler.nodes['#COMMENT'];
if (list !== undefined) {
const node = list.pop();
if (node !== undefined) {
Expand Down Expand Up @@ -68,7 +68,7 @@ const recycler = {
});

// collect
let name = node.nodeName;
let name = node.nodeName.toUpperCase();
if (node.asmDomNS !== undefined) name += node.namespaceURI;
const list = recycler.nodes[name];
if (list !== undefined) list.push(node);
Expand Down
16 changes: 8 additions & 8 deletions test/cpp/domRecycler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ describe('dom recycler', () => {
it('should create and recycler texts', () => {
const node = recycler.createText('Hello World!');
expect(node.nodeValue).toEqual('Hello World!');
expect(recycler.nodes['#text']).toEqual(undefined);
expect(recycler.nodes['#TEXT']).toEqual(undefined);
recycler.collect(node);
expect(recycler.nodes['#text']).toEqual([node]);
expect(recycler.nodes['#TEXT']).toEqual([node]);
const newNode = recycler.createText('New Hello World!');
expect(node.nodeValue).toEqual('New Hello World!');
expect(newNode).toEqual(node);
expect(recycler.nodes['#text']).toEqual([]);
expect(recycler.nodes['#TEXT']).toEqual([]);
});

it('should create and recycler comments', () => {
const node = recycler.createComment('Hello World!');
expect(node.nodeValue).toEqual('Hello World!');
expect(recycler.nodes['#comment']).toEqual(undefined);
expect(recycler.nodes['#COMMENT']).toEqual(undefined);
recycler.collect(node);
expect(recycler.nodes['#comment']).toEqual([node]);
expect(recycler.nodes['#COMMENT']).toEqual([node]);
const newNode = recycler.createComment('New Hello World!');
expect(node.nodeValue).toEqual('New Hello World!');
expect(newNode).toEqual(node);
expect(recycler.nodes['#comment']).toEqual([]);
expect(recycler.nodes['#COMMENT']).toEqual([]);
});

it('should create and normal nodes', () => {
Expand All @@ -44,12 +44,12 @@ describe('dom recycler', () => {

it('should create and nodes with namespace', () => {
const node = recycler.createNS('svg', 'http://www.w3.org/2000/svg');
expect(node.nodeName).toEqual('SVG');
expect(node.nodeName).toEqual('svg');
expect(recycler.nodes['SVGhttp://www.w3.org/2000/svg']).toEqual(undefined);
recycler.collect(node);
expect(recycler.nodes['SVGhttp://www.w3.org/2000/svg']).toEqual([node]);
const newNode = recycler.createNS('svg', 'http://www.w3.org/2000/svg');
expect(node.nodeName).toEqual('SVG');
expect(node.nodeName).toEqual('svg');
expect(newNode).toEqual(node);
expect(recycler.nodes['SVGhttp://www.w3.org/2000/svg']).toEqual([]);
});
Expand Down

0 comments on commit 075ea6c

Please sign in to comment.