-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathreplaceContent.test.mts
More file actions
32 lines (29 loc) · 1010 Bytes
/
replaceContent.test.mts
File metadata and controls
32 lines (29 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { equal } from "node:assert/strict";
import { describe, it } from "node:test";
import { replaceContent } from "../../windows/app.mjs";
describe("replaceContent()", () => {
it("returns same string with no replacements", () => {
// @ts-expect-error intentional use of `undefined`
equal(replaceContent(undefined, {}), undefined);
equal(replaceContent("", {}), "");
equal(replaceContent("content", {}), "content");
});
it("replaces content only if patterns match", () => {
equal(
replaceContent("|$(ReactNativeModulePath)|", {
"\\$\\(ReactNativeModulePath\\)": "Arnold",
"\\$\\(ReactTestAppProjectPath\\)": "Schwarzenegger",
}),
"|Arnold|"
);
});
it("replaces all occurrences of given pattern", () => {
equal(
replaceContent(
"|$(ReactNativeModulePath)|$(ReactNativeModulePath)|$(ReactNativeModulePath)|",
{ "\\$\\(ReactNativeModulePath\\)": "Arnold" }
),
"|Arnold|Arnold|Arnold|"
);
});
});