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

View File

@ -4,6 +4,11 @@
<title>ReDoc</title>
<link rel="stylesheet" href="main.css">
<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>
<body>
<nav>

View File

@ -51,25 +51,26 @@ module.exports = function (config) {
'node_modules/zone.js/dist/jasmine-patch.js',
'node_modules/zone.js/dist/long-stack-trace-zone.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: {
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',
'.tmp/lib/**/*.json', '.tmp/*js', '.tmp/lib/**/*.scss'],
'.tmp/lib/**/*.json', '.tmp/*js', '.tmp/lib/**/*.css'],
nocache: true
},
proxies: {
'/tests/': '/base/tests/',
'/lib/components/Redoc/redoc-initial-styles.scss': '/base/.tmp/lib/components/Redoc/redoc-initial-styles.scss',
'/tests/schemas': '/base/tests/schemas',
'/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/': '/base/lib/',
'/jspm_packages/': '/base/jspm_packages/',
'/node_modules/': '/base/node_modules/',
'/prismjs-bundle.js': '/base/.tmp/prismjs-bundle.js',
'/.tmp/': '/base/.tmp/'
},
reporters: travis ? ['mocha', 'coverage', 'coveralls'] : ['mocha', 'coverage'],

View File

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

View File

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

View File

@ -1,9 +1,8 @@
'use strict';
import { getChildDebugElement } from 'tests/helpers';
import { getChildDebugElement } from '../../../tests/helpers';
import { Component, provide } from '@angular/core';
import { DynamicComponentLoader } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import {
inject,
@ -15,9 +14,8 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing';
import { JsonSchemaLazy } from 'lib/components/JsonSchema/json-schema-lazy';
import SchemaManager from 'lib/utils/SchemaManager';
import { OptionsService } from 'lib/services/index';
import { JsonSchemaLazy } from './json-schema-lazy';
import { SchemaManager } from '../../utils/SchemaManager';
describe('Redoc components', () => {
describe('JsonSchemaLazy Component', () => {
@ -26,25 +24,25 @@ describe('Redoc components', () => {
let schemaMgr = new SchemaManager();
let fixture;
let loader;
let appRef = {
instance: {},
let appRefMock = {
instance: {
pointer: ''
},
hostView: {changeDetectorRef: {detectChanges : function() {} }}
};
beforeEachProviders(() => [
provide(SchemaManager, {useValue: schemaMgr}),
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
provide(OptionsService, {useClass: OptionsService})
provide(SchemaManager, {useValue: schemaMgr})
]);
beforeEach(inject([TestComponentBuilder, DynamicComponentLoader], (tcb, dcl) => {
builder = tcb;
loader = dcl;
spyOn(loader, 'loadNextToLocation').and.returnValue({then: (fn) => fn(appRef)});
spyOn(loader, 'loadNextToLocation').and.returnValue({then: (fn) => fn(appRefMock)});
}));
beforeEach((done) => {
builder.createAsync(TestApp).then(_fixture => {
fixture = _fixture;
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
component = debugEl.componentInstance;
component = <JsonSchemaLazy>debugEl.componentInstance;
done();
}, err => done.fail(err));
});
@ -76,7 +74,7 @@ describe('Redoc components', () => {
component.pointer = '#/def';
fixture.detectChanges();
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';
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 SchemaManager from 'lib/utils/SchemaManager';
import { JsonSchema } from './json-schema';
import { SchemaManager } from '../../utils/SchemaManager';;
describe('Redoc components', () => {
describe('JsonSchema Component', () => {
@ -23,8 +22,7 @@ describe('Redoc components', () => {
let schemaMgr = new SchemaManager();
let fixture;
beforeEachProviders(() => [
provide(SchemaManager, {useValue: schemaMgr}),
provide(OptionsService, {useClass: OptionsService})
provide(SchemaManager, {useValue: schemaMgr})
]);
beforeEach(inject([TestComponentBuilder], (tcb) => {
builder = tcb;
@ -40,21 +38,21 @@ describe('Redoc components', () => {
it('should init component', () => {
component.pointer = '';
schemaMgr._schema = {type: 'object'};
(<any>schemaMgr)._schema = {type: 'object'};
fixture.detectChanges();
expect(component).not.toBeNull();
});
it('should set isTrivial for non-object/array types', () => {
component.pointer = '';
schemaMgr._schema = {type: 'string'};
(<any>schemaMgr)._schema = {type: 'string'};
fixture.detectChanges();
component.schema.isTrivial.should.be.true();
});
it('should use < * > notation for prop without type', () => {
component.pointer = '';
schemaMgr._schema = {type: 'object', properties: {
(<any>schemaMgr)._schema = {type: 'object', properties: {
test: {}
}};
fixture.detectChanges();

View File

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

View File

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

View File

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

View File

@ -69,7 +69,7 @@ export class Redoc extends BaseComponent {
}, 400);
}
static init(specUrl, options?) {
static init(specUrl?, options?) {
var optionsService = new OptionsService(dom);
optionsService.options = options;
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';
import { getChildDebugElement } from 'tests/helpers';
import { getChildDebugElement } from '../../../tests/helpers';
import { Component, provide } from '@angular/core';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { OptionsService, RedocEventsService } from 'lib/services/index';
import { OptionsService } from '../../services/index';
import {
inject,
@ -15,17 +14,11 @@ import {
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();
testOptions.options = {
scrollYOffset: () => 0,
scrollParent: window
};
let redocEvents = new RedocEventsService();
let testOptions;
describe('Redoc components', () => {
describe('SideMenu Component', () => {
@ -33,13 +26,16 @@ describe('Redoc components', () => {
let component;
let fixture;
beforeEachProviders(() => [
provide(SchemaManager, {useValue: new SchemaManager()}),
provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}),
provide(OptionsService, {useValue: testOptions}),
provide(RedocEventsService, {useValue: redocEvents})
provide(SchemaManager, {useValue: new SchemaManager()})
]);
beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => {
beforeEach(async(inject([TestComponentBuilder, SchemaManager, OptionsService],
(tcb, schemaMgr, opts) => {
builder = tcb;
testOptions = opts;
testOptions.options = {
scrollYOffset: () => 0,
scrollParent: window
};
return schemaMgr.load('/tests/schemas/extended-petstore.yml');
})));

View File

@ -1,7 +1,7 @@
'use strict';
import SchemaManager from 'lib/utils/SchemaManager';
import { BaseComponent } from 'lib/components/base';
import { SchemaManager } from '../utils/SchemaManager';
import { BaseComponent } from '../components/base';
describe('Redoc components', () => {
describe('BaseComponent', () => {
@ -30,11 +30,14 @@ describe('Redoc components', () => {
});
it('should call prepareModel and init virtual methods after init', () => {
sinon.spy(component, 'prepareModel');
sinon.spy(component, 'init');
spyOn(component, 'prepareModel');
spyOn(component, 'init');
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', () => {

View File

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

View File

@ -2,7 +2,7 @@
import 'dropkickjs/build/css/dropkick.css!css';
import 'prismjs/themes/prism-dark.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';

View File

@ -16,8 +16,8 @@ import { MenuService } from './menu.service';
import { Hash } from './hash.service';
import { ScrollService } from './scroll.service';
import { RedocEventsService } from './events.service';
import { MethodsList } from 'lib/components/index';
import SchemaManager from 'lib/utils/SchemaManager';
import { MethodsList } from '../components/index';
import { SchemaManager } from '../utils/SchemaManager';;
describe('Menu service', () => {
let menu, hashService, scroll;
@ -73,9 +73,9 @@ describe('Menu service', () => {
spyOn(window, 'scrollTo').and.stub();
hashService.changed.subscribe(() => {
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);
window.scrollTo.and.callThrough();
(<jasmine.Spy>window.scrollTo).and.callThrough();
done();
});
hashService.changed.next(hash);
@ -87,7 +87,7 @@ describe('Menu service', () => {
spyOn(window, 'scrollTo').and.stub();
hashService.changed.subscribe(() => {
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);
done();
});

View File

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

View File

@ -1,6 +1,6 @@
'use strict';
import { getChildDebugElement, getChildDebugElementAll } from 'tests/helpers';
import { getChildDebugElement, getChildDebugElementAll } from '../../../../tests/helpers';
import {Component} from '@angular/core';
import {
@ -11,7 +11,7 @@ import {
import { TestComponentBuilder } from '@angular/compiler/testing';
import {Tabs, Tab} from 'lib/shared/components/index';
import {Tabs, Tab} from '../index';
describe('Common components', () => {
describe('Tabs Component', () => {
@ -148,6 +148,7 @@ describe('Common components', () => {
</tabs>`
})
class TestApp {
eventLog: any;
constructor() {
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';
import { getChildDebugElement, mouseclick } from 'tests/helpers';
import { getChildDebugElement, mouseclick } from '../../../../tests/helpers';
import { Component } from '@angular/core';
import {
inject,
beforeEach,
it
it,
expect
} from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { Zippy } from 'lib/shared/components/index';
import { Zippy } from '../index';
describe('Common components', () => {
describe('Zippy Component', () => {
@ -54,7 +55,7 @@ describe('Common components', () => {
it('project inner content', () => {
fixture.detectChanges();
let contentEl = nativeElement.querySelector('.zippy-content');
expect(contentEl).toHaveText('\n test\n ');
expect(contentEl.innerText).toMatch('test');
});
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>`
})
class TestApp {
opened: boolean;
clickCount: number;
constructor() {
this.opened = false;
this.clickCount = 0;

View File

@ -6,7 +6,7 @@ const origParse = JsonPointerLib.parse;
* Wrapper for JsonPointer. Provides common operations
*/
class JsonPointer {
export class JsonPointer {
/**
* returns last JsonPointer token
* 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';
export class SchemaManager {
private _schema:any = {};
public _schema:any = {};
private _instance:any;
apiUrl: string;

View File

@ -20,7 +20,8 @@ export function getChildDebugElementAll(parent, tagName) {
export function mouseclick( element ) {
// create a mouse click event
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
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';
import {JsonPointer} from 'lib/utils/JsonPointer';
import {JsonPointer} from '../../lib/utils/JsonPointer';
// test extended JsonPointer
describe('Utils', () => {
describe('JsonPointer', () => {

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,8 @@
"jasmine": "registry:dt/jasmine#2.2.0+20160505161446"
},
"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": {
"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/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"
}
}