Guest User

Untitled

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. import { ComponentFixture, TestBed, async, inject, fakeAsync, flush } from '@angular/core/testing';
  2. import {
  3. MatCheckboxModule,
  4. MatSelectModule
  5. } from '@angular/material';
  6. import { By } from '@angular/platform-browser';
  7.  
  8. import { SelectMenuTestHelper } from './select-menu-test.helper';
  9.  
  10. describe('SelectOptionComponent', () => {
  11. let component: SelectOptionComponent;
  12. let fixture: ComponentFixture<SelectOptionComponent>;
  13.  
  14. beforeEach(() => {
  15. TestBed.configureTestingModule({
  16. declarations: [
  17. SelectOptionComponent
  18. ],
  19. imports: [
  20. MatCheckboxModule,
  21. MatSelectModule,
  22. BrowserAnimationsModule
  23. ]
  24. }).compileComponents();
  25.  
  26. });
  27.  
  28. beforeEach(async(() => {
  29. fixture = TestBed.createComponent(SelectOptionComponent);
  30. component = fixture.componentInstance;
  31. fixture.detectChanges();
  32. }));
  33.  
  34. it('should be created', () => {
  35. expect(component).toBeTruthy();
  36. });
  37.  
  38. describe('Select Menu changes', () => {
  39. let options: HTMLElement[];
  40. let selectMenu: SelectMenuTestHelper;
  41.  
  42. beforeEach(() => {
  43. selectMenu = new SelectMenuTestHelper(fixture);
  44. component.users = [
  45. { id: randomId(), displayName: 'User1' }
  46. ];
  47. });
  48.  
  49. beforeEach(fakeAsync(() => {
  50. selectMenu.triggerMenu();
  51. options = selectMenu.getOptions();
  52. }));
  53.  
  54. afterEach(() => {
  55. selectMenu.cleanup();
  56. });
  57.  
  58. it('should disable user check boxes if user security option inherit is selected', fakeAsync(() => {
  59. options.forEach((option: HTMLElement) => {
  60. selectMenu.selectOption(option);
  61. const checked = fixture.debugElement.query(By.css('.mat-checkbox-input')).nativeElement;
  62. if (option.innerText.trim() === 'security.inherit') {
  63. expect(checked.disabled).toEqual(true);
  64. } else {
  65. expect(checked.disabled).toEqual(false);
  66. }
  67. });
  68. }));
  69. });
  70. });
Add Comment
Please, Sign In to add comment