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

Improve some XML test strings #183

Closed
wants to merge 2 commits into from
Closed
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
44 changes: 27 additions & 17 deletions test/dom/element.test.js
Expand Up @@ -13,10 +13,12 @@ describe('XML Namespace Parse', () => {

it('supports getElementsByTagName', () => {
const doc = new DOMParser().parseFromString(
'<xml xmlns="http://test.com" xmlns:t="http://test.com" xmlns:t2="http://test2.com">' +
'<t:test/><test/><t2:test/>' +
'<child attr="1"><test><child attr="2"/></test></child>' +
'<child attr="3"/></xml>',
''.concat(
'<xml xmlns="http://test.com" xmlns:t="http://test.com" xmlns:t2="http://test2.com">',
'<t:test/><test/><t2:test/>',
'<child attr="1"><test><child attr="2"/></test></child>',
'<child attr="3"/></xml>'
),
'text/xml'
)

Expand Down Expand Up @@ -49,10 +51,12 @@ describe('XML Namespace Parse', () => {

it('supports getElementsByTagNameNS', () => {
const doc = new DOMParser().parseFromString(
'<xml xmlns="http://test.com" xmlns:t="http://test.com" xmlns:t2="http://test2.com">' +
'<t:test/><test/><t2:test/>' +
'<child attr="1"><test><child attr="2"/></test></child>' +
'<child attr="3"/></xml>',
''.concat(
'<xml xmlns="http://test.com" xmlns:t="http://test.com" xmlns:t2="http://test2.com">',
'<t:test/><test/><t2:test/>',
'<child attr="1"><test><child attr="2"/></test></child>',
'<child attr="3"/></xml>'
),
'text/xml'
)

Expand Down Expand Up @@ -83,9 +87,11 @@ describe('XML Namespace Parse', () => {

it('supports getElementById', () => {
const doc = new DOMParser().parseFromString(
'<xml xmlns="http://test.com" id="root">' +
'<child id="a1" title="1"><child id="a2" title="2"/></child>' +
'<child id="a1" title="3"/></xml>',
''.concat(
'<xml xmlns="http://test.com" id="root">',
'<child id="a1" title="1"><child id="a2" title="2"/></child>',
'<child id="a1" title="3"/></xml>'
),
'text/xml'
)
expect(doc.getElementById('root')).not.toBeNull()
Expand All @@ -96,9 +102,11 @@ describe('XML Namespace Parse', () => {

it('can properly append exist child', () => {
const doc = new DOMParser().parseFromString(
'<xml xmlns="http://test.com" id="root">' +
'<child1 id="a1" title="1"><child11 id="a2" title="2"/></child1>' +
'<child2 id="a1" title="3"/><child3 id="a1" title="3"/></xml>',
''.concat(
'<xml xmlns="http://test.com" id="root">',
'<child1 id="a1" title="1"><child11 id="a2" title="2"/></child1>',
'<child2 id="a1" title="3"/><child3 id="a1" title="3"/></xml>'
),
'text/xml'
)

Expand All @@ -122,9 +130,11 @@ describe('XML Namespace Parse', () => {

it('can properly append exist other child', () => {
const doc = new DOMParser().parseFromString(
'<xml xmlns="http://test.com" id="root">' +
'<child1 id="a1" title="1"><child11 id="a2" title="2"><child/></child11></child1>' +
'<child2 id="a1" title="3"/><child3 id="a1" title="3"/></xml>',
''.concat(
'<xml xmlns="http://test.com" id="root">',
'<child1 id="a1" title="1"><child11 id="a2" title="2"><child/></child11></child1>',
'<child2 id="a1" title="3"/><child3 id="a1" title="3"/></xml>'
),
'text/xml'
)

Expand Down
8 changes: 5 additions & 3 deletions test/test.js
Expand Up @@ -5,9 +5,11 @@ var DOMParser = require('../lib/dom-parser').DOMParser
var XMLSerializer = require('../lib/dom-parser').XMLSerializer

var doc = new DOMParser().parseFromString(
'<xml xmlns="http://test.com" id="root">' +
'<child1 id="a1" title="1"><child11 id="a2" title="2"/></child1>' +
'<child2 id="a1" title="3"/><child3 id="a1" title="3"/></xml>',
''.concat(
'<xml xmlns="http://test.com" id="root">',
'<child1 id="a1" title="1"><child11 id="a2" title="2"/></child1>',
'<child2 id="a1" title="3"/><child3 id="a1" title="3"/></xml>'
),
'text/xml'
)

Expand Down