diff --git a/src/app/content-viewer/content-viewer-actions.component.spec.ts b/src/app/content-viewer/content-viewer-actions.component.spec.ts new file mode 100644 index 0000000..35f9034 --- /dev/null +++ b/src/app/content-viewer/content-viewer-actions.component.spec.ts @@ -0,0 +1,67 @@ +import {providers} from 'ng-forward/cjs/testing/providers'; + +import {Input, Component, provide} from 'ng-forward'; + +import * as helpers from "../../spec/helpers"; + +import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; +import {ContentViewerActions} from './content-viewer-actions.component'; + +// this htmlTemplate will be re-used between the container components in this spec file +const htmlTemplate: string = ''; + +describe('Content Viewer Actions Component', () => { + + beforeEach(() => { + + angular.mock.module("templates"); + + providers((provide: any) => { + return [ + provide('ProfileService', { + useValue: helpers.mocks.profileService + }) + ]; + }); + }); + + let buildComponent = (): Promise => { + return helpers.quickCreateComponent({ + providers: [ + helpers.provideEmptyObjects('Restangular'), + helpers.provideFilters('translateFilter') + ], + directives: [ContentViewerActions], + template: htmlTemplate + }); + }; + + it('renders content viewer actions directive', (done: Function) => { + buildComponent().then((fixture: ComponentFixture) => { + expect(fixture.debugElement.query('content-viewer-actions').length).toEqual(1); + + done(); + }); + }); + + it('check if profile was loaded', (done: Function) => { + let profile: any = { + id: 1, + identifier: 'the-profile-test', + type: 'Person' + }; + + helpers.mocks.profileService.getCurrentProfile = () => { + return helpers.mocks.promiseResultTemplate(profile); + }; + + buildComponent().then((fixture: ComponentFixture) => { + let contentViewerComp: ContentViewerActions = fixture.debugElement.componentViewChildren[0].componentInstance; + + expect(contentViewerComp.profile).toEqual(jasmine.objectContaining(profile)); + + done(); + }); + }); + +}); diff --git a/src/spec/mocks.ts b/src/spec/mocks.ts index ab9ad6a..da1053a 100644 --- a/src/spec/mocks.ts +++ b/src/spec/mocks.ts @@ -93,6 +93,6 @@ export var mocks = { then: (func?: (response: any) => void) => { if (func) { return func(response); } } - } + }; } }; -- libgit2 0.21.2