Skip to content

Commit b0f30d8

Browse files
committed
test: takes the focus
1 parent fbbbc20 commit b0f30d8

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

test/adapters/show-document-adapter.test.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ describe("ShowDocumentAdapter", () => {
4141
describe("shows the document inside Atom", async () => {
4242
const helloPath = join(dirname(__dirname), "fixtures", "hello.js")
4343

44+
async function canShowDocumentInAtom(params: ShowDocumentParams) {
45+
const { success } = await ShowDocumentAdapter.showDocument(params)
46+
expect(success).to.be.true
47+
48+
const editor = atom.workspace.getTextEditors()[0]
49+
expect(editor instanceof TextEditor).to.be.true
50+
51+
expect(editor!.getPath()).includes(helloPath)
52+
expect(editor!.getText()).includes(`atom.notifications.addSuccess("Hello World")`)
53+
54+
return editor
55+
}
56+
4457
beforeEach(() => {
4558
atom.workspace.getTextEditors().forEach((ed) => {
4659
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -53,15 +66,16 @@ describe("ShowDocumentAdapter", () => {
5366
const params: ShowDocumentParams = {
5467
uri: helloPath,
5568
}
69+
await canShowDocumentInAtom(params)
70+
})
5671

57-
const { success } = await ShowDocumentAdapter.showDocument(params)
58-
expect(success).to.be.true
59-
60-
const editor = atom.workspace.getTextEditors()[0]
61-
expect(editor instanceof TextEditor).to.be.true
62-
63-
expect(editor!.getPath()).includes(helloPath)
64-
expect(editor!.getText()).includes(`atom.notifications.addSuccess("Hello World")`)
72+
it("takes the focus", async () => {
73+
const params: ShowDocumentParams = {
74+
uri: helloPath,
75+
takeFocus: true,
76+
}
77+
const editor = await canShowDocumentInAtom(params)
78+
expect(atom.workspace.getActivePane()?.getItems()[0]).equal(editor)
6579
})
6680
})
6781

0 commit comments

Comments
 (0)