Skip to content

Commit

Permalink
Add property to doc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neild3r committed Mar 27, 2017
1 parent dc008c5 commit 30ceb03
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export class Doc {
public return:string;
public var:string;
public message:string;
protected config:{};

constructor(message:string = '') {
this.message = message;
Expand All @@ -27,14 +28,21 @@ export class Doc {
}
}

getConfig():WorkspaceConfiguration {
return workspace.getConfiguration('php-docblocker');
getConfig():any {
if (this.config == null) {
this.config = workspace.getConfiguration().get('php-docblocker');
}
return this.config;
}

setConfig(config:any) {
this.config = config;
}

build(isEmpty:boolean = false):SnippetString {
let snippet = new SnippetString();
let extra = this.getConfig().get('extra');
let gap = !this.getConfig().get('gap');
let extra = this.getConfig().extra;
let gap = !this.getConfig().gap;

if (isEmpty) {
gap = true;
Expand Down
3 changes: 3 additions & 0 deletions test/doc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ suite("Snippet build tests", () => {
test("Snippet test: "+ testData.name, () => {
let doc = new Doc();
let empty = false;
if (testData.config != undefined) {
doc.setConfig(testData.config);
}
if (testData.input != undefined) {
doc.fromObject(testData.input);
} else {
Expand Down
19 changes: 18 additions & 1 deletion test/fixtures/doc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
[
{
"name": "empty",
"name": "Empty",
"expected": [
"/**",
" * ${1}",
" */"
]
},
{
"name": "Property",
"config": {
"gap": false,
"extra": []
},
"input": {
"message": "Undocumented var",
"var": "mixed"
},
"expected": [
"/**",
" * ${1:Undocumented var}",
" * @var ${2:mixed}",
" */"
]
}
]

0 comments on commit 30ceb03

Please sign in to comment.