Commit a4fb50e283c46e4478ce3a2c8600ab3d4f1fbbc2
1 parent
9a88aab0
Exists in
master
and in
26 other branches
Test behavior of comment component when article doesn't accept comments
Showing
2 changed files
with
26 additions
and
4 deletions
Show diff stats
src/app/article/comment/comment.component.spec.ts
| @@ -7,16 +7,23 @@ const htmlTemplate: string = '<noosfero-comment [article]="ctrl.article" [commen | @@ -7,16 +7,23 @@ const htmlTemplate: string = '<noosfero-comment [article]="ctrl.article" [commen | ||
| 7 | describe("Components", () => { | 7 | describe("Components", () => { |
| 8 | describe("Comment Component", () => { | 8 | describe("Comment Component", () => { |
| 9 | 9 | ||
| 10 | - beforeEach(angular.mock.module("templates")); | 10 | + let properties: any; |
| 11 | 11 | ||
| 12 | + beforeEach(angular.mock.module("templates")); | ||
| 13 | + beforeEach(() => { | ||
| 14 | + properties = { | ||
| 15 | + article: { id: 1, accept_comments: true }, | ||
| 16 | + comment: { title: "title", body: "body" } | ||
| 17 | + }; | ||
| 18 | + }); | ||
| 12 | 19 | ||
| 13 | function createComponent() { | 20 | function createComponent() { |
| 14 | let providers = helpers.provideFilters("translateFilter"); | 21 | let providers = helpers.provideFilters("translateFilter"); |
| 15 | 22 | ||
| 16 | @Component({ selector: 'test-container-component', directives: [CommentComponent], template: htmlTemplate, providers: providers }) | 23 | @Component({ selector: 'test-container-component', directives: [CommentComponent], template: htmlTemplate, providers: providers }) |
| 17 | class ContainerComponent { | 24 | class ContainerComponent { |
| 18 | - article = { id: 1 }; | ||
| 19 | - comment = { title: "title", body: "body" }; | 25 | + article = properties['article']; |
| 26 | + comment = properties['comment']; | ||
| 20 | } | 27 | } |
| 21 | return helpers.createComponentFromClass(ContainerComponent); | 28 | return helpers.createComponentFromClass(ContainerComponent); |
| 22 | } | 29 | } |
| @@ -52,5 +59,20 @@ describe("Components", () => { | @@ -52,5 +59,20 @@ describe("Components", () => { | ||
| 52 | done(); | 59 | done(); |
| 53 | }); | 60 | }); |
| 54 | }); | 61 | }); |
| 62 | + | ||
| 63 | + it("display reply button", done => { | ||
| 64 | + createComponent().then(fixture => { | ||
| 65 | + expect(fixture.debugElement.queryAll(".comment .actions .reply").length).toEqual(1); | ||
| 66 | + done(); | ||
| 67 | + }); | ||
| 68 | + }); | ||
| 69 | + | ||
| 70 | + it("not display reply button when accept_comments is false", done => { | ||
| 71 | + properties['article']['accept_comments'] = false; | ||
| 72 | + createComponent().then(fixture => { | ||
| 73 | + expect(fixture.debugElement.queryAll(".comment .actions .reply").length).toEqual(0); | ||
| 74 | + done(); | ||
| 75 | + }); | ||
| 76 | + }); | ||
| 55 | }); | 77 | }); |
| 56 | }); | 78 | }); |
src/app/article/comment/comment.html
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | <div class="title">{{ctrl.comment.title}}</div> | 18 | <div class="title">{{ctrl.comment.title}}</div> |
| 19 | <div class="body">{{ctrl.comment.body}}</div> | 19 | <div class="body">{{ctrl.comment.body}}</div> |
| 20 | <div class="actions" ng-if="ctrl.displayActions"> | 20 | <div class="actions" ng-if="ctrl.displayActions"> |
| 21 | - <a href="#" (click)="ctrl.reply()" class="small text-muted" ng-if="ctrl.article.accept_comments"> | 21 | + <a href="#" (click)="ctrl.reply()" class="small text-muted reply" ng-if="ctrl.article.accept_comments"> |
| 22 | {{"comment.reply" | translate}} | 22 | {{"comment.reply" | translate}} |
| 23 | </a> | 23 | </a> |
| 24 | </div> | 24 | </div> |