fix: build image URL regexes at call time, not module load time
This commit is contained in:
1 parent
2f7d0a7fb2
commit
3bab2edc41
2 files changed
+34
-13
No files matched your search
@@ -20,8 +20,14 @@ describe("downloadCommentImages", () => {
|
||||
let fsMkdirSpy: any;
|
||||
let fsWriteFileSpy: any;
|
||||
let fetchSpy: any;
|
||||
let savedServerUrl: string | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
// Pin GITHUB_SERVER_URL so tests pass regardless of runner environment.
|
||||
// The image-downloader reads process.env directly at call time.
|
||||
savedServerUrl = process.env.GITHUB_SERVER_URL;
|
||||
process.env.GITHUB_SERVER_URL = "https://github.com";
|
||||
|
||||
// Spy on console methods
|
||||
consoleLogSpy = spyOn(console, "log").mockImplementation(() => {});
|
||||
consoleWarnSpy = spyOn(console, "warn").mockImplementation(() => {});
|
||||
@@ -36,6 +42,13 @@ describe("downloadCommentImages", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Restore GITHUB_SERVER_URL
|
||||
if (savedServerUrl !== undefined) {
|
||||
process.env.GITHUB_SERVER_URL = savedServerUrl;
|
||||
} else {
|
||||
delete process.env.GITHUB_SERVER_URL;
|
||||
}
|
||||
|
||||
consoleLogSpy.mockRestore();
|
||||
consoleWarnSpy.mockRestore();
|
||||
consoleErrorSpy.mockRestore();
|
||||
|
||||
Reference in new issue
Block a user