navbar-actions.spec.ts
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
import {Provider} from 'ng-forward';
import {ComponentTestHelper, createClass} from "./../../../spec/component-test-helper";
import {providers} from 'ng-forward/cjs/testing/providers';
import {ContentViewerActionsComponent} from '././content-viewer-actions.component';
import * as helpers from "../../../spec/helpers";
const htmlTemplate: string = '<content-viewer-actions [article]="ctrl.article" [profile]="ctrl.profile"></content-viewer-actions>';
describe("Components", () => {
describe("Content Viewer Actions Component", () => {
let serviceMock = {
getEnvironmentPeople: (filters: any): any => {
return Promise.resolve([{ identifier: "person1" }]);
}
};
let providers = [
new Provider('ArticleService', { useValue: helpers.mocks.articleService }),
new Provider('ProfileService', { useValue: helpers.mocks.profileService })
];
let helper: ComponentTestHelper<ContentViewerActionsComponent>;
beforeEach(angular.mock.module("templates"));
/**
* The beforeEach procedure will initialize the helper and parse
* the component according to the given providers. Unfortunetly, in
* this mode, the providers and properties given to the construtor
* can't be overriden.
*/
beforeEach((done) => {
// Create the component bed for the test. Optionally, this could be done
// in each test if one needs customization of these parameters per test
let cls = createClass({
template: htmlTemplate,
directives: [ContentViewerActionsComponent],
providers: providers,
properties: {}
});
helper = new ComponentTestHelper<ContentViewerActionsComponent>(cls, done);
});
it("render the actions new item menu", () => {
expect(helper.all("a[class|='btn dropdown-toggle']")[0]).not.toBeNull();
});
it("render two menu item actions", () => {
expect(helper.all("ul")[1].find("li").length).toBe(2);
});
});
});