-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathcontent-provider.test.ts
More file actions
43 lines (36 loc) · 1.87 KB
/
content-provider.test.ts
File metadata and controls
43 lines (36 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import ContentProvider from '../../lib/content-provider';
import * as assert from 'assert';
import {mockType} from '../helpers';
import NormalisationRuleStore from '../../lib/normalisation-rule-store';
import * as vscode from 'vscode';
import SelectionInfoRegistry from '../../lib/selection-info-registry';
suite('ContentProvider', () => {
const selectionInfoRegistry = new SelectionInfoRegistry();
selectionInfoRegistry.set('key1', {
text: 'TEXT_1',
fileName: 'FILE_1',
lineRanges: []
});
suite('When normalisation rules are given', () => {
const normalisationRuleStore = mockType<NormalisationRuleStore>({
activeRules: [{match: '_', replaceWith: ':'}]
});
const contentProvider = new ContentProvider(selectionInfoRegistry, normalisationRuleStore);
test('it extracts text key from the given uri and uses it to retrieve text', () => {
const uri = mockType<vscode.Uri>({path: 'text/file.txt', query: 'key=key1'});
assert.deepEqual(contentProvider.provideTextDocumentContent(uri), 'TEXT:1');
});
test('it returns an empty string if a text is not yet selected', () => {
const uri = mockType<vscode.Uri>({path: 'text/file.txt', query: 'key=keyNotExist'});
assert.deepEqual(contentProvider.provideTextDocumentContent(uri), '');
});
});
suite('When normalisation rules are NOT given', () => {
const normalisationRuleStore = mockType<NormalisationRuleStore>({activeRules: []});
const contentProvider = new ContentProvider(selectionInfoRegistry, normalisationRuleStore);
test('it returns the registered text as is', () => {
const uri = mockType<vscode.Uri>({path: 'text/file.txt', query: 'key=key1'});
assert.deepEqual(contentProvider.provideTextDocumentContent(uri), 'TEXT_1');
});
});
});