@@ -41,6 +41,19 @@ describe("ShowDocumentAdapter", () => {
41
41
describe ( "shows the document inside Atom" , async ( ) => {
42
42
const helloPath = join ( dirname ( __dirname ) , "fixtures" , "hello.js" )
43
43
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
+
44
57
beforeEach ( ( ) => {
45
58
atom . workspace . getTextEditors ( ) . forEach ( ( ed ) => {
46
59
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -53,15 +66,16 @@ describe("ShowDocumentAdapter", () => {
53
66
const params : ShowDocumentParams = {
54
67
uri : helloPath ,
55
68
}
69
+ await canShowDocumentInAtom ( params )
70
+ } )
56
71
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 )
65
79
} )
66
80
} )
67
81
0 commit comments