forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
1,774 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// | ||
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING | ||
// | ||
// This file is providing the test runner to use when running extension tests. | ||
// By default the test runner in use is Mocha based. | ||
// | ||
// You can provide your own test runner if you want to override it by exporting | ||
// a function run(testRoot: string, clb: (error:Error) => void) that the extension | ||
// host can call to run the tests. The test runner is expected to use console.log | ||
// to report the results back to the caller. When the tests are finished, return | ||
// a possible error to the callback or null if none. | ||
|
||
const testRunner = require('vscode/lib/testrunner'); | ||
|
||
// You can directly control Mocha options by uncommenting the following lines | ||
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info | ||
testRunner.configure({ | ||
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.) | ||
useColors: process.platform !== 'win32', // colored output from test results (only windows cannot handle) | ||
timeout: 60000 | ||
}); | ||
|
||
export = testRunner; |
75 changes: 75 additions & 0 deletions
75
extensions/markdown/src/test/tableOfContentsProvider.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import * as vscode from 'vscode'; | ||
|
||
import { TableOfContentsProvider } from '../tableOfContentsProvider'; | ||
import { MarkdownEngine } from '../markdownEngine'; | ||
|
||
suite('markdown.TableOfContentsProvider', () => { | ||
test('Should not return anything for empty document', async () => { | ||
const doc = new InMemoryDocument(vscode.Uri.parse('test.md'), ''); | ||
const provider = new TableOfContentsProvider(new MarkdownEngine(), doc); | ||
|
||
assert.strictEqual(await provider.lookup(''), undefined); | ||
assert.strictEqual(await provider.lookup('foo'), undefined); | ||
}); | ||
}); | ||
|
||
class InMemoryDocument implements vscode.TextDocument { | ||
private readonly _lines: string[]; | ||
|
||
constructor( | ||
public readonly uri: vscode.Uri, | ||
contents: string | ||
) { | ||
this._lines = contents.split(/\n/g); | ||
} | ||
|
||
fileName: string = ''; | ||
isUntitled: boolean = false; | ||
languageId: string = ''; | ||
version: number = 1; | ||
isDirty: boolean = false; | ||
isClosed: boolean = false; | ||
eol: vscode.EndOfLine = vscode.EndOfLine.LF; | ||
|
||
get lineCount(): number { | ||
return this._lines.length; | ||
} | ||
|
||
lineAt(line: any): vscode.TextLine { | ||
return { | ||
lineNumber: line, | ||
text: this._lines[line], | ||
range: new vscode.Range(0, 0, 0, 0), | ||
firstNonWhitespaceCharacterIndex: 0, | ||
rangeIncludingLineBreak: new vscode.Range(0, 0, 0, 0), | ||
isEmptyOrWhitespace: false | ||
}; | ||
} | ||
offsetAt(_position: vscode.Position): never { | ||
throw new Error('Method not implemented.'); | ||
} | ||
positionAt(_offset: number): never{ | ||
throw new Error('Method not implemented.'); | ||
} | ||
getText(_range?: vscode.Range | undefined): never { | ||
throw new Error('Method not implemented.'); | ||
} | ||
getWordRangeAtPosition(_position: vscode.Position, _regex?: RegExp | undefined): never { | ||
throw new Error('Method not implemented.'); | ||
} | ||
validateRange(_range: vscode.Range): never { | ||
throw new Error('Method not implemented.'); | ||
} | ||
validatePosition(_position: vscode.Position): never { | ||
throw new Error('Method not implemented.'); | ||
} | ||
save(): never { | ||
throw new Error('Method not implemented.'); | ||
} | ||
} |
Oops, something went wrong.