Clean up tests

This commit is contained in:
Roman Hotsiy 2016-07-01 16:30:45 +03:00
parent 81d06316ed
commit 4a475677f7
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 14 additions and 8 deletions

View File

@ -58,7 +58,7 @@ describe('Redoc components', () => {
}); });
it('should return promise', () => { it('should return promise', () => {
let res = Redoc.init(); let res = Redoc.init().catch(() => {/**/});
res.should.be.instanceof(Promise); res.should.be.instanceof(Promise);
}); });
@ -66,7 +66,7 @@ describe('Redoc components', () => {
spyOn(Redoc, 'hideLoadingAnimation').and.callThrough(); spyOn(Redoc, 'hideLoadingAnimation').and.callThrough();
spyOn(Redoc, 'displayError').and.callThrough(); spyOn(Redoc, 'displayError').and.callThrough();
let res = Redoc.init(); let res = Redoc.init();
return res.then(() => { return res.catch(() => {
expect(Redoc.hideLoadingAnimation).toHaveBeenCalled(); expect(Redoc.hideLoadingAnimation).toHaveBeenCalled();
expect(Redoc.displayError).toHaveBeenCalled(); expect(Redoc.displayError).toHaveBeenCalled();
}); });

View File

@ -79,10 +79,10 @@ export class Redoc extends BaseComponent implements AfterViewInit {
Redoc.hideLoadingAnimation(); Redoc.hideLoadingAnimation();
Redoc.appRef = appRef; Redoc.appRef = appRef;
console.log('ReDoc bootstrapped!'); console.log('ReDoc bootstrapped!');
}, err => { }).catch(err => {
console.log(err);
Redoc.hideLoadingAnimation(); Redoc.hideLoadingAnimation();
Redoc.displayError(err); Redoc.displayError(err);
throw err;
}); });
} }
@ -97,7 +97,6 @@ export class Redoc extends BaseComponent implements AfterViewInit {
} }
static displayError(err) { static displayError(err) {
console.log(err);
let redocEl = dom.query('redoc'); let redocEl = dom.query('redoc');
if (!redocEl) return; if (!redocEl) return;
let heading = 'Oops... ReDoc failed to render this spec'; let heading = 'Oops... ReDoc failed to render this spec';

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 } from '@angular/core';
import { OptionsService } from '../../services/index'; import { OptionsService } from '../../services/index';
import { import {

View File

@ -111,9 +111,18 @@ describe('Spec Helper', () => {
let resolved; let resolved;
beforeAll(() => { beforeAll(() => {
let pointer = '/paths/test5/get/parameters/0'; let pointer = '/paths/test5/get/parameters/0';
spyOn(console, 'warn').and.stub();
resolved = normalizer.normalize(specMgr.byPointer(pointer), pointer); resolved = normalizer.normalize(specMgr.byPointer(pointer), pointer);
}); });
afterAll(() => {
(<jasmine.Spy>console.warn).and.callThrough();
});
it('should print warning to console', () => {
expect(console.warn).toHaveBeenCalled();
});
it('should skip other fields', () => { it('should skip other fields', () => {
expect(resolved.$ref).toBeUndefined(); expect(resolved.$ref).toBeUndefined();
expect(resolved.title).toBeDefined(); expect(resolved.title).toBeDefined();

View File

@ -110,8 +110,6 @@
"parameters": [ "parameters": [
{ {
"$ref": "#/definitions/CircularTransitive", "$ref": "#/definitions/CircularTransitive",
"title": "test",
"description": "test"
} }
] ]
} }