Commit 1eeaf5bc72bb4663196cba6c9461a91bed77cc0e

Authored by ABNER SILVA DE OLIVEIRA
1 parent 3f5563c8

added tests to check if button remove is displayed or not according to the retur…

…n of the  allowRemove method.
src/app/article/comment/comment.component.spec.ts
... ... @@ -80,6 +80,26 @@ describe("Components", () => {
80 80 });
81 81 });
82 82  
  83 + it("does not show the Remove button if user is not allowed to remove", done => {
  84 + createComponent().then(fixture => {
  85 + let component: CommentComponent = fixture.debugElement.componentViewChildren[0].componentInstance;
  86 + component.allowRemove = () => false;
  87 + fixture.detectChanges();
  88 + expect(fixture.debugElement.queryAll("a.action.remove").length).toEqual(0);
  89 + done();
  90 + });
  91 + });
  92 +
  93 + it("shows the Remove button if user is allowed to remove", done => {
  94 + createComponent().then(fixture => {
  95 + let component: CommentComponent = fixture.debugElement.componentViewChildren[0].componentInstance;
  96 + component.allowRemove = () => true;
  97 + fixture.detectChanges();
  98 + expect(fixture.debugElement.queryAll("a.action.remove").length).toEqual(1);
  99 + done();
  100 + });
  101 + });
  102 +
83 103 it("call comment service to remove comment", done => {
84 104 notificationService.confirmation = (params: any, func: Function) => { func(); };
85 105 commentService.removeFromArticle = jasmine.createSpy("removeFromArticle").and.returnValue(Promise.resolve());
... ...