Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { ComponentFixture, TestBed, async, inject, fakeAsync, flush } from '@angular/core/testing';
- import {
- MatCheckboxModule,
- MatSelectModule
- } from '@angular/material';
- import { By } from '@angular/platform-browser';
- import { SelectMenuTestHelper } from './select-menu-test.helper';
- describe('SelectOptionComponent', () => {
- let component: SelectOptionComponent;
- let fixture: ComponentFixture<SelectOptionComponent>;
- beforeEach(() => {
- TestBed.configureTestingModule({
- declarations: [
- SelectOptionComponent
- ],
- imports: [
- MatCheckboxModule,
- MatSelectModule,
- BrowserAnimationsModule
- ]
- }).compileComponents();
- });
- beforeEach(async(() => {
- fixture = TestBed.createComponent(SelectOptionComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- }));
- it('should be created', () => {
- expect(component).toBeTruthy();
- });
- describe('Select Menu changes', () => {
- let options: HTMLElement[];
- let selectMenu: SelectMenuTestHelper;
- beforeEach(() => {
- selectMenu = new SelectMenuTestHelper(fixture);
- component.users = [
- { id: randomId(), displayName: 'User1' }
- ];
- });
- beforeEach(fakeAsync(() => {
- selectMenu.triggerMenu();
- options = selectMenu.getOptions();
- }));
- afterEach(() => {
- selectMenu.cleanup();
- });
- it('should disable user check boxes if user security option inherit is selected', fakeAsync(() => {
- options.forEach((option: HTMLElement) => {
- selectMenu.selectOption(option);
- const checked = fixture.debugElement.query(By.css('.mat-checkbox-input')).nativeElement;
- if (option.innerText.trim() === 'security.inherit') {
- expect(checked.disabled).toEqual(true);
- } else {
- expect(checked.disabled).toEqual(false);
- }
- });
- }));
- });
- });
Add Comment
Please, Sign In to add comment