Migrate tests to TypeScript

This commit is contained in:
Roman Hotsiy 2016-06-12 20:44:34 +03:00
parent 3629e34a5a
commit 4498884f62
40 changed files with 334 additions and 819 deletions

View File

@ -1,32 +0,0 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"browser": true,
"jasmine": true
},
// currently eslint doesn't support extension-typed configs
"globals": {
"should": true,
"expect": true,
"sinon": true,
"Reflect": true
},
"rules": {
"quotes": [2, "single"],
"no-console": 0,
"comma-spacing": 2,
"comma-style": [2, "last"],
"consistent-return": 2,
"strict": [2, "global"],
"eqeqeq": [2, "smart"],
"curly": [2, "multi-line"],
"semi-spacing": [2, {"before": false, "after": true}],
"semi": [2, "always"],
"no-extra-semi": 2,
"comma-dangle": [2, "never"],
"no-sequences": 2,
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"]
}
}

View File

@ -40,7 +40,6 @@ gulp.task('copyDebug', () => {
gulp.task('rebuild', function(done) { gulp.task('rebuild', function(done) {
return runSequence( return runSequence(
'tsc',
'inlineTemplates', 'inlineTemplates',
'bundle', 'bundle',
'concatDeps', 'concatDeps',
@ -53,8 +52,8 @@ gulp.task('tsc', function() {
exec('tsc -p ./tsconfig.json'); exec('tsc -p ./tsconfig.json');
}); });
gulp.task('inlineTemplates', ['sass'], function() { gulp.task('inlineTemplates', ['tsc', 'sass'], function() {
return gulp.src('.tmp/lib/**/*.js', { base: './tmp' }) return gulp.src('.tmp/**/*.js', { base: './tmp' })
.pipe(replace(/'(.*?)\.css'/g, '\'$1.scss\'')) .pipe(replace(/'(.*?)\.css'/g, '\'$1.scss\''))
.pipe(inlineNg2Template({ .pipe(inlineNg2Template({
base: './', base: './',

View File

@ -4,6 +4,11 @@
<title>ReDoc</title> <title>ReDoc</title>
<link rel="stylesheet" href="main.css"> <link rel="stylesheet" href="main.css">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
@import url(//fonts.googleapis.com/css?family=Roboto:300,400,700);
@import url(//fonts.googleapis.com/css?family=Montserrat:400,700);
</style>
</head> </head>
<body> <body>
<nav> <nav>

View File

@ -51,25 +51,26 @@ module.exports = function (config) {
'node_modules/zone.js/dist/jasmine-patch.js', 'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/babel-polyfill/dist/polyfill.js', 'node_modules/babel-polyfill/dist/polyfill.js',
'./node_modules/reflect-metadata/Reflect.js' './node_modules/reflect-metadata/Reflect.js',
'.tmp/prismjs-bundle.js'
], ],
jspm: { jspm: {
config: 'system.config.js', config: 'system.config.js',
loadFiles: ['tests/setup.js', 'tests/helpers.js', 'tests/unit/*.spec.js', 'lib/**/*.js'], loadFiles: ['.tmp/tests/setup.js', '.tmp/tests/helpers.js', '.tmp/lib/**/*.js',
'.tmp/tests/unit/*.js'],
serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html', serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html',
'.tmp/lib/**/*.json', '.tmp/*js', '.tmp/lib/**/*.scss'], '.tmp/lib/**/*.json', '.tmp/*js', '.tmp/lib/**/*.css'],
nocache: true nocache: true
}, },
proxies: { proxies: {
'/tests/': '/base/tests/', '/tests/schemas': '/base/tests/schemas',
'/lib/components/Redoc/redoc-initial-styles.scss': '/base/.tmp/lib/components/Redoc/redoc-initial-styles.scss', '/lib/components/redoc/redoc-initial-styles.scss': '/base/.tmp/lib/components/Redoc/redoc-initial-styles.scss',
'/lib/version.json': '/base/.tmp/lib/version.json', '/lib/version.json': '/base/.tmp/lib/version.json',
'/lib/': '/base/lib/', '/lib/': '/base/lib/',
'/jspm_packages/': '/base/jspm_packages/', '/jspm_packages/': '/base/jspm_packages/',
'/node_modules/': '/base/node_modules/', '/node_modules/': '/base/node_modules/',
'/prismjs-bundle.js': '/base/.tmp/prismjs-bundle.js',
'/.tmp/': '/base/.tmp/' '/.tmp/': '/base/.tmp/'
}, },
reporters: travis ? ['mocha', 'coverage', 'coveralls'] : ['mocha', 'coverage'], reporters: travis ? ['mocha', 'coverage', 'coveralls'] : ['mocha', 'coverage'],

View File

@ -1,11 +1,12 @@
'use strict'; 'use strict';
import { getChildDebugElement } from 'tests/helpers'; import { getChildDebugElement } from '../../../tests/helpers';
import { Component, provide } from '@angular/core'; import { Component, provide } from '@angular/core';
import { import {
inject, inject,
async, async,
expect,
beforeEach, beforeEach,
beforeEachProviders, beforeEachProviders,
it it
@ -13,11 +14,9 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { ApiInfo } from 'lib/components/ApiInfo/api-info'; import { ApiInfo } from './api-info';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';
import { OptionsService } from 'lib/services/index'; import { OptionsService } from '../../services/index';
let optionsService = new OptionsService();
describe('Redoc components', () => { describe('Redoc components', () => {
describe('ApiInfo Component', () => { describe('ApiInfo Component', () => {
@ -26,7 +25,7 @@ describe('Redoc components', () => {
let fixture; let fixture;
beforeEachProviders(() => [ beforeEachProviders(() => [
provide(SchemaManager, {useValue: new SchemaManager()}), provide(SchemaManager, {useValue: new SchemaManager()}),
provide(OptionsService, {useValue: optionsService}) provide(OptionsService, {useClass: OptionsService})
]); ]);
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { getChildDebugElement } from 'tests/helpers'; import { getChildDebugElement } from '../../../tests/helpers';
import {Component, provide} from '@angular/core'; import {Component, provide} from '@angular/core';
import { import {
@ -13,8 +13,8 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { ApiLogo } from 'lib/components/ApiLogo/api-logo'; import { ApiLogo } from './api-logo';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';
describe('Redoc components', () => { describe('Redoc components', () => {

View File

@ -1,9 +1,8 @@
'use strict'; 'use strict';
import { getChildDebugElement } from 'tests/helpers'; import { getChildDebugElement } from '../../../tests/helpers';
import { Component, provide } from '@angular/core'; import { Component, provide } from '@angular/core';
import { DynamicComponentLoader } from '@angular/core'; import { DynamicComponentLoader } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
inject, inject,
@ -15,9 +14,8 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { JsonSchemaLazy } from 'lib/components/JsonSchema/json-schema-lazy'; import { JsonSchemaLazy } from './json-schema-lazy';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';
import { OptionsService } from 'lib/services/index';
describe('Redoc components', () => { describe('Redoc components', () => {
describe('JsonSchemaLazy Component', () => { describe('JsonSchemaLazy Component', () => {
@ -26,25 +24,25 @@ describe('Redoc components', () => {
let schemaMgr = new SchemaManager(); let schemaMgr = new SchemaManager();
let fixture; let fixture;
let loader; let loader;
let appRef = { let appRefMock = {
instance: {}, instance: {
pointer: ''
},
hostView: {changeDetectorRef: {detectChanges : function() {} }} hostView: {changeDetectorRef: {detectChanges : function() {} }}
}; };
beforeEachProviders(() => [ beforeEachProviders(() => [
provide(SchemaManager, {useValue: schemaMgr}), provide(SchemaManager, {useValue: schemaMgr})
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
provide(OptionsService, {useClass: OptionsService})
]); ]);
beforeEach(inject([TestComponentBuilder, DynamicComponentLoader], (tcb, dcl) => { beforeEach(inject([TestComponentBuilder, DynamicComponentLoader], (tcb, dcl) => {
builder = tcb; builder = tcb;
loader = dcl; loader = dcl;
spyOn(loader, 'loadNextToLocation').and.returnValue({then: (fn) => fn(appRef)}); spyOn(loader, 'loadNextToLocation').and.returnValue({then: (fn) => fn(appRefMock)});
})); }));
beforeEach((done) => { beforeEach((done) => {
builder.createAsync(TestApp).then(_fixture => { builder.createAsync(TestApp).then(_fixture => {
fixture = _fixture; fixture = _fixture;
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy'); let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
component = debugEl.componentInstance; component = <JsonSchemaLazy>debugEl.componentInstance;
done(); done();
}, err => done.fail(err)); }, err => done.fail(err));
}); });
@ -76,7 +74,7 @@ describe('Redoc components', () => {
component.pointer = '#/def'; component.pointer = '#/def';
fixture.detectChanges(); fixture.detectChanges();
component.load(); component.load();
expect(appRef.instance.pointer).toEqual(component.pointer); expect(appRefMock.instance.pointer).toEqual(component.pointer);
}); });
}); });
}); });

View File

@ -9,12 +9,11 @@ import {
} from '@angular/core/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { OptionsService } from 'lib/services/index'; import { getChildDebugElement } from '../../../tests/helpers';
import { getChildDebugElement } from 'tests/helpers';
import { JsonSchema } from 'lib/components/JsonSchema/json-schema'; import { JsonSchema } from './json-schema';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';;
describe('Redoc components', () => { describe('Redoc components', () => {
describe('JsonSchema Component', () => { describe('JsonSchema Component', () => {
@ -23,8 +22,7 @@ describe('Redoc components', () => {
let schemaMgr = new SchemaManager(); let schemaMgr = new SchemaManager();
let fixture; let fixture;
beforeEachProviders(() => [ beforeEachProviders(() => [
provide(SchemaManager, {useValue: schemaMgr}), provide(SchemaManager, {useValue: schemaMgr})
provide(OptionsService, {useClass: OptionsService})
]); ]);
beforeEach(inject([TestComponentBuilder], (tcb) => { beforeEach(inject([TestComponentBuilder], (tcb) => {
builder = tcb; builder = tcb;
@ -40,21 +38,21 @@ describe('Redoc components', () => {
it('should init component', () => { it('should init component', () => {
component.pointer = ''; component.pointer = '';
schemaMgr._schema = {type: 'object'}; (<any>schemaMgr)._schema = {type: 'object'};
fixture.detectChanges(); fixture.detectChanges();
expect(component).not.toBeNull(); expect(component).not.toBeNull();
}); });
it('should set isTrivial for non-object/array types', () => { it('should set isTrivial for non-object/array types', () => {
component.pointer = ''; component.pointer = '';
schemaMgr._schema = {type: 'string'}; (<any>schemaMgr)._schema = {type: 'string'};
fixture.detectChanges(); fixture.detectChanges();
component.schema.isTrivial.should.be.true(); component.schema.isTrivial.should.be.true();
}); });
it('should use < * > notation for prop without type', () => { it('should use < * > notation for prop without type', () => {
component.pointer = ''; component.pointer = '';
schemaMgr._schema = {type: 'object', properties: { (<any>schemaMgr)._schema = {type: 'object', properties: {
test: {} test: {}
}}; }};
fixture.detectChanges(); fixture.detectChanges();

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import { Component, provide } from '@angular/core'; import { Component, provide } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
inject, inject,
async, async,
@ -11,21 +10,17 @@ import {
} from '@angular/core/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { getChildDebugElement } from 'tests/helpers'; import { getChildDebugElement } from '../../../tests/helpers';
import { Method } from 'lib/components/Method/method'; import { Method } from './method';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';;
import { OptionsService, RedocEventsService } from 'lib/services/index';
describe('Redoc components', () => { describe('Redoc components', () => {
describe('Method Component', () => { describe('Method Component', () => {
let builder; let builder;
let component; let component;
beforeEachProviders(() => [ beforeEachProviders(() => [
provide(SchemaManager, {useValue: new SchemaManager()}), provide(SchemaManager, {useValue: new SchemaManager()})
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
provide(OptionsService, {useClass: OptionsService}),
provide(RedocEventsService, {useClass: RedocEventsService})
]); ]);
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
builder = tcb; builder = tcb;

View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import { Component, provide } from '@angular/core'; import { Component, provide } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
inject, inject,
async, async,
@ -11,11 +10,11 @@ import {
} from '@angular/core/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { getChildDebugElement } from 'tests/helpers'; import { getChildDebugElement } from '../../../tests/helpers';
import { OptionsService, RedocEventsService } from 'lib/services/index';
import { MethodsList } from 'lib/components/MethodsList/methods-list'; import { MethodsList } from './methods-list';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';
describe('Redoc components', () => { describe('Redoc components', () => {
describe('MethodsList Component', () => { describe('MethodsList Component', () => {
@ -23,10 +22,7 @@ describe('Redoc components', () => {
let component; let component;
let fixture; let fixture;
beforeEachProviders(() => [ beforeEachProviders(() => [
provide(SchemaManager, {useValue: new SchemaManager()}), provide(SchemaManager, {useValue: new SchemaManager()})
provide(OptionsService, {useClass: OptionsService}),
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
provide(RedocEventsService, {useClass: RedocEventsService})
]); ]);
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
builder = tcb; builder = tcb;

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { getChildDebugElement } from 'tests/helpers'; import { getChildDebugElement } from '../../../tests/helpers';
import { Component, provide } from '@angular/core'; import { Component, provide, ComponentRef } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { import {
@ -14,28 +14,32 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { Redoc } from 'lib/components/Redoc/redoc'; import { Redoc } from './redoc';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';
import { OptionsService } from 'lib/services/index'; import { OptionsService } from '../../services/index';
let optsMgr = new OptionsService(new BrowserDomAdapter()); let optsMgr:OptionsService;
describe('Redoc components', () => { describe('Redoc components', () => {
describe('Redoc Component', () => { describe('Redoc Component', () => {
let builder; let builder;
let schemaMgr;
beforeEachProviders(() => [ beforeEachProviders(() => [
provide(SchemaManager, {useValue: new SchemaManager()}), provide(SchemaManager, {useValue: new SchemaManager()}),
provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}),
provide(OptionsService, {useValue: optsMgr})
]); ]);
beforeEachProviders(() => [ beforeEach(async(inject([TestComponentBuilder, SchemaManager, OptionsService],
provide(OptionsService, {useValue: optsMgr}) (tcb, _schemaMgr, _optsMgr) => {
]); optsMgr = _optsMgr;
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
builder = tcb; builder = tcb;
return schemaMgr.load('/tests/schemas/extended-petstore.yml'); schemaMgr = _schemaMgr;
}))); })));
beforeEach((done) => {
return schemaMgr.load('/tests/schemas/extended-petstore.yml')
.then(() => done())
.catch(err => done.fail(err));
});
it('should init component', (done) => { it('should init component', (done) => {
builder.createAsync(TestApp).then(fixture => { builder.createAsync(TestApp).then(fixture => {
@ -51,7 +55,9 @@ describe('Redoc components', () => {
(() => fixture.detectChanges()).should.not.throw(); (() => fixture.detectChanges()).should.not.throw();
fixture.destroy(); fixture.destroy();
done(); done();
}, err => done.fail(err)); }, err => {
return done.fail(err)
});
}); });
}); });
@ -114,7 +120,7 @@ describe('Redoc components', () => {
fixture = _fixture; fixture = _fixture;
element = getChildDebugElement(fixture.debugElement, 'methods-list').nativeElement; element = getChildDebugElement(fixture.debugElement, 'methods-list').nativeElement;
destroySpy = jasmine.createSpy('spy'); destroySpy = jasmine.createSpy('spy');
Redoc.appRef = { Redoc.appRef = <ComponentRef<any>>{
destroy: destroySpy destroy: destroySpy
}; };
fixture.detectChanges(); fixture.detectChanges();
@ -148,7 +154,9 @@ describe('Redoc components', () => {
describe('Redoc autoInit', () => { describe('Redoc autoInit', () => {
const testURL = 'testurl'; const testURL = 'testurl';
let dom = new BrowserDomAdapter(); let dom = new BrowserDomAdapter();
let elem; //let redocInitSpy;
let elem: HTMLElement;
beforeEach(() => { beforeEach(() => {
spyOn(Redoc, 'init').and.stub(); spyOn(Redoc, 'init').and.stub();
elem = dom.createElement('redoc'); elem = dom.createElement('redoc');
@ -159,7 +167,7 @@ describe('Redoc components', () => {
it('should call Redoc.init with url from param spec-url', () => { it('should call Redoc.init with url from param spec-url', () => {
Redoc.autoInit(); Redoc.autoInit();
expect(Redoc.init).toHaveBeenCalled(); expect(Redoc.init).toHaveBeenCalled();
expect(Redoc.init.calls.argsFor(0)).toEqual([testURL]); expect((<jasmine.Spy>Redoc.init).calls.argsFor(0)).toEqual([testURL]);
}); });
it('should not call Redoc.init when spec-url param is not provided', () => { it('should not call Redoc.init when spec-url param is not provided', () => {
@ -169,7 +177,7 @@ describe('Redoc components', () => {
}); });
afterEach(() => { afterEach(() => {
Redoc.init.and.callThrough(); (<jasmine.Spy>Redoc.init).and.callThrough();
dom.defaultDoc().body.removeChild(elem); dom.defaultDoc().body.removeChild(elem);
}); });
}); });

View File

@ -69,7 +69,7 @@ export class Redoc extends BaseComponent {
}, 400); }, 400);
} }
static init(specUrl, options?) { static init(specUrl?, options?) {
var optionsService = new OptionsService(dom); var optionsService = new OptionsService(dom);
optionsService.options = options; optionsService.options = options;
optionsService.options.specUrl = optionsService.options.specUrl || specUrl; optionsService.options.specUrl = optionsService.options.specUrl || specUrl;

View File

@ -1,70 +0,0 @@
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = require('@angular/core');
var OpenAPISampler = require('openapi-sampler');
var base_1 = require('../base');
var JsonFormatterPipe_1 = require('../../utils/JsonFormatterPipe');
var SchemaSample = (function (_super) {
__extends(SchemaSample, _super);
function SchemaSample(schemaMgr, elementRef) {
_super.call(this, schemaMgr);
this.element = elementRef.nativeElement;
}
SchemaSample.prototype.init = function () {
this.data = {};
var base = {};
var sample;
if (this.componentSchema.schema) {
base = this.componentSchema;
this.componentSchema = this.componentSchema.schema;
}
if (base.examples && base.examples['application/json']) {
sample = base.examples['application/json'];
}
else {
this.dereference(this.componentSchema);
try {
sample = OpenAPISampler.sample(this.componentSchema);
}
catch (e) {
}
}
this.data.sample = sample;
this.element.addEventListener('click', function (event) {
var collapsed, target = event.target;
if (event.target.className === 'collapser') {
collapsed = target.parentNode.getElementsByClassName('collapsible')[0];
if (collapsed.parentNode.classList.contains('collapsed')) {
collapsed.parentNode.classList.remove('collapsed');
}
else {
collapsed.parentNode.classList.add('collapsed');
}
}
});
};
SchemaSample = __decorate([
base_1.RedocComponent({
selector: 'schema-sample',
templateUrl: './schema-sample.html',
pipes: [JsonFormatterPipe_1.JsonFormatter],
styleUrls: ['./schema-sample.css']
}),
__metadata('design:paramtypes', [base_1.SchemaManager, core_1.ElementRef])
], SchemaSample);
return SchemaSample;
}(base_1.BaseComponent));
exports.SchemaSample = SchemaSample;

View File

@ -1,9 +1,8 @@
'use strict'; 'use strict';
import { getChildDebugElement } from 'tests/helpers'; import { getChildDebugElement } from '../../../tests/helpers';
import { Component, provide } from '@angular/core'; import { Component, provide } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { OptionsService } from '../../services/index';
import { OptionsService, RedocEventsService } from 'lib/services/index';
import { import {
inject, inject,
@ -15,17 +14,11 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { MethodsList, SideMenu } from 'lib/components/index'; import { MethodsList, SideMenu } from '../index';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../utils/SchemaManager';;
let testOptions = new OptionsService(); let testOptions;
testOptions.options = {
scrollYOffset: () => 0,
scrollParent: window
};
let redocEvents = new RedocEventsService();
describe('Redoc components', () => { describe('Redoc components', () => {
describe('SideMenu Component', () => { describe('SideMenu Component', () => {
@ -33,13 +26,16 @@ describe('Redoc components', () => {
let component; let component;
let fixture; let fixture;
beforeEachProviders(() => [ beforeEachProviders(() => [
provide(SchemaManager, {useValue: new SchemaManager()}), provide(SchemaManager, {useValue: new SchemaManager()})
provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}),
provide(OptionsService, {useValue: testOptions}),
provide(RedocEventsService, {useValue: redocEvents})
]); ]);
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { beforeEach(async(inject([TestComponentBuilder, SchemaManager, OptionsService],
(tcb, schemaMgr, opts) => {
builder = tcb; builder = tcb;
testOptions = opts;
testOptions.options = {
scrollYOffset: () => 0,
scrollParent: window
};
return schemaMgr.load('/tests/schemas/extended-petstore.yml'); return schemaMgr.load('/tests/schemas/extended-petstore.yml');
}))); })));

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../utils/SchemaManager';
import { BaseComponent } from 'lib/components/base'; import { BaseComponent } from '../components/base';
describe('Redoc components', () => { describe('Redoc components', () => {
describe('BaseComponent', () => { describe('BaseComponent', () => {
@ -30,11 +30,14 @@ describe('Redoc components', () => {
}); });
it('should call prepareModel and init virtual methods after init', () => { it('should call prepareModel and init virtual methods after init', () => {
sinon.spy(component, 'prepareModel'); spyOn(component, 'prepareModel');
sinon.spy(component, 'init'); spyOn(component, 'init');
component.ngOnInit(); component.ngOnInit();
component.prepareModel.calledOnce.should.be.true;
component.init.calledOnce.should.be.true; component.prepareModel.calls.count().should.be.equal(1);
component.init.calls.count().should.be.equal(1);
component.prepareModel.and.callThrough();
component.init.and.callThrough();
}); });
describe('dereference', () => { describe('dereference', () => {

View File

@ -95,10 +95,9 @@ export function RedocComponent(options) {
* @class * @class
*/ */
export class BaseComponent { export class BaseComponent {
componentSchema: any; componentSchema: any = null;
pointer: String; pointer: String;
constructor(public schemaMgr: SchemaManager) { constructor(public schemaMgr: SchemaManager) {
this.componentSchema = null;
} }
/** /**
@ -169,7 +168,7 @@ export class BaseComponent {
this.componentSchema = snapshot(resolve(schema)); this.componentSchema = snapshot(resolve(schema));
} }
static joinAllOf(schema, opts) { static joinAllOf(schema: any, opts?: any) {
function merge(into, schemas) { function merge(into, schemas) {
for (let subSchema of schemas) { for (let subSchema of schemas) {
if (opts && opts.omitParent && subSchema.discriminator) continue; if (opts && opts.omitParent && subSchema.discriminator) continue;

View File

@ -2,7 +2,7 @@
import 'dropkickjs/build/css/dropkick.css!css'; import 'dropkickjs/build/css/dropkick.css!css';
import 'prismjs/themes/prism-dark.css!css'; import 'prismjs/themes/prism-dark.css!css';
import 'hint.css/hint.base.css!css'; import 'hint.css/hint.base.css!css';
import './components/redoc/redoc-initial-styles.css!css'; import './components/Redoc/redoc-initial-styles.css!css';
import { Redoc } from './components/index'; import { Redoc } from './components/index';

View File

@ -16,8 +16,8 @@ import { MenuService } from './menu.service';
import { Hash } from './hash.service'; import { Hash } from './hash.service';
import { ScrollService } from './scroll.service'; import { ScrollService } from './scroll.service';
import { RedocEventsService } from './events.service'; import { RedocEventsService } from './events.service';
import { MethodsList } from 'lib/components/index'; import { MethodsList } from '../components/index';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../utils/SchemaManager';;
describe('Menu service', () => { describe('Menu service', () => {
let menu, hashService, scroll; let menu, hashService, scroll;
@ -73,9 +73,9 @@ describe('Menu service', () => {
spyOn(window, 'scrollTo').and.stub(); spyOn(window, 'scrollTo').and.stub();
hashService.changed.subscribe(() => { hashService.changed.subscribe(() => {
expect(menu.hashScroll).toHaveBeenCalled(); expect(menu.hashScroll).toHaveBeenCalled();
let scrollY = window.scrollTo.calls.argsFor(0)[1]; let scrollY = (<jasmine.Spy>window.scrollTo).calls.argsFor(0)[1];
expect(scrollY).toBeGreaterThan(0); expect(scrollY).toBeGreaterThan(0);
window.scrollTo.and.callThrough(); (<jasmine.Spy>window.scrollTo).and.callThrough();
done(); done();
}); });
hashService.changed.next(hash); hashService.changed.next(hash);
@ -87,7 +87,7 @@ describe('Menu service', () => {
spyOn(window, 'scrollTo').and.stub(); spyOn(window, 'scrollTo').and.stub();
hashService.changed.subscribe(() => { hashService.changed.subscribe(() => {
expect(menu.hashScroll).toHaveBeenCalled(); expect(menu.hashScroll).toHaveBeenCalled();
let scrollY = window.scrollTo.calls.argsFor(0)[1]; let scrollY = (<jasmine.Spy>window.scrollTo).calls.argsFor(0)[1];
expect(scrollY).toBeGreaterThan(0); expect(scrollY).toBeGreaterThan(0);
done(); done();
}); });

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { getChildDebugElementByType } from 'tests/helpers'; import { getChildDebugElementByType } from '../../../../tests/helpers';
import { Component, provide } from '@angular/core'; import { Component, provide } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
@ -13,7 +13,7 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { StickySidebar } from 'lib/shared/components/index'; import { StickySidebar } from '../index';
describe('Common components', () => { describe('Common components', () => {
describe('StickySidebar Component', () => { describe('StickySidebar Component', () => {
@ -75,6 +75,8 @@ describe('Common components', () => {
}) })
class TestApp { class TestApp {
options: any;
scrollParent: Window;
constructor() { constructor() {
this.options = {}; this.options = {};
this.scrollParent = window; this.scrollParent = window;

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { getChildDebugElement, getChildDebugElementAll } from 'tests/helpers'; import { getChildDebugElement, getChildDebugElementAll } from '../../../../tests/helpers';
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import { import {
@ -11,7 +11,7 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import {Tabs, Tab} from 'lib/shared/components/index'; import {Tabs, Tab} from '../index';
describe('Common components', () => { describe('Common components', () => {
describe('Tabs Component', () => { describe('Tabs Component', () => {
@ -148,6 +148,7 @@ describe('Common components', () => {
</tabs>` </tabs>`
}) })
class TestApp { class TestApp {
eventLog: any;
constructor() { constructor() {
this.eventLog = []; this.eventLog = [];
} }

View File

@ -1,5 +0,0 @@
/**
* This file is generated by the Angular 2 template compiler.
* Do not edit.
*/
export const styles:any[] = ['.zippy-title[_ngcontent-%COMP%]{padding:10px;border-radius:2px;margin:2px 0;line-height:1.5em;background-color:#f2f2f2;cursor:pointer}.zippy-success[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#00aa13;background-color:rgba(0,170,19,0.08)}.zippy-error[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#e53935;background-color:rgba(229,57,53,0.06)}.zippy-redirect[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#263238;background-color:rgba(38,50,56,0.08)}.zippy-info[_ngcontent-%COMP%]>.zippy-title[_ngcontent-%COMP%]{color:#0033a0;background-color:rgba(0,51,160,0.08)}span.zippy-indicator[_ngcontent-%COMP%]{font-size:1.2em;margin-right:0.2em;position:relative;top:0}.zippy-content[_ngcontent-%COMP%]{padding:15px 0}.zippy-empty[_ngcontent-%COMP%] .zippy-title[_ngcontent-%COMP%]{cursor:default}.zippy-empty[_ngcontent-%COMP%] .zippy-indicator[_ngcontent-%COMP%]{display:none}.zippy-empty[_ngcontent-%COMP%] .zippy-content[_ngcontent-%COMP%]{display:none}.zippy-hidden[_ngcontent-%COMP%]{overflow:hidden;visibility:hidden;height:0;padding:0}'];

View File

@ -1,16 +1,17 @@
'use strict'; 'use strict';
import { getChildDebugElement, mouseclick } from 'tests/helpers'; import { getChildDebugElement, mouseclick } from '../../../../tests/helpers';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { import {
inject, inject,
beforeEach, beforeEach,
it it,
expect
} from '@angular/core/testing'; } from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing'; import { TestComponentBuilder } from '@angular/compiler/testing';
import { Zippy } from 'lib/shared/components/index'; import { Zippy } from '../index';
describe('Common components', () => { describe('Common components', () => {
describe('Zippy Component', () => { describe('Zippy Component', () => {
@ -54,7 +55,7 @@ describe('Common components', () => {
it('project inner content', () => { it('project inner content', () => {
fixture.detectChanges(); fixture.detectChanges();
let contentEl = nativeElement.querySelector('.zippy-content'); let contentEl = nativeElement.querySelector('.zippy-content');
expect(contentEl).toHaveText('\n test\n '); expect(contentEl.innerText).toMatch('test');
}); });
it('should open and close zippy', () => { it('should open and close zippy', () => {
@ -101,6 +102,8 @@ describe('Common components', () => {
`<zippy title="Zippy" type="test" visible="true" empty="true" (open)="open()" (close)="close()">test</zippy>` `<zippy title="Zippy" type="test" visible="true" empty="true" (open)="open()" (close)="close()">test</zippy>`
}) })
class TestApp { class TestApp {
opened: boolean;
clickCount: number;
constructor() { constructor() {
this.opened = false; this.opened = false;
this.clickCount = 0; this.clickCount = 0;

View File

@ -6,7 +6,7 @@ const origParse = JsonPointerLib.parse;
* Wrapper for JsonPointer. Provides common operations * Wrapper for JsonPointer. Provides common operations
*/ */
class JsonPointer { export class JsonPointer {
/** /**
* returns last JsonPointer token * returns last JsonPointer token
* if level > 1 returns levels last (second last/third last) * if level > 1 returns levels last (second last/third last)

View File

@ -5,7 +5,7 @@ import JsonPointer from './JsonPointer';
import {methods as swaggerMethods} from './swagger-defs'; import {methods as swaggerMethods} from './swagger-defs';
export class SchemaManager { export class SchemaManager {
private _schema:any = {}; public _schema:any = {};
private _instance:any; private _instance:any;
apiUrl: string; apiUrl: string;

View File

@ -20,7 +20,8 @@ export function getChildDebugElementAll(parent, tagName) {
export function mouseclick( element ) { export function mouseclick( element ) {
// create a mouse click event // create a mouse click event
var event = document.createEvent( 'MouseEvents' ); var event = document.createEvent( 'MouseEvents' );
event.initMouseEvent( 'click', true, true, window, 1, 0, 0 ); event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false,
false, false, false, 0, element);
// send click to element // send click to element
element.dispatchEvent( event ); element.dispatchEvent( event );

View File

@ -1,11 +0,0 @@
'use strict';
import {setBaseTestProviders} from '@angular/core/testing';
import {
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
} from '@angular/platform-browser-dynamic/testing';
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, [TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS]);

20
tests/setup.ts Normal file
View File

@ -0,0 +1,20 @@
'use strict';
import {setBaseTestProviders} from '@angular/core/testing';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { OptionsService, RedocEventsService} from '../lib/services/index';
import { provide } from '@angular/core';
import {
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
} from '@angular/platform-browser-dynamic/testing';
setBaseTestProviders(
[
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
provide(OptionsService, {useClass: OptionsService}),
provide(RedocEventsService, {useClass: RedocEventsService})
],
[TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS]);

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import {JsonPointer} from 'lib/utils/JsonPointer'; import {JsonPointer} from '../../lib/utils/JsonPointer';
// test extended JsonPointer // test extended JsonPointer
describe('Utils', () => { describe('Utils', () => {
describe('JsonPointer', () => { describe('JsonPointer', () => {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import SchemaManager from 'lib/utils/SchemaManager'; import { SchemaManager } from '../../lib/utils/SchemaManager';
describe('Utils', () => { describe('Utils', () => {
describe('Schema manager', () => { describe('Schema manager', () => {
let schemaMgr; let schemaMgr;

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import {statusCodeType} from 'lib/utils/helpers'; import {statusCodeType} from '../../lib/utils/helpers';
describe('Utils', () => { describe('Utils', () => {
describe('statusCodeType', () => { describe('statusCodeType', () => {
it('Should return info for status codes within 100 and 200', ()=> { it('Should return info for status codes within 100 and 200', ()=> {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import {KeysPipe, ValuesPipe, JsonPointerEscapePipe, MarkedPipe} from 'lib/utils/pipes'; import {KeysPipe, ValuesPipe, JsonPointerEscapePipe, MarkedPipe} from '../../lib/utils/pipes';
describe('Pipes', () => { describe('Pipes', () => {
describe('KeysPipe and ValuesPipe', () => { describe('KeysPipe and ValuesPipe', () => {

View File

@ -6,7 +6,7 @@
"target": "es6", "target": "es6",
"noImplicitAny": false, "noImplicitAny": false,
"sourceMap": false, "sourceMap": false,
"outDir": ".tmp/lib", "outDir": ".tmp/",
"moduleResolution": "node" "moduleResolution": "node"
}, },
"exclude": [ "exclude": [

View File

@ -3,7 +3,8 @@
"jasmine": "registry:dt/jasmine#2.2.0+20160505161446" "jasmine": "registry:dt/jasmine#2.2.0+20160505161446"
}, },
"globalDependencies": { "globalDependencies": {
"marked": "registry:dt/marked#0.0.0+20160325085301" "marked": "registry:dt/marked#0.0.0+20160325085301",
"should": "registry:dt/should#8.1.1+20160521152556"
}, },
"ambientDevDependencies": { "ambientDevDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2" "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"

168
typings/globals/should/index.d.ts vendored Normal file
View File

@ -0,0 +1,168 @@
// Generated by typings
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/445ed7e54c1b2a8e84610afab0aab2b2ee2ffb4e/should/should.d.ts
interface Object {
should: ShouldAssertion;
}
interface ShouldAssertion {
// basic grammar
a: ShouldAssertion;
an: ShouldAssertion;
and: ShouldAssertion;
be: ShouldAssertion;
has: ShouldAssertion;
have: ShouldAssertion;
is: ShouldAssertion;
it: ShouldAssertion;
with: ShouldAssertion;
which: ShouldAssertion;
the: ShouldAssertion;
of: ShouldAssertion;
not: ShouldAssertion;
// validators
arguments(): ShouldAssertion;
empty(): ShouldAssertion;
ok(): ShouldAssertion;
true(): ShouldAssertion;
false(): ShouldAssertion;
NaN(): ShouldAssertion;
Infinity(): ShouldAssertion;
Array(): ShouldAssertion;
Object(): ShouldAssertion;
String(): ShouldAssertion;
Boolean(): ShouldAssertion;
Number(): ShouldAssertion;
Error(): ShouldAssertion;
Function(): ShouldAssertion;
Date(): ShouldAssertion;
Class(): ShouldAssertion;
Undefined(): ShouldAssertion;
generator(): ShouldAssertion;
iterable(): ShouldAssertion;
iterator(): ShouldAssertion;
eql(expected: any, description?: string): ShouldAssertion;
equal(expected: any, description?: string): ShouldAssertion;
equalOneOf(...values: any[]): ShouldAssertion;
within(start: number, finish: number, description?: string): ShouldAssertion;
approximately(value: number, delta: number, description?: string): ShouldAssertion;
type(expected: any, description?: string): ShouldAssertion;
instanceof(constructor: Function, description?: string): ShouldAssertion;
above(n: number, description?: string): ShouldAssertion;
below(n: number, description?: string): ShouldAssertion;
aboveOrEqual(n: number, description?: string): ShouldAssertion;
greaterThanOrEqual(n: number, description?: string): ShouldAssertion;
belowOrEqual(n: number, description?: string): ShouldAssertion;
lessThanOrEqual(n: number, description?: string): ShouldAssertion;
match(other: {}, description?: string): ShouldAssertion;
match(other: (val: any) => any, description?: string): ShouldAssertion;
match(regexp: RegExp, description?: string): ShouldAssertion;
match(other: any, description?: string): ShouldAssertion;
matchEach(other: {}, description?: string): ShouldAssertion;
matchEach(other: (val: any) => any, description?: string): ShouldAssertion;
matchEach(regexp: RegExp, description?: string): ShouldAssertion;
matchEach(other: any, description?: string): ShouldAssertion;
matchAny(other: {}, description?: string): ShouldAssertion;
matchAny(other: (val: any) => any, description?: string): ShouldAssertion;
matchAny(regexp: RegExp, description?: string): ShouldAssertion;
matchAny(other: any, description?: string): ShouldAssertion;
length(n: number, description?: string): ShouldAssertion;
property(name: string, description?: string): ShouldAssertion;
property(name: string, val: any, description?: string): ShouldAssertion;
properties(names: string[]): ShouldAssertion;
properties(name: string): ShouldAssertion;
properties(descriptor: any): ShouldAssertion;
properties(...properties: string[]): ShouldAssertion;
propertyByPath(...properties: string[]): ShouldAssertion;
propertyWithDescriptor(name: string, descriptor: PropertyDescriptor): ShouldAssertion;
oneOf(...values: any[]): ShouldAssertion;
ownProperty(name: string, description?: string): ShouldAssertion;
containEql(obj: any): ShouldAssertion;
containDeep(obj: any): ShouldAssertion;
containDeepOrdered(obj: any): ShouldAssertion;
keys(...allKeys: string[]): ShouldAssertion;
keys(allKeys: string[]): ShouldAssertion;
enumerable(property: string, value?: any): ShouldAssertion;
enumerables(...properties: string[]): ShouldAssertion;
startWith(expected: string, message?: any): ShouldAssertion;
endWith(expected: string, message?: any): ShouldAssertion;
throw(message?: any): ShouldAssertion;
//http
header(field: string, val?: string): ShouldAssertion;
status(code: number): ShouldAssertion;
json(): ShouldAssertion;
html(): ShouldAssertion;
//stubs
alwaysCalledOn(thisTarget: any): ShouldAssertion;
alwaysCalledWith(...arguments: any[]): ShouldAssertion;
alwaysCalledWithExactly(...arguments: any[]): ShouldAssertion;
alwaysCalledWithMatch(...arguments: any[]): ShouldAssertion;
alwaysCalledWithNew(): ShouldAssertion;
alwaysThrew(exception?: any): ShouldAssertion;
callCount(count: number): ShouldAssertion;
called(): ShouldAssertion;
calledOn(thisTarget: any): ShouldAssertion;
calledOnce(): ShouldAssertion;
calledTwice(): ShouldAssertion;
calledThrice(): ShouldAssertion;
calledWith(...arguments: any[]): ShouldAssertion;
calledWithExactly(...arguments: any[]): ShouldAssertion;
calledWithMatch(...arguments: any[]): ShouldAssertion;
calledWithNew(): ShouldAssertion;
neverCalledWith(...arguments: any[]): ShouldAssertion;
neverCalledWithMatch(...arguments: any[]): ShouldAssertion;
threw(exception?: any): ShouldAssertion;
// aliases
True(): ShouldAssertion;
False(): ShouldAssertion;
Arguments(): ShouldAssertion;
class(): ShouldAssertion;
deepEqual(expected: any, description?: string): ShouldAssertion;
exactly(expected: any, description?: string): ShouldAssertion;
instanceOf(constructor: Function, description?: string): ShouldAssertion;
throwError(message?: any): ShouldAssertion;
lengthOf(n: number, description?: string): ShouldAssertion;
key(key: string): ShouldAssertion;
hasOwnProperty(name: string, description?: string): ShouldAssertion;
greaterThan(n: number, description?: string): ShouldAssertion;
lessThan(n: number, description?: string): ShouldAssertion;
}
interface ShouldInternal {
// should.js's extras
exist(actual: any, msg?: string): void;
exists(actual: any, msg?: string): void;
not: ShouldInternal;
}
interface Internal extends ShouldInternal {
(obj: any): ShouldAssertion;
// node.js's assert functions
fail(actual: any, expected: any, message: string, operator: string): void;
assert(value: any, message: string): void;
ok(value: any, message?: string): void;
equal(actual: any, expected: any, message?: string): void;
notEqual(actual: any, expected: any, message?: string): void;
deepEqual(actual: any, expected: any, message?: string): void;
notDeepEqual(actual: any, expected: any, message?: string): void;
strictEqual(actual: any, expected: any, message?: string): void;
notStrictEqual(actual: any, expected: any, message?: string): void;
throws(block: any, error?: any, message?: string): void;
doesNotThrow(block: any, message?: string): void;
ifError(value: any): void;
inspect(value: any, obj: any): any;
}
declare var should: Internal;
declare var Should: Internal;
interface Window {
Should: Internal;
}
declare module "should" {
export = should;
}

View File

@ -0,0 +1,8 @@
{
"resolution": "main",
"tree": {
"src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/445ed7e54c1b2a8e84610afab0aab2b2ee2ffb4e/should/should.d.ts",
"raw": "registry:dt/should#8.1.1+20160521152556",
"typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/445ed7e54c1b2a8e84610afab0aab2b2ee2ffb4e/should/should.d.ts"
}
}

2
typings/index.d.ts vendored
View File

@ -1,3 +1,3 @@
/// <reference path="globals/jasmine/index.d.ts" /> /// <reference path="globals/jasmine/index.d.ts" />
/// <reference path="globals/json-pointer/index.d.ts" /> /// <reference path="globals/json-pointer/index.d.ts" />
/// <reference path="modules/chai/index.d.ts" /> /// <reference path="globals/should/index.d.ts" />

View File

@ -1,547 +0,0 @@
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-assertion-error/105841317bd2bdd5d110bfb763e49e482a77230d/main.d.ts
declare module '~chai~assertion-error/main' {
// Type definitions for assertion-error 1.0.0
// Project: https://github.com/chaijs/assertion-error
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
export class AssertionError implements Error {
constructor(message: string, props?: any, ssf?: Function);
public name: string;
public message: string;
public showDiff: boolean;
public stack: string;
/**
* Allow errors to be converted to JSON for static transfer.
*
* @param {Boolean} include stack (default: `true`)
* @return {Object} object that can be `JSON.stringify`
*/
public toJSON(stack: boolean): Object;
}
}
declare module '~chai~assertion-error' {
import alias = require('~chai~assertion-error/main');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Assert.d.ts
declare module '~chai/lib/Assert' {
export interface AssertStatic extends Assert {
}
export interface Assert {
/**
* @param expression Expression to test for truthiness.
* @param message Message to display on error.
*/
(expression: any, message?: string): void;
(expression: any, messageCallback: () => string): void;
fail(actual?: any, expected?: any, msg?: string, operator?: string): void;
ok(val: any, msg?: string): void;
isOk(val: any, msg?: string): void;
notOk(val: any, msg?: string): void;
isNotOk(val: any, msg?: string): void;
equal(act: any, exp: any, msg?: string): void;
notEqual(act: any, exp: any, msg?: string): void;
strictEqual(act: any, exp: any, msg?: string): void;
notStrictEqual(act: any, exp: any, msg?: string): void;
deepEqual(act: any, exp: any, msg?: string): void;
notDeepEqual(act: any, exp: any, msg?: string): void;
isTrue(val: any, msg?: string): void;
isFalse(val: any, msg?: string): void;
isNotTrue(val: any, msg?: string): void;
isNotFalse(val: any, msg?: string): void;
isNull(val: any, msg?: string): void;
isNotNull(val: any, msg?: string): void;
isUndefined(val: any, msg?: string): void;
isDefined(val: any, msg?: string): void;
isNaN(val: any, msg?: string): void;
isNotNaN(val: any, msg?: string): void;
isAbove(val: number, abv: number, msg?: string): void;
isBelow(val: number, blw: number, msg?: string): void;
isAtLeast(val: number, atlst: number, msg?: string): void;
isAtMost(val: number, atmst: number, msg?: string): void;
isFunction(val: any, msg?: string): void;
isNotFunction(val: any, msg?: string): void;
isObject(val: any, msg?: string): void;
isNotObject(val: any, msg?: string): void;
isArray(val: any, msg?: string): void;
isNotArray(val: any, msg?: string): void;
isString(val: any, msg?: string): void;
isNotString(val: any, msg?: string): void;
isNumber(val: any, msg?: string): void;
isNotNumber(val: any, msg?: string): void;
isBoolean(val: any, msg?: string): void;
isNotBoolean(val: any, msg?: string): void;
typeOf(val: any, type: string, msg?: string): void;
notTypeOf(val: any, type: string, msg?: string): void;
instanceOf(val: any, type: Function, msg?: string): void;
notInstanceOf(val: any, type: Function, msg?: string): void;
include(exp: string, inc: any, msg?: string): void;
include(exp: any[], inc: any, msg?: string): void;
include(exp: Object, inc: Object, msg?: string): void;
notInclude(exp: string, inc: any, msg?: string): void;
notInclude(exp: any[], inc: any, msg?: string): void;
match(exp: any, re: RegExp, msg?: string): void;
notMatch(exp: any, re: RegExp, msg?: string): void;
property(obj: Object, prop: string, msg?: string): void;
notProperty(obj: Object, prop: string, msg?: string): void;
deepProperty(obj: Object, prop: string, msg?: string): void;
notDeepProperty(obj: Object, prop: string, msg?: string): void;
propertyVal(obj: Object, prop: string, val: any, msg?: string): void;
propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void;
deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
lengthOf(exp: any, len: number, msg?: string): void;
throw(fn: Function, msg?: string): void;
throw(fn: Function, regExp: RegExp): void;
throw(fn: Function, errType: Function, msg?: string): void;
throw(fn: Function, errType: Function, regExp: RegExp): void;
throws(fn: Function, msg?: string): void;
throws(fn: Function, regExp: RegExp): void;
throws(fn: Function, errType: Function, msg?: string): void;
throws(fn: Function, errType: Function, regExp: RegExp): void;
Throw(fn: Function, msg?: string): void;
Throw(fn: Function, regExp: RegExp): void;
Throw(fn: Function, errType: Function, msg?: string): void;
Throw(fn: Function, errType: Function, regExp: RegExp): void;
doesNotThrow(fn: Function, msg?: string): void;
doesNotThrow(fn: Function, regExp: RegExp): void;
doesNotThrow(fn: Function, errType: Function, msg?: string): void;
doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
operator(val: any, operator: string, val2: any, msg?: string): void;
closeTo(act: number, exp: number, delta: number, msg?: string): void;
approximately(act: number, exp: number, delta: number, msg?: string): void;
sameMembers(set1: any[], set2: any[], msg?: string): void;
sameDeepMembers(set1: any[], set2: any[], msg?: string): void;
includeMembers(superset: any[], subset: any[], msg?: string): void;
includeDeepMembers(superset: any[], subset: any[], msg?: string): void;
ifError(val: any, msg?: string): void;
isExtensible(obj: {}, msg?: string): void;
extensible(obj: {}, msg?: string): void;
isNotExtensible(obj: {}, msg?: string): void;
notExtensible(obj: {}, msg?: string): void;
isSealed(obj: {}, msg?: string): void;
sealed(obj: {}, msg?: string): void;
isNotSealed(obj: {}, msg?: string): void;
notSealed(obj: {}, msg?: string): void;
isFrozen(obj: Object, msg?: string): void;
frozen(obj: Object, msg?: string): void;
isNotFrozen(obj: Object, msg?: string): void;
notFrozen(obj: Object, msg?: string): void;
oneOf(inList: any, list: any[], msg?: string): void;
changes(fn: Function, obj: {}, property: string): void;
doesNotChange(fn: Function, obj: {}, property: string): void;
increases(fn: Function, obj: {}, property: string): void;
doesNotIncrease(fn: Function, obj: {}, property: string): void;
decreases(fn: Function, obj: {}, property: string): void;
doesNotDecrease(fn: Function, obj: {}, property: string): void;
}
}
declare module 'chai/lib/Assert' {
import alias = require('~chai/lib/Assert');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Assertion.d.ts
declare module '~chai/lib/Assertion' {
export interface AssertionStatic {
(target?: any, message?: string, stack?: Function): Assertion;
new (target?: any, message?: string, stack?: Function): Assertion;
}
export interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
not: Assertion;
deep: Deep;
any: KeyFilter;
all: KeyFilter;
a: TypeComparison;
an: TypeComparison;
include: Include;
includes: Include;
contain: Include;
contains: Include;
ok: Assertion;
true: Assertion;
false: Assertion;
null: Assertion;
undefined: Assertion;
NaN: Assertion;
exist: Assertion;
empty: Assertion;
arguments: Assertion;
Arguments: Assertion;
equal: Equal;
equals: Equal;
eq: Equal;
eql: Equal;
eqls: Equal;
property: Property;
ownProperty: OwnProperty;
haveOwnProperty: OwnProperty;
ownPropertyDescriptor: OwnPropertyDescriptor;
haveOwnPropertyDescriptor: OwnPropertyDescriptor;
length: Length;
lengthOf: Length;
match: Match;
matches: Match;
string(str: string, message?: string): Assertion;
keys: Keys;
key(str: string): Assertion;
throw: Throw;
throws: Throw;
Throw: Throw;
respondTo: RespondTo;
respondsTo: RespondTo;
itself: Assertion;
satisfy: Satisfy;
satisfies: Satisfy;
closeTo: CloseTo;
approximately: CloseTo;
members: Members;
increase: PropertyChange;
increases: PropertyChange;
decrease: PropertyChange;
decreases: PropertyChange;
change: PropertyChange;
changes: PropertyChange;
extensible: Assertion;
sealed: Assertion;
frozen: Assertion;
oneOf(list: any[], message?: string): Assertion;
}
export interface LanguageChains {
to: Assertion;
be: Assertion;
been: Assertion;
is: Assertion;
that: Assertion;
which: Assertion;
and: Assertion;
has: Assertion;
have: Assertion;
with: Assertion;
at: Assertion;
of: Assertion;
same: Assertion;
}
export interface NumericComparison {
above: NumberComparer;
gt: NumberComparer;
greaterThan: NumberComparer;
least: NumberComparer;
gte: NumberComparer;
below: NumberComparer;
lt: NumberComparer;
lessThan: NumberComparer;
most: NumberComparer;
lte: NumberComparer;
within(start: number, finish: number, message?: string): Assertion;
}
export interface NumberComparer {
(value: number, message?: string): Assertion;
}
export interface TypeComparison {
(type: string, message?: string): Assertion;
instanceof: InstanceOf;
instanceOf: InstanceOf;
}
export interface InstanceOf {
(constructor: Object, message?: string): Assertion;
}
export interface CloseTo {
(expected: number, delta: number, message?: string): Assertion;
}
export interface Deep {
equal: Equal;
equals: Equal;
eq: Equal;
include: Include;
property: Property;
members: Members;
}
export interface KeyFilter {
keys: Keys;
}
export interface Equal {
(value: any, message?: string): Assertion;
}
export interface Property {
(name: string, value?: any, message?: string): Assertion;
}
export interface OwnProperty {
(name: string, message?: string): Assertion;
}
export interface OwnPropertyDescriptor {
(name: string, descriptor: PropertyDescriptor, message?: string): Assertion;
(name: string, message?: string): Assertion;
}
export interface Length extends LanguageChains, NumericComparison {
(length: number, message?: string): Assertion;
}
export interface Include {
(value: Object, message?: string): Assertion;
(value: string, message?: string): Assertion;
(value: number, message?: string): Assertion;
string(value: string, message?: string): Assertion;
keys: Keys;
members: Members;
any: KeyFilter;
all: KeyFilter;
}
export interface Match {
(regexp: RegExp | string, message?: string): Assertion;
}
export interface Keys {
(...keys: any[]): Assertion;
(keys: any[]): Assertion;
(keys: Object): Assertion;
}
export interface Throw {
(): Assertion;
(expected: string, message?: string): Assertion;
(expected: RegExp, message?: string): Assertion;
(constructor: Error, expected?: string, message?: string): Assertion;
(constructor: Error, expected?: RegExp, message?: string): Assertion;
(constructor: Function, expected?: string, message?: string): Assertion;
(constructor: Function, expected?: RegExp, message?: string): Assertion;
}
export interface RespondTo {
(method: string, message?: string): Assertion;
}
export interface Satisfy {
(matcher: Function, message?: string): Assertion;
}
export interface Members {
(set: any[], message?: string): Assertion;
}
export interface PropertyChange {
(object: Object, prop: string, msg?: string): Assertion;
}
}
declare module 'chai/lib/Assertion' {
import alias = require('~chai/lib/Assertion');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Expect.d.ts
declare module '~chai/lib/Expect' {
import {AssertionStatic} from '~chai/lib/Assertion';
export interface ExpectStatic extends AssertionStatic {
fail(actual?: any, expected?: any, message?: string, operator?: string): void;
}
}
declare module 'chai/lib/Expect' {
import alias = require('~chai/lib/Expect');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Should.d.ts
declare module '~chai/lib/Should' {
export interface Should extends ShouldAssertion {
not: ShouldAssertion;
fail(actual: any, expected: any, message?: string, operator?: string): void;
}
export interface ShouldAssertion {
Throw: ShouldThrow;
throw: ShouldThrow;
equal(value1: any, value2: any, message?: string): void;
exist(value: any, message?: string): void;
}
export interface ShouldThrow {
(actual: Function): void;
(actual: Function, expected: string | RegExp, message?: string): void;
(actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void;
}
}
declare module 'chai/lib/Should' {
import alias = require('~chai/lib/Should');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Config.d.ts
declare module '~chai/lib/Config' {
export interface Config {
includeStack: boolean;
showDiff: boolean;
truncateThreshold: number;
}
}
declare module 'chai/lib/Config' {
import alias = require('~chai/lib/Config');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Utils.d.ts
declare module '~chai/lib/Utils' {
import {Assertion} from '~chai/lib/Assertion';
export interface PathInfo {
parent: any;
name: number|string;
value: any;
exists: boolean;
}
export interface Utils {
addChainableMethod(ctx: any, name: string, chainingBehavior: (value: any) => void): void;
addMethod(ctx: any, name: string, method: (value: any) => void): void;
addProperty(ctx: any, name: string, getter: () => void): void;
expectTypes(obj: Object, types: string[]): void;
flag(obj: Object, key: string, value?: any): any;
getActual(obj: Object, actual?: any): any;
getEnumerableProperties(obj: Object): string[];
getMessage(obj: Object, params: any[]): string;
getMessage(obj: Object, message: string, negateMessage: string): string;
getName(func: Function): string;
getPathInfo(path: string, obj: Object): PathInfo;
getPathValue(path: string, obj: Object): any;
getProperties(obj: Object): string[];
hasProperty(obj: Object, name: string): boolean;
transferFlags(assertion: Assertion | any, obj: Object, includeAll?: boolean): void;
inspect(obj: any): any;
}
}
declare module 'chai/lib/Utils' {
import alias = require('~chai/lib/Utils');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/lib/Chai.d.ts
declare module '~chai/lib/Chai' {
import * as AE from '~chai~assertion-error';
import * as Assert from '~chai/lib/Assert';
import * as A from '~chai/lib/Assertion';
import * as Expect from '~chai/lib/Expect';
import * as Should from '~chai/lib/Should';
import * as Config from '~chai/lib/Config';
import * as Utils from '~chai/lib/Utils';
namespace chai {
export interface AssertionStatic extends A.AssertionStatic {}
export class AssertionError extends AE.AssertionError {}
export var Assertion: A.AssertionStatic;
export var expect: Expect.ExpectStatic;
export var assert: Assert.AssertStatic;
export var config: Config.Config;
export var util: Utils.Utils;
export function should(): Should.Should;
export function Should(): Should.Should;
/**
* Provides a way to extend the internals of Chai
*/
export function use(fn: (chai: any, utils: Utils.Utils) => void): typeof chai;
}
export = chai;
/* tslint:disable:no-internal-module */
global {
interface Object {
should: A.Assertion;
}
}
}
declare module 'chai/lib/Chai' {
import alias = require('~chai/lib/Chai');
export = alias;
}
// Generated by typings
// Source: https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/index.d.ts
declare module '~chai/index' {
// Type definitions for chai 3.4.0
// Project: http://chaijs.com/
// Original Definitions by: Jed Mao <https://github.com/jedmao/>,
// Bart van der Schoor <https://github.com/Bartvds>,
// Andrew Brown <https://github.com/AGBrown>,
// Olivier Chevet <https://github.com/olivr70>,
// Matt Wistrand <https://github.com/mwistrand>
import chai = require('~chai/lib/Chai');
export = chai;
}
declare module 'chai/index' {
import alias = require('~chai/index');
export = alias;
}
declare module 'chai' {
import alias = require('~chai/index');
export = alias;
}

View File

@ -1,21 +0,0 @@
{
"resolution": "main",
"tree": {
"src": "https://raw.githubusercontent.com/typed-typings/npm-chai/793bee097a6a644e078a033603d88ac89eb7b560/typings.json",
"raw": "registry:npm/chai#3.5.0+20160415060238",
"main": "index.d.ts",
"global": false,
"dependencies": {
"assertion-error": {
"src": "https://raw.githubusercontent.com/typed-typings/npm-assertion-error/105841317bd2bdd5d110bfb763e49e482a77230d/typings.json",
"raw": "github:typed-typings/npm-assertion-error#105841317bd2bdd5d110bfb763e49e482a77230d",
"main": "main.d.ts",
"global": false,
"name": "assertion-error",
"type": "typings"
}
},
"name": "chai",
"type": "typings"
}
}