@@ -72,21 +72,40 @@ class MockTextDocument implements TextDocument {
7272}
7373
7474suite ( 'Extension Test Suite' , ( ) => {
75+
76+ const position = new Position ( 0 , 0 ) ;
77+ const token = new MockCancellationToken ( false ) ;
78+ const context = new MockCompletionContext ( ) ;
79+
7580 window . showInformationMessage ( 'Start all tests.' ) ;
7681
77- test ( 'Completes empty document with no items .' , done => {
82+ test ( 'Rejects empty documents .' , done => {
7883 const provider = new ClassCompletionItemProvider ( ) ;
79-
8084 const document = new MockTextDocument ( "" ) ;
81- const position = new Position ( 0 , 0 ) ;
82- const token = new MockCancellationToken ( false ) ;
83- const context = new MockCompletionContext ( ) ;
85+ const result = provider . provideCompletionItems ( document , position , token , context ) as Thenable < CompletionItem [ ] > ;
8486
87+ result . then ( items => { } , ( e ) => {
88+ try {
89+ assert . strictEqual ( e , undefined ) ;
90+ done ( ) ;
91+ } catch ( e ) {
92+ done ( e ) ;
93+ }
94+ } ) ;
95+ } ) ;
96+
97+ test ( 'Rejects outside class attribute.' , done => {
98+ const provider = new ClassCompletionItemProvider ( ) ;
99+ const document = new MockTextDocument ( "<a class=''>" ) ;
85100 const result = provider . provideCompletionItems ( document , position , token , context ) as Thenable < CompletionItem [ ] > ;
86101
87- result . then ( ( items ) => {
88- assert . strictEqual ( items . length , 0 ) ;
89- done ( ) ;
90- } , done ) ;
102+ result . then ( items => { } , ( e ) => {
103+ try {
104+ assert . strictEqual ( e , undefined ) ;
105+ done ( ) ;
106+ } catch ( e ) {
107+ done ( e ) ;
108+ }
109+ } ) ;
91110 } ) ;
92111} ) ;
0 commit comments