forked from angular/angular
-
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.
chore(doc-gen): add some tests for typescript-definition-package
- Loading branch information
1 parent
09bb114
commit 4d80ce5
Showing
4 changed files
with
76 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var Package = require('dgeni').Package; | ||
|
||
module.exports = function mockPackage() { | ||
|
||
return new Package('mockPackage', [require('../')]) | ||
|
||
// provide a mock log service | ||
.factory('log', function() { return require('dgeni/lib/mocks/log')(false); }) | ||
// .factory('templateEngine', function() { return {}; }); | ||
|
||
}; |
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
48 changes: 48 additions & 0 deletions
48
docs/typescript-definition-package/processors/createTypeDefinitionFile.spec.js
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,48 @@ | ||
var mockPackage = require('../mocks/mockPackage'); | ||
var Dgeni = require('dgeni'); | ||
var path = require('canonical-path'); | ||
var _ = require('lodash'); | ||
|
||
describe('createTypeDefinitionFile processor', function() { | ||
var dgeni, injector, processor; | ||
|
||
beforeEach(function() { | ||
dgeni = new Dgeni([mockPackage()]); | ||
injector = dgeni.configureInjector(); | ||
processor = injector.get('createTypeDefinitionFile'); | ||
|
||
// Initialize the processor | ||
processor.typeDefinitions = [{ | ||
id: 'angular2/angular2', | ||
modules: { 'angular2/angular2': 'angular2/angular2' } | ||
}]; | ||
}); | ||
|
||
|
||
|
||
describe('classes with private constructors', function() { | ||
|
||
it('should convert heritage from `implements` into `extends`', function() { | ||
|
||
// Create some mock docs for testing | ||
var docs = [ | ||
{ | ||
id: 'angular2/angular2', | ||
exports: [ | ||
{ docType: 'class', heritage: 'implements Xyz', constructorDoc: { private: true } } | ||
] | ||
} | ||
]; | ||
|
||
docs = processor.$process(docs); | ||
|
||
expect(docs.length).toEqual(1); | ||
expect(docs[0].docType).toEqual('type-definition'); | ||
|
||
var moduleDoc = docs[0].moduleDocs['angular2/angular2'].doc; | ||
expect(moduleDoc.exports.length).toEqual(2); | ||
expect(moduleDoc.exports[0].heritage).toEqual('extends Xyz'); | ||
}); | ||
}); | ||
|
||
}); |