mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fix Books Unit Tests (#6702)
* wait for all toc.yml to be found * add event to signal all toc.yml files read * add workspae folder parameter back * remove toc filter
This commit is contained in:
@@ -24,12 +24,17 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
private _extensionContext: vscode.ExtensionContext;
|
||||
private _throttleTimer: any;
|
||||
private _resource: string;
|
||||
private _onReadAllTOCFiles: vscode.EventEmitter<void> = new vscode.EventEmitter<void>();
|
||||
|
||||
constructor(workspaceFolders: vscode.WorkspaceFolder[], extensionContext: vscode.ExtensionContext) {
|
||||
this.getTableOfContentFiles(workspaceFolders).then(() => undefined, (err) => { console.log(err); });
|
||||
this._extensionContext = extensionContext;
|
||||
}
|
||||
|
||||
public get onReadAllTOCFiles(): vscode.Event<void> {
|
||||
return this._onReadAllTOCFiles.event;
|
||||
}
|
||||
|
||||
async getTableOfContentFiles(workspaceFolders: vscode.WorkspaceFolder[]): Promise<void> {
|
||||
let notebookConfig = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||
let maxDepth = notebookConfig[maxBookSearchDepth];
|
||||
@@ -46,6 +51,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
}
|
||||
let bookOpened: boolean = this._tableOfContentPaths.length > 0;
|
||||
vscode.commands.executeCommand('setContext', 'bookOpened', bookOpened);
|
||||
this._onReadAllTOCFiles.fire();
|
||||
}
|
||||
|
||||
async openNotebook(resource: string): Promise<void> {
|
||||
|
||||
@@ -73,14 +73,17 @@ describe('BookTreeViewProvider.getChildren', function (): void {
|
||||
});
|
||||
|
||||
it('should return all book nodes when element is undefined', async function (): Promise<void> {
|
||||
bookTreeViewProvider.onReadAllTOCFiles(async () => {
|
||||
const children = await bookTreeViewProvider.getChildren();
|
||||
should(children).be.Array();
|
||||
should(children.length).equal(1);
|
||||
book = children[0];
|
||||
should(book.title).equal(expectedBook.title);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return all page nodes when element is a book', async function (): Promise<void> {
|
||||
bookTreeViewProvider.onReadAllTOCFiles(async () => {
|
||||
const children = await bookTreeViewProvider.getChildren(book);
|
||||
should(children).be.Array();
|
||||
should(children.length).equal(3);
|
||||
@@ -94,6 +97,7 @@ describe('BookTreeViewProvider.getChildren', function (): void {
|
||||
should(externalLink.title).equal(expectedExternalLink.title);
|
||||
should(externalLink.uri).equal(expectedExternalLink.url);
|
||||
});
|
||||
});
|
||||
|
||||
this.afterAll(async function () {
|
||||
if (fs.existsSync(rootFolderPath)) {
|
||||
|
||||
Reference in New Issue
Block a user