Преглед изворни кода

fix(deps): update dependency fast-xml-parser to v5 (#4358)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Riccio <[email protected]>
Co-authored-by: cte <[email protected]>
renovate[bot] пре 6 месеци
родитељ
комит
639cace3f7
3 измењених фајлова са 43 додато и 26 уклоњено
  1. 11 6
      pnpm-lock.yaml
  2. 1 1
      src/package.json
  3. 31 19
      src/utils/__tests__/xml.test.ts

+ 11 - 6
pnpm-lock.yaml

@@ -643,8 +643,8 @@ importers:
         specifier: ^3.1.3
         specifier: ^3.1.3
         version: 3.1.3
         version: 3.1.3
       fast-xml-parser:
       fast-xml-parser:
-        specifier: ^4.5.1
-        version: 4.5.3
+        specifier: ^5.0.0
+        version: 5.2.3
       fastest-levenshtein:
       fastest-levenshtein:
         specifier: ^1.0.16
         specifier: ^1.0.16
         version: 1.0.16
         version: 1.0.16
@@ -6401,8 +6401,8 @@ packages:
     resolution: {integrity: sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==}
     resolution: {integrity: sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==}
     hasBin: true
     hasBin: true
 
 
-  fast-xml-parser@4.5.3:
-    resolution: {integrity: sha512-RKihhV+SHsIUGXObeVy9AXiBbFwkVk7Syp8XgwN5U3JV416+Gwp/GO9i0JYKmikykgz/UHRrrV4ROuZEo/T0ig==}
+  fast-xml-parser@5.2.3:
+    resolution: {integrity: sha512-OdCYfRqfpuLUFonTNjvd30rCBZUneHpSQkCqfaeWQ9qrKcl6XlWeDBNVwGb+INAIxRshuN2jF+BE0L6gbBO2mw==}
     hasBin: true
     hasBin: true
 
 
   [email protected]:
   [email protected]:
@@ -9646,6 +9646,9 @@ packages:
   [email protected]:
   [email protected]:
     resolution: {integrity: sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==}
     resolution: {integrity: sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==}
 
 
+  [email protected]:
+    resolution: {integrity: sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==}
+
   [email protected]:
   [email protected]:
     resolution: {integrity: sha512-eJe5caH6Pi5oMMeQtIoBPpvNu/s4jiyb63u5tkHNnQXomK+puyQ5i+Z5iTLBr/xUz/pIcps0NSfzzFI34+gAXg==}
     resolution: {integrity: sha512-eJe5caH6Pi5oMMeQtIoBPpvNu/s4jiyb63u5tkHNnQXomK+puyQ5i+Z5iTLBr/xUz/pIcps0NSfzzFI34+gAXg==}
     engines: {node: '>=12.0.0'}
     engines: {node: '>=12.0.0'}
@@ -16899,9 +16902,9 @@ snapshots:
     dependencies:
     dependencies:
       strnum: 1.1.2
       strnum: 1.1.2
 
 
-  fast-xml-parser@4.5.3:
+  fast-xml-parser@5.2.3:
     dependencies:
     dependencies:
-      strnum: 1.1.2
+      strnum: 2.1.1
 
 
   [email protected]: {}
   [email protected]: {}
 
 
@@ -20979,6 +20982,8 @@ snapshots:
 
 
   [email protected]: {}
   [email protected]: {}
 
 
+  [email protected]: {}
+
   [email protected]: {}
   [email protected]: {}
 
 
   [email protected]: {}
   [email protected]: {}

+ 1 - 1
src/package.json

@@ -378,7 +378,7 @@
 		"diff": "^5.2.0",
 		"diff": "^5.2.0",
 		"diff-match-patch": "^1.0.5",
 		"diff-match-patch": "^1.0.5",
 		"fast-deep-equal": "^3.1.3",
 		"fast-deep-equal": "^3.1.3",
-		"fast-xml-parser": "^4.5.1",
+		"fast-xml-parser": "^5.0.0",
 		"fastest-levenshtein": "^1.0.16",
 		"fastest-levenshtein": "^1.0.16",
 		"fzf": "^0.5.2",
 		"fzf": "^0.5.2",
 		"get-folder-size": "^5.0.0",
 		"get-folder-size": "^5.0.0",

+ 31 - 19
src/utils/__tests__/xml.test.ts

@@ -117,35 +117,47 @@ describe("parseXml", () => {
 
 
 	describe("error handling", () => {
 	describe("error handling", () => {
 		it("wraps parser errors with a descriptive message", () => {
 		it("wraps parser errors with a descriptive message", () => {
-			// Use jest.spyOn to mock the XMLParser implementation
+			// Create a mock implementation that throws an error
 			const mockParseFn = jest.fn().mockImplementation(() => {
 			const mockParseFn = jest.fn().mockImplementation(() => {
 				throw new Error("Simulated parsing error")
 				throw new Error("Simulated parsing error")
 			})
 			})
 
 
+			// Create a mock parser instance
 			const mockParserInstance = {
 			const mockParserInstance = {
 				parse: mockParseFn,
 				parse: mockParseFn,
 			}
 			}
 
 
-			// Spy on the XMLParser constructor to return our mock
-			const parserSpy = jest
-				.spyOn(require("fast-xml-parser"), "XMLParser")
-				.mockImplementation(() => mockParserInstance)
-
-			// Test that our function wraps the error appropriately
-			expect(() => parseXml("<root></root>")).toThrow("Failed to parse XML: Simulated parsing error")
-
-			// Verify the parser was called with the expected options
-			expect(parserSpy).toHaveBeenCalledWith({
-				ignoreAttributes: false,
-				attributeNamePrefix: "@_",
-				parseAttributeValue: false,
-				parseTagValue: false,
-				trimValues: true,
-				stopNodes: [],
+			// Create a mock constructor function
+			const MockXMLParser = jest.fn().mockImplementation(() => mockParserInstance)
+
+			// Save the original XMLParser
+			const { XMLParser } = jest.requireActual("fast-xml-parser")
+
+			// Replace the XMLParser with our mock
+			jest.doMock("fast-xml-parser", () => ({
+				XMLParser: MockXMLParser,
+			}))
+
+			// Import the module with our mocked dependency
+			jest.isolateModules(() => {
+				const { parseXml } = require("../xml")
+
+				// Test that our function wraps the error appropriately
+				expect(() => parseXml("<root></root>")).toThrow("Failed to parse XML: Simulated parsing error")
+
+				// Verify the parser was called with the expected options
+				expect(MockXMLParser).toHaveBeenCalledWith({
+					ignoreAttributes: false,
+					attributeNamePrefix: "@_",
+					parseAttributeValue: false,
+					parseTagValue: false,
+					trimValues: true,
+					stopNodes: [],
+				})
 			})
 			})
 
 
-			// Cleanup
-			parserSpy.mockRestore()
+			// Restore the original module
+			jest.dontMock("fast-xml-parser")
 		})
 		})
 	})
 	})
 })
 })