This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dgeni): Add test file for tag fixer unit test.
- Loading branch information
Showing
6 changed files
with
63 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"codeNode": { | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "AssignmentExpression", | ||
"operator": "=", | ||
"left": { | ||
"type": "MemberExpression", | ||
"object": { | ||
"type": "MemberExpression", | ||
"object": { | ||
"type": "Identifier", | ||
"name": "ElementArrayFinder" | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"name": "prototype" | ||
} | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"name": "all" | ||
} | ||
} | ||
} | ||
} | ||
} |
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,14 @@ | ||
{ | ||
"codeNode": { | ||
"type": "VariableDeclaration", | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"id": { | ||
"type": "Identifier", | ||
"name": "ElementArrayFinder" | ||
} | ||
} | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,79 +1,48 @@ | ||
var tagFixerFn = require('../processors/tag-fixer'); | ||
var elementArrayFinder = require('./element-array-finder.json'); | ||
var elementAll = require('./element-array-finder-all.json'); | ||
var _ = require('lodash'); | ||
|
||
describe('tag fixer', function() { | ||
var expressionDoc, declarationDoc, docs, tagFixer; | ||
var classMethodStatement, constructorStatement, docs, tagFixer; | ||
|
||
beforeEach(function() { | ||
tagFixer = tagFixerFn(); | ||
}); | ||
|
||
beforeEach(function() { | ||
expressionDoc = { | ||
codeNode: { | ||
node: { | ||
expression: { | ||
left: { | ||
object: { | ||
name: 'element' | ||
}, | ||
property: { | ||
name: 'all' | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
tags: { | ||
description: 'element description' | ||
} | ||
}; | ||
constructorStatement = _.cloneDeep(elementArrayFinder); | ||
classMethodStatement = _.cloneDeep(elementAll); | ||
|
||
declarationDoc = { | ||
codeNode: { | ||
node: { | ||
declarations: [ | ||
{ | ||
id: { | ||
name: 'element' | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
tags: { | ||
description: 'element description' | ||
} | ||
}; | ||
|
||
docs = [expressionDoc, declarationDoc]; | ||
docs = [constructorStatement, classMethodStatement]; | ||
}); | ||
|
||
it('should find name in code expression', function() { | ||
it('should find name for method declaration', function() { | ||
// When you process the docs. | ||
tagFixer.$process(docs); | ||
|
||
// Then ensure the name was parsed. | ||
expect(expressionDoc.name).toBe('element.all'); | ||
expect(classMethodStatement.name).toBe('ElementArrayFinder.prototype.all'); | ||
}); | ||
|
||
it('should find name in code declaration', function() { | ||
it('should find name for constructor declaration', function() { | ||
// When you process the docs. | ||
tagFixer.$process(docs); | ||
|
||
// Then ensure the name was parsed. | ||
expect(declarationDoc.name).toBe('element'); | ||
expect(constructorStatement.name).toBe('ElementArrayFinder'); | ||
}); | ||
|
||
it('should not override name', function() { | ||
// Given that the doc has a @name. | ||
expressionDoc.name = 'name1'; | ||
declarationDoc.name = 'name2'; | ||
classMethodStatement.name = 'name1'; | ||
constructorStatement.name = 'name2'; | ||
|
||
// When you process the docs. | ||
tagFixer.$process(docs); | ||
|
||
// Then ensure the name was not changed. | ||
expect(expressionDoc.name).toBe('name1'); | ||
expect(declarationDoc.name).toBe('name2'); | ||
expect(classMethodStatement.name).toBe('name1'); | ||
expect(constructorStatement.name).toBe('name2'); | ||
}); | ||
}); |
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