Skip to content

Commit 2510c82

Browse files
Cyprien AutexierCyprien Autexier
authored andcommitted
add repro test for #22
1 parent af41d7e commit 2510c82

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Tests/XmlPatch/xmlPatcher.spec.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("XML Patcher", () => {
3737

3838
expect(result).toEqual('<rootNode><name>a name</name><childNode size="42"><leaf color="#aaaaaa"/><leaf color="#000000"/></childNode></rootNode>');
3939
});
40-
40+
4141
it(": should support basic node content replace.", () => {
4242
var patcher = new xmlatcher.XmlPatcher([
4343
{
@@ -87,4 +87,30 @@ describe("XML Patcher", () => {
8787
});
8888
});
8989
});
90+
91+
describe("Regression tests", () => {
92+
it(": test #22 find by attribute value is working properly", () => {
93+
var source = '<?xml version="1.0" encoding="utf-8"?> \
94+
<configuration> \
95+
<connectionStrings> \
96+
<add name="db" connectionString="Data Source=local_dev;Database=Internal_DEV;Type System Version=SQL Server 2012;User ID=someone;Password=something;Persist Security Info=True" providerName="System.Data.SqlClient" /> \
97+
<add name="example" connectionString="Data Source=xx;Database=xx;Type System Version=SQL Server 2012;User ID=xx;Password=xx;Persist Security Info=True" providerName="System.Data.SqlClient" /> \
98+
</connectionStrings> \
99+
<appSettings> \
100+
<!-- Specify a super user name, for example \
101+
<add key="SuperUser" value="US\jshkolnik" /> \
102+
--> \
103+
<add key="SuperUser" value="#should_be_replaced#" /> \
104+
</appSettings> \
105+
</configuration>';
106+
var patcher = new xmlatcher.XmlPatcher([
107+
{
108+
op: "replace", path: "/configuration/appSettings/add[@key='SuperUser']/@value", value : "a value"
109+
}
110+
], {});
111+
var result = patcher.apply(source);
112+
console.log(result);
113+
expect(result).not.toContain('#should_be_replaced#');
114+
});
115+
});
90116
});

0 commit comments

Comments
 (0)