2016-01-24 22:27:15 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-12 20:44:34 +03:00
|
|
|
import { getChildDebugElement } from '../../../tests/helpers';
|
2016-07-01 15:53:16 +03:00
|
|
|
import { Component } from '@angular/core';
|
2016-01-24 22:27:15 +03:00
|
|
|
|
|
|
|
import {
|
|
|
|
inject,
|
2016-07-01 15:53:16 +03:00
|
|
|
TestComponentBuilder
|
2016-05-06 00:48:41 +03:00
|
|
|
} from '@angular/core/testing';
|
|
|
|
|
2016-06-12 20:44:34 +03:00
|
|
|
import { JsonSchemaLazy } from './json-schema-lazy';
|
2016-01-24 22:27:15 +03:00
|
|
|
|
|
|
|
describe('Redoc components', () => {
|
|
|
|
describe('JsonSchemaLazy Component', () => {
|
|
|
|
let builder;
|
|
|
|
let component;
|
|
|
|
let fixture;
|
2016-07-01 15:53:16 +03:00
|
|
|
|
|
|
|
beforeEach(inject([TestComponentBuilder], (tcb) => {
|
2016-01-24 22:27:15 +03:00
|
|
|
builder = tcb;
|
|
|
|
}));
|
2016-07-01 15:53:16 +03:00
|
|
|
beforeEach(() => {
|
|
|
|
fixture = builder.createSync(TestAppComponent);
|
|
|
|
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
|
|
|
|
component = <JsonSchemaLazy>debugEl.componentInstance;
|
|
|
|
spyOn(component, '_loadAfterSelf').and.stub();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
component._loadAfterSelf.and.callThrough();
|
2016-01-24 22:27:15 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should init component', () => {
|
|
|
|
expect(component).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should run loadNextToLocation on load', () => {
|
|
|
|
component.pointer = '#/def';
|
|
|
|
fixture.detectChanges();
|
|
|
|
component.load();
|
2016-06-29 19:06:42 +03:00
|
|
|
expect(component._loadAfterSelf).toHaveBeenCalled();
|
2016-01-24 22:27:15 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should not run loadNextToLocation if already loaded', () => {
|
|
|
|
component.pointer = '#/def';
|
|
|
|
fixture.detectChanges();
|
|
|
|
component.load();
|
|
|
|
component.load();
|
2016-06-29 19:06:42 +03:00
|
|
|
expect(component._loadAfterSelf.calls.count()).toEqual(1);
|
2016-01-24 22:27:15 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/** Test component that contains a Method. */
|
2016-03-27 18:25:46 +03:00
|
|
|
@Component({
|
|
|
|
selector: 'test-app',
|
2016-01-24 22:27:15 +03:00
|
|
|
directives: [JsonSchemaLazy],
|
|
|
|
template:
|
|
|
|
`<json-schema-lazy></json-schema-lazy>`
|
|
|
|
})
|
2016-06-13 20:54:24 +03:00
|
|
|
class TestAppComponent {
|
2016-01-24 22:27:15 +03:00
|
|
|
}
|