Skip to content

Commit 723a274

Browse files
authored
Merge pull request #3769 from cdr/jsjoeio-chore-cleanup
refactor: clean up testing files
2 parents a5cf018 + fc16f7e commit 723a274

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

test/browser/pages/login.test.ts renamed to test/unit/browser/pages/login.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { JSDOM } from "jsdom"
2-
import { LocationLike } from "../../unit/util.test"
2+
import { LocationLike } from "../../util.test"
33

44
describe("login", () => {
55
describe("there is an element with id 'base'", () => {
@@ -36,7 +36,7 @@ describe("login", () => {
3636
document.body.appendChild(mockElement)
3737
spy.mockImplementation(() => mockElement)
3838
// Load file
39-
require("../../../src/browser/pages/login")
39+
require("../../../../src/browser/pages/login")
4040

4141
const el: HTMLInputElement | null = document.querySelector("input#base")
4242
expect(el?.value).toBe("/hello-world")
@@ -80,7 +80,7 @@ describe("login", () => {
8080
it("should do nothing", () => {
8181
spy.mockImplementation(() => null)
8282
// Load file
83-
require("../../../src/browser/pages/login")
83+
require("../../../../src/browser/pages/login")
8484

8585
// It's called once by getOptions in the top of the file
8686
// and then another to get the base element

test/unit/browser/vscode.test.ts renamed to test/unit/browser/pages/vscode.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getNlsConfiguration,
77
nlsConfigElementId,
88
setBodyBackgroundToThemeBackgroundColor,
9-
} from "../../../src/browser/pages/vscode"
9+
} from "../../../../src/browser/pages/vscode"
1010

1111
describe("vscode", () => {
1212
describe("getNlsConfiguration", () => {

test/unit/register.test.ts renamed to test/unit/browser/register.test.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { JSDOM } from "jsdom"
2-
import { registerServiceWorker } from "../../src/browser/register"
3-
import { createLoggerMock } from "../utils/helpers"
4-
import { LocationLike } from "./util.test"
2+
import { registerServiceWorker } from "../../../src/browser/register"
3+
import { createLoggerMock } from "../../utils/helpers"
4+
import { LocationLike } from "../util.test"
55

66
describe("register", () => {
77
describe("when navigator and serviceWorker are defined", () => {
@@ -50,7 +50,7 @@ describe("register", () => {
5050

5151
it("should register a ServiceWorker", () => {
5252
// Load service worker like you would in the browser
53-
require("../../src/browser/register")
53+
require("../../../src/browser/register")
5454
expect(mockRegisterFn).toHaveBeenCalled()
5555
expect(mockRegisterFn).toHaveBeenCalledTimes(1)
5656
})
@@ -64,7 +64,7 @@ describe("register", () => {
6464
})
6565

6666
// Load service worker like you would in the browser
67-
require("../../src/browser/register")
67+
require("../../../src/browser/register")
6868

6969
expect(mockRegisterFn).toHaveBeenCalled()
7070
expect(loggerModule.logger.error).toHaveBeenCalled()
@@ -88,7 +88,7 @@ describe("register", () => {
8888

8989
it("should log an error", () => {
9090
// Load service worker like you would in the browser
91-
require("../../src/browser/register")
91+
require("../../../src/browser/register")
9292
expect(loggerModule.logger.error).toHaveBeenCalled()
9393
expect(loggerModule.logger.error).toHaveBeenCalledTimes(1)
9494
expect(loggerModule.logger.error).toHaveBeenCalledWith("[Service Worker] navigator is undefined")

test/unit/serviceWorker.test.ts renamed to test/unit/browser/serviceWorker.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("serviceWorker", () => {
5858
})
5959

6060
it("should add 3 listeners: install, activate and fetch", () => {
61-
require("../../src/browser/serviceWorker.ts")
61+
require("../../../src/browser/serviceWorker.ts")
6262
const listenerEventNames = listeners.map((listener) => listener.event)
6363

6464
expect(listeners).toHaveLength(3)
@@ -68,20 +68,20 @@ describe("serviceWorker", () => {
6868
})
6969

7070
it("should call the proper callbacks for 'install'", async () => {
71-
require("../../src/browser/serviceWorker.ts")
71+
require("../../../src/browser/serviceWorker.ts")
7272
emit("install")
7373
expect(spy).toHaveBeenCalledWith("[Service Worker] installed")
7474
expect(spy).toHaveBeenCalledTimes(1)
7575
})
7676

7777
it("should do nothing when 'fetch' is called", async () => {
78-
require("../../src/browser/serviceWorker.ts")
78+
require("../../../src/browser/serviceWorker.ts")
7979
emit("fetch")
8080
expect(spy).not.toHaveBeenCalled()
8181
})
8282

8383
it("should call the proper callbacks for 'activate'", async () => {
84-
require("../../src/browser/serviceWorker.ts")
84+
require("../../../src/browser/serviceWorker.ts")
8585
emit("activate")
8686

8787
// Activate serviceWorker

test/unit/node/util.test.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,7 @@ describe("pathToFsPath", () => {
469469
util
470470
// @ts-expect-error We need to check other types
471471
.pathToFsPath({}),
472-
).toThrow(
473-
`Could not compute fsPath from given uri. Expected path to be of type string, but was of type undefined.`,
474-
)
472+
).toThrow(`Could not compute fsPath from given uri. Expected path to be of type string, but was of type undefined.`)
475473
})
476474
it("should not throw an error for a string array", () => {
477475
// @ts-expect-error We need to check other types

0 commit comments

Comments
 (0)