@@ -34,7 +34,7 @@ temp.track()
34
34
describe ( 'XTerminalElement' , ( ) => {
35
35
const savedPlatform = process . platform
36
36
this . element = null
37
- this . tmpdirObj = null
37
+ this . tmpdir = null
38
38
39
39
const createNewElement = async ( uri = 'x-terminal://somesessionid/' ) => {
40
40
const terminalsSet = new Set ( )
@@ -100,7 +100,7 @@ describe('XTerminalElement', () => {
100
100
} )
101
101
102
102
it ( 'getShellCommand()' , ( ) => {
103
- expect ( this . element . getShellCommand ( ) ) . toBe ( configDefaults . getDefaultShellCommand ( ) )
103
+ expect ( this . element . getShellCommand ( ) ) . toBe ( configDefaults . command )
104
104
} )
105
105
106
106
it ( 'getShellCommand() command set in uri' , async ( ) => {
@@ -129,7 +129,7 @@ describe('XTerminalElement', () => {
129
129
} )
130
130
131
131
it ( 'getTermType()' , ( ) => {
132
- expect ( this . element . getTermType ( ) ) . toBe ( configDefaults . getDefaultTermType ( ) )
132
+ expect ( this . element . getTermType ( ) ) . toBe ( configDefaults . termType )
133
133
} )
134
134
135
135
it ( 'getTermType() name set in uri' , async ( ) => {
@@ -167,7 +167,7 @@ describe('XTerminalElement', () => {
167
167
168
168
it ( 'getCwd()' , async ( ) => {
169
169
const cwd = await this . element . getCwd ( )
170
- expect ( cwd ) . toBe ( configDefaults . getDefaultCwd ( ) )
170
+ expect ( cwd ) . toBe ( configDefaults . cwd )
171
171
} )
172
172
173
173
it ( 'getCwd() cwd set in uri' , async ( ) => {
@@ -179,6 +179,16 @@ describe('XTerminalElement', () => {
179
179
expect ( cwd ) . toBe ( expected )
180
180
} )
181
181
182
+ it ( 'getCwd() ignore cwd in uri if projectCwd is set' , async ( ) => {
183
+ const expected = await temp . mkdir ( 'projectCwd' )
184
+ spyOn ( atom . project , 'getPaths' ) . and . returnValue ( [ expected ] )
185
+ const params = new URLSearchParams ( { projectCwd : true , cwd : this . tmpdir } )
186
+ const url = new URL ( 'x-terminal://?' + params . toString ( ) )
187
+ const element = await createNewElement ( url . href )
188
+ const cwd = await element . getCwd ( )
189
+ expect ( cwd ) . toBe ( expected )
190
+ } )
191
+
182
192
it ( 'getCwd() model getPath() returns valid path' , async ( ) => {
183
193
const previousActiveItem = jasmine . createSpyObj (
184
194
'previousActiveItem' ,
@@ -204,7 +214,7 @@ describe('XTerminalElement', () => {
204
214
)
205
215
const element = await createNewElement ( )
206
216
const cwd = await element . getCwd ( )
207
- expect ( cwd ) . toBe ( configDefaults . getDefaultCwd ( ) )
217
+ expect ( cwd ) . toBe ( configDefaults . cwd )
208
218
} )
209
219
210
220
it ( 'getCwd() non-existent cwd set in uri' , async ( ) => {
@@ -213,14 +223,14 @@ describe('XTerminalElement', () => {
213
223
const url = new URL ( 'x-terminal://?' + params . toString ( ) )
214
224
await createNewElement ( url . href )
215
225
const cwd = await this . element . getCwd ( )
216
- expect ( cwd ) . toBe ( configDefaults . getDefaultCwd ( ) )
226
+ expect ( cwd ) . toBe ( configDefaults . cwd )
217
227
} )
218
228
219
229
it ( 'getCwd() non-existent project path added' , async ( ) => {
220
230
spyOn ( atom . project , 'getPaths' ) . and . returnValue ( [ path . join ( this . tmpdir , 'non-existent-dir' ) ] )
221
231
const element = await createNewElement ( )
222
232
const cwd = await element . getCwd ( )
223
- expect ( cwd ) . toBe ( configDefaults . getDefaultCwd ( ) )
233
+ expect ( cwd ) . toBe ( configDefaults . cwd )
224
234
} )
225
235
226
236
it ( 'getEnv()' , ( ) => {
@@ -1054,6 +1064,56 @@ describe('XTerminalElement', () => {
1054
1064
expect ( this . element . ptyProcess ) . toBeTruthy ( )
1055
1065
} )
1056
1066
1067
+ describe ( 'loaded addons' , ( ) => {
1068
+ const { Terminal } = require ( 'xterm' )
1069
+ const { WebLinksAddon } = require ( 'xterm-addon-web-links' )
1070
+ const { WebglAddon } = require ( 'xterm-addon-webgl' )
1071
+
1072
+ beforeEach ( ( ) => {
1073
+ spyOn ( Terminal . prototype , 'loadAddon' ) . and . callThrough ( )
1074
+ } )
1075
+
1076
+ it ( 'createTerminal() enable web-link addon' , async ( ) => {
1077
+ const params = new URLSearchParams ( { webLinks : true } )
1078
+ const url = new URL ( 'x-terminal://?' + params . toString ( ) )
1079
+ await createNewElement ( url . href )
1080
+ const wasAdded = Terminal . prototype . loadAddon . calls . all ( ) . some ( call => {
1081
+ return call . args [ 0 ] instanceof WebLinksAddon
1082
+ } )
1083
+ expect ( wasAdded ) . toBe ( true )
1084
+ } )
1085
+
1086
+ it ( 'createTerminal() disable web-link addon' , async ( ) => {
1087
+ const params = new URLSearchParams ( { webLinks : false } )
1088
+ const url = new URL ( 'x-terminal://?' + params . toString ( ) )
1089
+ await createNewElement ( url . href )
1090
+ const wasAdded = Terminal . prototype . loadAddon . calls . all ( ) . some ( call => {
1091
+ return call . args [ 0 ] instanceof WebLinksAddon
1092
+ } )
1093
+ expect ( wasAdded ) . toBe ( false )
1094
+ } )
1095
+
1096
+ it ( 'createTerminal() enable webgl addon' , async ( ) => {
1097
+ const params = new URLSearchParams ( { webgl : true } )
1098
+ const url = new URL ( 'x-terminal://?' + params . toString ( ) )
1099
+ await createNewElement ( url . href )
1100
+ const wasAdded = Terminal . prototype . loadAddon . calls . all ( ) . some ( call => {
1101
+ return call . args [ 0 ] instanceof WebglAddon
1102
+ } )
1103
+ expect ( wasAdded ) . toBe ( true )
1104
+ } )
1105
+
1106
+ it ( 'createTerminal() disable webgl addon' , async ( ) => {
1107
+ const params = new URLSearchParams ( { webgl : false } )
1108
+ const url = new URL ( 'x-terminal://?' + params . toString ( ) )
1109
+ await createNewElement ( url . href )
1110
+ const wasAdded = Terminal . prototype . loadAddon . calls . all ( ) . some ( call => {
1111
+ return call . args [ 0 ] instanceof WebglAddon
1112
+ } )
1113
+ expect ( wasAdded ) . toBe ( false )
1114
+ } )
1115
+ } )
1116
+
1057
1117
it ( 'restartPtyProcess() check new pty process created' , async ( ) => {
1058
1118
const oldPtyProcess = this . element . ptyProcess
1059
1119
const newPtyProcess = jasmine . createSpyObj ( 'ptyProcess' ,
@@ -1820,23 +1880,23 @@ describe('XTerminalElement', () => {
1820
1880
} )
1821
1881
1822
1882
it ( 'use ctrl+wheelScrollUp font already at maximum' , ( ) => {
1823
- this . element . model . profile . fontSize = configDefaults . getMaximumFontSize ( )
1883
+ this . element . model . profile . fontSize = configDefaults . maximumFontSize
1824
1884
const wheelEvent = new WheelEvent ( 'wheel' , {
1825
1885
deltaY : - 150 ,
1826
1886
ctrlKey : true ,
1827
1887
} )
1828
1888
this . element . terminalDiv . dispatchEvent ( wheelEvent )
1829
- expect ( this . element . model . profile . fontSize ) . toBe ( configDefaults . getMaximumFontSize ( ) )
1889
+ expect ( this . element . model . profile . fontSize ) . toBe ( configDefaults . maximumFontSize )
1830
1890
} )
1831
1891
1832
1892
it ( 'use ctrl+wheelScrollDown font already at minimum' , ( ) => {
1833
- this . element . model . profile . fontSize = configDefaults . getMinimumFontSize ( )
1893
+ this . element . model . profile . fontSize = configDefaults . minimumFontSize
1834
1894
const wheelEvent = new WheelEvent ( 'wheel' , {
1835
1895
deltaY : 150 ,
1836
1896
ctrlKey : true ,
1837
1897
} )
1838
1898
this . element . terminalDiv . dispatchEvent ( wheelEvent )
1839
- expect ( this . element . model . profile . fontSize ) . toBe ( configDefaults . getMinimumFontSize ( ) )
1899
+ expect ( this . element . model . profile . fontSize ) . toBe ( configDefaults . minimumFontSize )
1840
1900
} )
1841
1901
1842
1902
it ( 'getXtermOptions() default options' , ( ) => {
0 commit comments