Skip to content

Commit

Permalink
adjust for both NodeJS and Chrome
Browse files Browse the repository at this point in the history
remove a duplicate test
  • Loading branch information
jeremymeng committed Jan 10, 2024
1 parent f1730b5 commit 3ab2efe
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions sdk/core/core-xml/test/xml.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ describe("XML serializer", function () {
// @ts-expect-error - intentional error for test
await parseXML(undefined);
assert.fail("Expected error");
} catch (error: any) {
} catch (err) {
assert.ok(err instanceof Error);
const error = err as Error;
assert.ok(
error.message.indexOf("This page contains the following errors") !== -1 || // Chrome
error.message.includes("Document is empty") || // NodeJS v8
error.message.includes("This page contains the following errors") || // Chrome
(error.message.startsWith("XML Parsing Error: syntax error") &&
error.message.includes("undefined")), // Firefox
`error.message ("${error.message}") should have contained "Document is empty" or "undefined"`,
Expand All @@ -26,9 +29,12 @@ describe("XML serializer", function () {
// @ts-expect-error - intentional error for test
await parseXML(null);
assert.fail("Expected error");
} catch (error: any) {
} catch (err) {
assert.ok(err instanceof Error);
const error = err as Error;
assert.ok(
error.message.indexOf("This page contains the following errors") !== -1 || // Chrome
error.message.includes("Document is empty") || // NodeJS v8
error.message.includes("This page contains the following errors") || // Chrome
(error.message.startsWith("XML Parsing Error: syntax error") &&
error.message.includes("null")), // Firefox
`error.message ("${error.message}") should have contained "Document is empty" or "null"`,
Expand Down Expand Up @@ -442,24 +448,6 @@ describe("XML serializer", function () {
);
});

it("with element with attribute and value", async function () {
const xml = stringifyXML(
{
fruit: {
$: {
healthy: "true",
},
_: "yum",
},
},
{ rootName: "fruits" },
);
assert.deepStrictEqual(
xml,
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><fruits><fruit healthy="true">yum</fruit></fruits>`,
);
});

it("with element with child empty element", async function () {
const xml = stringifyXML(
{
Expand Down

0 comments on commit 3ab2efe

Please sign in to comment.