From f128cef6ad15ab03c5e7700443bf3c33fb32dcdb Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 20:29:26 -0400 Subject: [PATCH 01/18] Create main.yml --- .github/workflows/main.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e8e77bc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: "Release to Marketplace" + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Setup NodeJS" + uses: "actions/setup-node@v2.1.0" + + - name: "Install Dependencies" + run: "npm install" + + - name: "Run Tests" + run: "npm run test" + + - name: "Publish to Marketplace" + uses: "sigma/vsce-publish-action@v0.0.2" + with: + vsce_token: "" From b94ddcb3aef5d43d51754f9e95aac8c33a8fabfc Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 20:38:16 -0400 Subject: [PATCH 02/18] Add VSCE_TOKEN Secret --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e8e77bc..34a8122 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,4 +24,4 @@ jobs: - name: "Publish to Marketplace" uses: "sigma/vsce-publish-action@v0.0.2" with: - vsce_token: "" + vsce_token: ${{ secrets.VSCE_TOKEN }} From 50ebf7aa42c6a6d27d82aafdf9fcf261ce8a4871 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 20:38:44 -0400 Subject: [PATCH 03/18] Rename main.yml to release.yml --- .github/workflows/{main.yml => release.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{main.yml => release.yml} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/release.yml similarity index 100% rename from .github/workflows/main.yml rename to .github/workflows/release.yml From 6f20c656bac3968670befcef84f73aaf768942de Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 20:41:05 -0400 Subject: [PATCH 04/18] Create test.yml --- .github/workflows/test.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bdacc31 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: "Run Tests" + +on: + pull_request: + branches: + - "master" + +jobs: + build: + runs-on: "ubuntu-latest" + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Setup NodeJS" + uses: "actions/setup-node@v2.1.0" + + - name: "Install Dependencies" + run: "npm install" + + - name: "Run Tests" + run: "npm run test" From 1aa74a9fd7db17772f3d714428f23bcfcb0d0ea8 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 20:47:07 -0400 Subject: [PATCH 05/18] Rename Job --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bdacc31..15d66f0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: - "master" jobs: - build: + test: runs-on: "ubuntu-latest" steps: - name: "Checkout" From 397093141c5e189a953d094a318a8d61a6761ce4 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 21:02:52 -0400 Subject: [PATCH 06/18] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34a8122..8410891 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - "v*" jobs: - build: + release: runs-on: "ubuntu-latest" steps: - name: "Checkout" From 045ef3230bc0c862c01680ba5ee0a32bad42be43 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 21:12:30 -0400 Subject: [PATCH 07/18] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 50f1d87..b473c6d 100644 --- a/package.json +++ b/package.json @@ -261,7 +261,7 @@ "compile": "npm run lint && tsc -p ./", "watch": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", - "test": "npm run compile && mocha ./out/test/**/*.js", + "test": "npm run compile && mocha './out/test/**/*.js'", "lint": "tslint -p tslint.json --fix" }, "devDependencies": { From 5f3610ecfdc7d6153d0ae436c5d1a98b4b1c05ff Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 21:18:29 -0400 Subject: [PATCH 08/18] Normalize Line Breaks --- src/test/extension.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 77ef70e..4836349 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -124,19 +124,19 @@ describe("V2XmlFormatter", () => { }); function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`); - const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`); + const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/, ""); + const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`).replace(/\r/, ""); - const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options); + const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, ""); assert.equal(actualFormattedXml, expectedFormattedXml, "Actual formatted XML does not match expected formatted XML."); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`); - const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`); + const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/, ""); + const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`).replace(/\r/, ""); - const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options); + const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, ""); assert.equal(actualMinifiedXml, expectedMinifiedXml, "Actual minified XML does not match expected minified XML."); } From f9265375aa0b17d0dd9a33f5a602f8b80bd26009 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 21:51:57 -0400 Subject: [PATCH 09/18] Replace Deprecated Assertions --- src/test/extension.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 4836349..b8180aa 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -129,7 +129,7 @@ function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, ""); - assert.equal(actualFormattedXml, expectedFormattedXml, "Actual formatted XML does not match expected formatted XML."); + assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { @@ -138,5 +138,5 @@ function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, ""); - assert.equal(actualMinifiedXml, expectedMinifiedXml, "Actual minified XML does not match expected minified XML."); + assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); } From 14dbb32d7be2176b47ab30c7155c26ebc74e18e0 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 21:55:22 -0400 Subject: [PATCH 10/18] Disable Line Length Check --- src/test/extension.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index b8180aa..565a99b 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -129,6 +129,7 @@ function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, ""); + // tslint:disable-next-line assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); } @@ -138,5 +139,6 @@ function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, ""); + // tslint:disable-next-line assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); } From 1a2477fd1967bff9aaee2b2af89db3a0c8a710f9 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:06:42 -0400 Subject: [PATCH 11/18] Bypass Linter Rule --- src/formatting/commands/textToXml.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/formatting/commands/textToXml.ts b/src/formatting/commands/textToXml.ts index 0b9dec0..cf6c4ef 100644 --- a/src/formatting/commands/textToXml.ts +++ b/src/formatting/commands/textToXml.ts @@ -23,6 +23,7 @@ export function textToXml(textEditor: TextEditor): void { .replace(/</g, "<") .replace(/>/g, ">") .replace(/&/g, "&") + // tslint:disable-next-line .replace(/"/g, '"') .replace(/'/g, "'"); From c051d9a9e374768cd8b0cf1a8e3236b6f75a71f1 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:07:00 -0400 Subject: [PATCH 12/18] Add Windows-Specific Test Script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b473c6d..3000246 100644 --- a/package.json +++ b/package.json @@ -262,6 +262,7 @@ "watch": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", "test": "npm run compile && mocha './out/test/**/*.js'", + "test-windows": "npm run compile && mocha ./out/test/**/*.js", "lint": "tslint -p tslint.json --fix" }, "devDependencies": { @@ -277,4 +278,4 @@ "xpath": "0.0.27", "xqlint": "^0.4.1" } -} +} \ No newline at end of file From cd1f9a7dbcaab7a0655d07ecd8ee7bda61b14370 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:11:48 -0400 Subject: [PATCH 13/18] Remove Debugging Changes --- src/test/extension.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 565a99b..dac0a9a 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -124,20 +124,20 @@ describe("V2XmlFormatter", () => { }); function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/, ""); - const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`).replace(/\r/, ""); + const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`); + const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`); - const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, ""); + const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options); // tslint:disable-next-line assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/, ""); - const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`).replace(/\r/, ""); + const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`); + const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`); - const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, ""); + const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options); // tslint:disable-next-line assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); From 07d34f3697c424af8150239820c8110e9d3e46fc Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:14:58 -0400 Subject: [PATCH 14/18] Normalize Line Endings Again Tests are working on Windows, but not Ubuntu for some reason. --- src/test/extension.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index dac0a9a..04d7bff 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -124,20 +124,20 @@ describe("V2XmlFormatter", () => { }); function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`); + const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/, ""); const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`); - const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options); + const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, ""); // tslint:disable-next-line assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`); + const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/, ""); const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`); - const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options); + const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, ""); // tslint:disable-next-line assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); From afd09bcc2ec79247e28858b68f3c0b199e2762d2 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:18:41 -0400 Subject: [PATCH 15/18] Trim Formatted XML --- src/test/extension.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 04d7bff..e99abab 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -124,20 +124,20 @@ describe("V2XmlFormatter", () => { }); function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/, ""); + const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/, "").trim(); const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`); - const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, ""); + const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, "").trim(); // tslint:disable-next-line assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/, ""); + const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/, "").trim(); const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`); - const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, ""); + const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, "").trim(); // tslint:disable-next-line assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); From 767580758652f9505e54dfef050473afa30fae6d Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:25:19 -0400 Subject: [PATCH 16/18] Convert Whitespace to Visible Characters on Error --- src/test/extension.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index e99abab..8734e63 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -130,7 +130,7 @@ function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, "").trim(); // tslint:disable-next-line - assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); + assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml.replace(/\n/, "~n").replace(" ", "~s")}\n\nEXPECTED\n${expectedFormattedXml.replace(/\n/, "~n").replace(" ", "~s")}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { @@ -140,5 +140,5 @@ function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, "").trim(); // tslint:disable-next-line - assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); + assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml.replace(/\n/, "~n").replace(" ", "~s")}\n\nEXPECTED\n${expectedMinifiedXml.replace(/\n/, "~n").replace(" ", "~s")}`); } From b5bff91fd8048d2eb606b194a1e844edc10b0bff Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:30:07 -0400 Subject: [PATCH 17/18] Add Global Flag to Regex --- src/test/extension.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 8734e63..68039e9 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -124,21 +124,21 @@ describe("V2XmlFormatter", () => { }); function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/, "").trim(); + const expectedFormattedXml = TestDataLoader.load(`${fileLabel}.formatted.xml`).replace(/\r/g, ""); const unformattedXml = TestDataLoader.load(`${fileLabel}.unformatted.xml`); - const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/, "").trim(); + const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/g, ""); // tslint:disable-next-line - assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml.replace(/\n/, "~n").replace(" ", "~s")}\n\nEXPECTED\n${expectedFormattedXml.replace(/\n/, "~n").replace(" ", "~s")}`); + assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { - const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/, "").trim(); + const expectedMinifiedXml = TestDataLoader.load(`${fileLabel}.minified.xml`).replace(/\r/g, ""); const unminifiedXml = TestDataLoader.load(`${fileLabel}.unminified.xml`); - const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/, "").trim(); + const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/g, ""); // tslint:disable-next-line - assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml.replace(/\n/, "~n").replace(" ", "~s")}\n\nEXPECTED\n${expectedMinifiedXml.replace(/\n/, "~n").replace(" ", "~s")}`); + assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); } From 45f3680efcc00c4a1b5e02386a2a5747e067c271 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 6 Jul 2020 22:36:59 -0400 Subject: [PATCH 18/18] Make ALL Whitespace Visible on Error --- src/test/extension.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 68039e9..640ec47 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -130,7 +130,7 @@ function testFormatter(xmlFormatter: XmlFormatter, options: XmlFormattingOptions const actualFormattedXml = xmlFormatter.formatXml(unformattedXml, options).replace(/\r/g, ""); // tslint:disable-next-line - assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml}\n\nEXPECTED\n${expectedFormattedXml}`); + assert.ok((actualFormattedXml === expectedFormattedXml), `Actual formatted XML does not match expected formatted XML.\n\nACTUAL\n${actualFormattedXml.replace(/\s/, "~ws~")}\n\nEXPECTED\n${expectedFormattedXml.replace(/\s/, "~ws~")}`); } function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, fileLabel: string): void { @@ -140,5 +140,5 @@ function testMinifier(xmlFormatter: XmlFormatter, options: XmlFormattingOptions, const actualMinifiedXml = xmlFormatter.minifyXml(unminifiedXml, options).replace(/\r/g, ""); // tslint:disable-next-line - assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml}\n\nEXPECTED\n${expectedMinifiedXml}`); + assert.ok((actualMinifiedXml === expectedMinifiedXml), `Actual minified XML does not match expected minified XML.\n\nACTUAL\n${actualMinifiedXml.replace(/\s/, "~ws~")}\n\nEXPECTED\n${expectedMinifiedXml.replace(/\s/, "~ws~")}`); }