Merge pull request #3769 from cdr/jsjoeio-chore-cleanup

refactor: clean up testing files
This commit is contained in:
Joe Previte 2021-07-12 17:19:41 -07:00 committed by GitHub
commit 723a2745f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 17 deletions

View File

@ -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'", () => {
@ -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")
@ -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

View File

@ -6,7 +6,7 @@ import {
getNlsConfiguration,
nlsConfigElementId,
setBodyBackgroundToThemeBackgroundColor,
} from "../../../src/browser/pages/vscode"
} from "../../../../src/browser/pages/vscode"
describe("vscode", () => {
describe("getNlsConfiguration", () => {

View File

@ -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", () => {
@ -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)
})
@ -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()
@ -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")

View File

@ -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)
@ -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

View File

@ -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