Skip to content

Commit

Permalink
test: merge the tests to share resources to fix macos crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jun 11, 2021
1 parent bb2eefc commit 42d2f3a
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions test/auto-languageclient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,51 +35,38 @@ function setupServerManager(client = setupClient()) {

describe("AutoLanguageClient", () => {
describe("determineProjectPath", () => {
it("returns null when a single file is open", async () => {
const client = setupClient()
const textEditor = (await atom.workspace.open(__filename)) as TextEditor
/* eslint-disable-next-line dot-notation */
const projectPath = client["determineProjectPath"](textEditor)
expect(projectPath).toBeNull()
})
it("returns the project path when a file of that project is open", async () => {
// macos has issues with handling too much resources
if (process.platform === "darwin") {
return
}
it("returns the project path for an internal or an external file in the project", async () => {
const client = setupClient()
const serverManager = setupServerManager(client)

// "returns null when a single file is open"

let textEditor = (await atom.workspace.open(__filename)) as TextEditor
/* eslint-disable-next-line dot-notation */
expect(client["determineProjectPath"](textEditor)).toBeNull()

// "returns the project path when a file of that project is open"
const projectPath = __dirname

// gives the open workspace folder
atom.project.addPath(projectPath)
await serverManager.startServer(projectPath)

const textEditor = (await atom.workspace.open(__filename)) as TextEditor
textEditor = (await atom.workspace.open(__filename)) as TextEditor
/* eslint-disable-next-line dot-notation */
expect(client["determineProjectPath"](textEditor)).toBe(normalizePath(projectPath))
})
it("returns the project path for an external file if it is in additional paths", async () => {
// macos has issues with handling too much resources
if (process.platform === "darwin") {
return
}
textEditor.destroy()

// "returns the project path when an external file is open and it is not in additional paths"

const client = setupClient()
const serverManager = setupServerManager(client)

const projectPath = __dirname
const externalDir = join(dirname(projectPath), "lib")
const externalFile = join(externalDir, "main.js")

// gives the open workspace folder
atom.project.addPath(projectPath)
await serverManager.startServer(projectPath)

let textEditor = (await atom.workspace.open(externalFile)) as TextEditor
textEditor = (await atom.workspace.open(externalFile)) as TextEditor
/* eslint-disable-next-line dot-notation */
expect(client["determineProjectPath"](textEditor)).toBeNull()
textEditor.destroy()
Expand Down

0 comments on commit 42d2f3a

Please sign in to comment.