Skip to content

refactor: clean up testing files #3769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSDOM } from "jsdom"
import { LocationLike } from "../../unit/util.test"
import { LocationLike } from "../../util.test"

describe("login", () => {
describe("there is an element with id 'base'", () => {
Expand Down Expand Up @@ -36,7 +36,7 @@ describe("login", () => {
document.body.appendChild(mockElement)
spy.mockImplementation(() => mockElement)
// Load file
require("../../../src/browser/pages/login")
require("../../../../src/browser/pages/login")

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

// It's called once by getOptions in the top of the file
// and then another to get the base element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getNlsConfiguration,
nlsConfigElementId,
setBodyBackgroundToThemeBackgroundColor,
} from "../../../src/browser/pages/vscode"
} from "../../../../src/browser/pages/vscode"

describe("vscode", () => {
describe("getNlsConfiguration", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { JSDOM } from "jsdom"
import { registerServiceWorker } from "../../src/browser/register"
import { createLoggerMock } from "../utils/helpers"
import { LocationLike } from "./util.test"
import { registerServiceWorker } from "../../../src/browser/register"
import { createLoggerMock } from "../../utils/helpers"
import { LocationLike } from "../util.test"

describe("register", () => {
describe("when navigator and serviceWorker are defined", () => {
Expand Down Expand Up @@ -50,7 +50,7 @@ describe("register", () => {

it("should register a ServiceWorker", () => {
// Load service worker like you would in the browser
require("../../src/browser/register")
require("../../../src/browser/register")
expect(mockRegisterFn).toHaveBeenCalled()
expect(mockRegisterFn).toHaveBeenCalledTimes(1)
})
Expand All @@ -64,7 +64,7 @@ describe("register", () => {
})

// Load service worker like you would in the browser
require("../../src/browser/register")
require("../../../src/browser/register")

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

it("should log an error", () => {
// Load service worker like you would in the browser
require("../../src/browser/register")
require("../../../src/browser/register")
expect(loggerModule.logger.error).toHaveBeenCalled()
expect(loggerModule.logger.error).toHaveBeenCalledTimes(1)
expect(loggerModule.logger.error).toHaveBeenCalledWith("[Service Worker] navigator is undefined")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("serviceWorker", () => {
})

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

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

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

it("should do nothing when 'fetch' is called", async () => {
require("../../src/browser/serviceWorker.ts")
require("../../../src/browser/serviceWorker.ts")
emit("fetch")
expect(spy).not.toHaveBeenCalled()
})

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

// Activate serviceWorker
Expand Down
4 changes: 1 addition & 3 deletions test/unit/node/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,7 @@ describe("pathToFsPath", () => {
util
// @ts-expect-error We need to check other types
.pathToFsPath({}),
).toThrow(
`Could not compute fsPath from given uri. Expected path to be of type string, but was of type undefined.`,
)
).toThrow(`Could not compute fsPath from given uri. Expected path to be of type string, but was of type undefined.`)
})
it("should not throw an error for a string array", () => {
// @ts-expect-error We need to check other types
Expand Down