forked from neild3r/vscode-php-docblocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.test.ts
47 lines (41 loc) · 1.67 KB
/
functions.test.ts
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
44
45
46
47
import * as assert from 'assert';
import {TextEditor, TextDocument, WorkspaceConfiguration} from 'vscode';
import Helper from './helpers';
import Function from '../src/block/function';
import {Doc, Param} from '../src/doc';
import { callback } from './bootstrap';
import Config from '../src/util/config';
suite("Function tests", () => {
let editor:TextEditor;
let document:TextDocument;
let testPositions:any = {};
let defaults:Config = Helper.getConfig();
let map = Helper.getFixtureMap('functions.php.json');
suiteSetup(function(done) {
Helper.loadFixture('functions.php', (edit:TextEditor, doc:TextDocument) => {
editor = edit;
document = doc;
testPositions = Helper.getFixturePositions(document);
done();
});
});
map.forEach(testData => {
test("Match Test: "+ testData.name, () => {
let func = new Function(testPositions[testData.key], editor);
assert.equal(func.test(), true, test.name);
});
test("Parse Test: "+ testData.name, () => {
let func = new Function(testPositions[testData.key], editor);
assert.ok(func.parse(), test.name);
});
test("Result Test: "+ testData.name, () => {
Helper.setConfig(testData.config);
let func = new Function(testPositions[testData.key], editor);
let actual:Doc = func.parse();
let expected:Doc = new Doc('Undocumented function');
expected.fromObject(testData.result);
expected.template = Helper.getConfig().get('functionTemplate');
assert.deepEqual(actual, expected);
});
});
});