Skip to content

Commit

Permalink
[DSC-472] Automated Test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sufiyan Shaikh committed Mar 8, 2022
1 parent d8ef53c commit d27fdfa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
36 changes: 36 additions & 0 deletions src/app/shared/context-menu/context-menu.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ describe('ContextMenuComponent', () => {
done();
});

it('should display d-none', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-none'));
expect(menu).not.toBeNull();
done();
});

it('should not display d-inline-block', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-inline-block'));
expect(menu).toBeNull();
done();
});

it('should display stand alone buttons', (done) => {
const menu = fixture.debugElement.query(By.css('button.btn-primary'));
expect(menu).not.toBeNull();
Expand Down Expand Up @@ -203,6 +215,18 @@ describe('ContextMenuComponent', () => {
done();
});

it('should display d-none', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-none'));
expect(menu).not.toBeNull();
done();
});

it('should not display d-inline-block', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-inline-block'));
expect(menu).toBeNull();
done();
});

it('should not display stand alone buttons', (done) => {
const menu = fixture.debugElement.query(By.css('button.btn-primary'));
expect(menu).not.toBeNull();
Expand Down Expand Up @@ -232,6 +256,18 @@ describe('ContextMenuComponent', () => {
done();
});

it('should display d-inline-block', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-inline-block'));
expect(menu).toBeNull();
done();
});

it('should not display d-none', (done) => {
const menu = fixture.debugElement.query(By.css('div.d-none'));
expect(menu).toBeNull();
done();
});

it('should check the authorization of the current user', (done) => {
expect(component.isAuthenticated).toBeObservable(cold('a', { a: false }));
done();
Expand Down
14 changes: 8 additions & 6 deletions src/app/shared/context-menu/context-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ export class ContextMenuComponent implements OnInit {

ngAfterViewChecked() {
// To check that Context-menu contains options or not
const el = Array.from(document.getElementById('itemOptionsDropdownMenu')?.getElementsByClassName('ng-star-inserted'));
this.optionCount = 0;
if (el) {
el.forEach(element => {
this.optionCount += element.childElementCount;
});
if (document.getElementById('itemOptionsDropdownMenu')) {
const el = Array.from(document.getElementById('itemOptionsDropdownMenu')?.getElementsByClassName('ng-star-inserted'));
this.optionCount = 0;
if (el) {
el.forEach(element => {
this.optionCount += element.childElementCount;
});
}
}
}
}

0 comments on commit d27fdfa

Please sign in to comment.