4
4
import { assert } from 'chai' ;
5
5
import { mock } from 'ts-mockito' ;
6
6
import * as TypeMoq from 'typemoq' ;
7
- import { CancellationToken , CodeActionContext , Position , Selection } from 'vscode' ;
7
+ import { Position , Selection } from 'vscode' ;
8
8
import { ExperimentService } from '../../client/common/experiments/service' ;
9
9
import { IExperimentService } from '../../client/common/types' ;
10
10
import { TensorBoardCodeActionProvider } from '../../client/tensorBoard/tensorBoardCodeActionProvider' ;
@@ -14,27 +14,18 @@ suite('TensorBoard code action provider', () => {
14
14
let experimentService : IExperimentService ;
15
15
let codeActionProvider : TensorBoardCodeActionProvider ;
16
16
let selection : TypeMoq . IMock < Selection > ;
17
- let context : TypeMoq . IMock < CodeActionContext > ;
18
- let token : TypeMoq . IMock < CancellationToken > ;
19
17
20
18
setup ( ( ) => {
21
19
experimentService = mock ( ExperimentService ) ;
22
20
codeActionProvider = new TensorBoardCodeActionProvider ( experimentService , [ ] ) ;
23
- context = TypeMoq . Mock . ofType < CodeActionContext > ( ) ;
24
- token = TypeMoq . Mock . ofType < CancellationToken > ( ) ;
25
21
} ) ;
26
22
27
23
test ( 'Provides code action for Python files' , ( ) => {
28
24
// eslint-disable-next-line @typescript-eslint/no-unused-vars
29
25
const document = new MockDocument ( 'import foo\nimport tensorboard' , 'foo.py' , async ( _doc ) => true ) ;
30
26
selection = TypeMoq . Mock . ofType < Selection > ( ) ;
31
27
selection . setup ( ( s ) => s . active ) . returns ( ( ) => new Position ( 1 , 0 ) ) ;
32
- const codeActions = codeActionProvider . provideCodeActions (
33
- document ,
34
- selection . object ,
35
- context . object ,
36
- token . object
37
- ) ;
28
+ const codeActions = codeActionProvider . provideCodeActions ( document , selection . object ) ;
38
29
assert . ok (
39
30
codeActions . length > 0 ,
40
31
'Failed to provide code action for Python file containing tensorboard import'
@@ -44,12 +35,7 @@ suite('TensorBoard code action provider', () => {
44
35
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45
36
const document = new MockDocument ( 'import tensorboard' , 'foo.ipynb' , async ( _doc ) => true ) ;
46
37
selection . setup ( ( s ) => s . active ) . returns ( ( ) => new Position ( 0 , 0 ) ) ;
47
- const codeActions = codeActionProvider . provideCodeActions (
48
- document ,
49
- selection . object ,
50
- context . object ,
51
- token . object
52
- ) ;
38
+ const codeActions = codeActionProvider . provideCodeActions ( document , selection . object ) ;
53
39
assert . ok (
54
40
codeActions . length > 0 ,
55
41
'Failed to provide code action for Python ipynb containing tensorboard import'
@@ -59,24 +45,14 @@ suite('TensorBoard code action provider', () => {
59
45
// eslint-disable-next-line @typescript-eslint/no-unused-vars
60
46
const document = new MockDocument ( 'import foo' , 'foo.ipynb' , async ( _doc ) => true ) ;
61
47
selection . setup ( ( s ) => s . active ) . returns ( ( ) => new Position ( 0 , 0 ) ) ;
62
- const codeActions = codeActionProvider . provideCodeActions (
63
- document ,
64
- selection . object ,
65
- context . object ,
66
- token . object
67
- ) ;
48
+ const codeActions = codeActionProvider . provideCodeActions ( document , selection . object ) ;
68
49
assert . ok ( codeActions . length === 0 , 'Provided code action for file without tensorboard import' ) ;
69
50
} ) ;
70
51
test ( 'Does not provide code action if cursor is not on line containing tensorboard import' , ( ) => {
71
52
// eslint-disable-next-line @typescript-eslint/no-unused-vars
72
53
const document = new MockDocument ( 'import foo\nimport tensorboard' , 'foo.py' , async ( _doc ) => true ) ;
73
54
selection . setup ( ( s ) => s . active ) . returns ( ( ) => new Position ( 0 , 0 ) ) ;
74
- const codeActions = codeActionProvider . provideCodeActions (
75
- document ,
76
- selection . object ,
77
- context . object ,
78
- token . object
79
- ) ;
55
+ const codeActions = codeActionProvider . provideCodeActions ( document , selection . object ) ;
80
56
assert . ok (
81
57
codeActions . length === 0 ,
82
58
'Provided code action for file even though cursor was not on line containing import'
0 commit comments