1
1
import { LocalProjectContextController } from './localProjectContextController'
2
- import { SinonStub , stub , assert as sinonAssert , match , restore } from 'sinon'
2
+ import { SinonStub , stub , assert as sinonAssert , match , restore , spy } from 'sinon'
3
3
import * as assert from 'assert'
4
4
import * as fs from 'fs'
5
5
import { Dirent } from 'fs'
@@ -75,12 +75,13 @@ describe('LocalProjectContextController', () => {
75
75
76
76
describe ( 'init' , ( ) => {
77
77
it ( 'should initialize vector library successfully' , async ( ) => {
78
+ const buildIndexSpy = spy ( controller , 'buildIndex' )
78
79
await controller . init ( { vectorLib : vectorLibMock } )
79
80
80
81
sinonAssert . notCalled ( logging . error )
81
82
sinonAssert . called ( vectorLibMock . start )
82
83
const vecLib = await vectorLibMock . start ( )
83
- sinonAssert . called ( vecLib . buildIndex )
84
+ sinonAssert . called ( buildIndexSpy )
84
85
} )
85
86
86
87
it ( 'should handle initialization errors' , async ( ) => {
@@ -92,6 +93,15 @@ describe('LocalProjectContextController', () => {
92
93
} )
93
94
} )
94
95
96
+ describe ( 'buildIndex' , ( ) => {
97
+ it ( 'should build Index with vectorLib' , async ( ) => {
98
+ await controller . init ( { vectorLib : vectorLibMock } )
99
+ const vecLib = await vectorLibMock . start ( )
100
+ await controller . buildIndex ( )
101
+ sinonAssert . called ( vecLib . buildIndex )
102
+ } )
103
+ } )
104
+
95
105
describe ( 'queryVectorIndex' , ( ) => {
96
106
beforeEach ( async ( ) => {
97
107
await controller . init ( { vectorLib : vectorLibMock } )
0 commit comments