"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib/list/selection-list.spec.ts" between
material2-7.3.2.tar.gz and material2-7.3.3.tar.gz

About: material2 offers Material Design components for Angular.

selection-list.spec.ts  (material2-7.3.2):selection-list.spec.ts  (material2-7.3.3)
import {DOWN_ARROW, SPACE, ENTER, UP_ARROW, HOME, END, A} from '@angular/cdk/key codes'; import {DOWN_ARROW, SPACE, ENTER, UP_ARROW, HOME, END, A} from '@angular/cdk/key codes';
import { import {
createKeyboardEvent, createKeyboardEvent,
dispatchFakeEvent, dispatchFakeEvent,
dispatchEvent, dispatchEvent,
dispatchKeyboardEvent, dispatchKeyboardEvent,
dispatchMouseEvent,
} from '@angular/cdk/testing'; } from '@angular/cdk/testing';
import { import {
Component, Component,
DebugElement, DebugElement,
ChangeDetectionStrategy, ChangeDetectionStrategy,
QueryList, QueryList,
ViewChildren, ViewChildren,
} from '@angular/core'; } from '@angular/core';
import {async, ComponentFixture, fakeAsync, TestBed, tick, flush} from '@angular /core/testing'; import {async, ComponentFixture, fakeAsync, TestBed, tick, flush} from '@angular /core/testing';
import {MatRipple} from '@angular/material/core'; import {MatRipple, defaultRippleAnimationConfig} from '@angular/material/core';
import {By} from '@angular/platform-browser'; import {By} from '@angular/platform-browser';
import { import {
MatListModule, MatListModule,
MatListOption, MatListOption,
MatSelectionList, MatSelectionList,
MatSelectionListChange MatSelectionListChange
} from './index'; } from './index';
import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/f orms'; import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/f orms';
describe('MatSelectionList without forms', () => { describe('MatSelectionList without forms', () => {
skipping to change at line 523 skipping to change at line 524
const list: MatSelectionList = selectionList.componentInstance; const list: MatSelectionList = selectionList.componentInstance;
expect(list.options.toArray().every(option => option.selected)).toBe(false ); expect(list.options.toArray().every(option => option.selected)).toBe(false );
list.selectAll(); list.selectAll();
descendatsFixture.detectChanges(); descendatsFixture.detectChanges();
expect(list.options.toArray().every(option => option.selected)).toBe(true) ; expect(list.options.toArray().every(option => option.selected)).toBe(true) ;
}); });
it('should disable list item ripples when the ripples on the list have been
disabled',
fakeAsync(() => {
const rippleTarget = fixture.nativeElement
.querySelector('.mat-list-option:not(.mat-list-item-disabled) .mat-l
ist-item-content');
const {enterDuration, exitDuration} = defaultRippleAnimationConfig;
dispatchMouseEvent(rippleTarget, 'mousedown');
dispatchMouseEvent(rippleTarget, 'mouseup');
expect(rippleTarget.querySelectorAll('.mat-ripple-element').length)
.toBe(1, 'Expected ripples to be enabled by default.');
// Wait for the ripples to go away.
tick(enterDuration + exitDuration);
expect(rippleTarget.querySelectorAll('.mat-ripple-element').length)
.toBe(0, 'Expected ripples to go away.');
fixture.componentInstance.listRippleDisabled = true;
fixture.detectChanges();
dispatchMouseEvent(rippleTarget, 'mousedown');
dispatchMouseEvent(rippleTarget, 'mouseup');
expect(rippleTarget.querySelectorAll('.mat-ripple-element').length)
.toBe(0, 'Expected no ripples after list ripples are disabled.');
}));
}); });
describe('with list option selected', () => { describe('with list option selected', () => {
let fixture: ComponentFixture<SelectionListWithSelectedOption>; let fixture: ComponentFixture<SelectionListWithSelectedOption>;
let listItemEl: DebugElement; let listItemEl: DebugElement;
let selectionList: DebugElement; let selectionList: DebugElement;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [MatListModule], imports: [MatListModule],
skipping to change at line 1092 skipping to change at line 1120
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
expect(testComponent.compareWith).toHaveBeenCalled(); expect(testComponent.compareWith).toHaveBeenCalled();
expect(testComponent.optionInstances.toArray()[1].selected).toBe(true); expect(testComponent.optionInstances.toArray()[1].selected).toBe(true);
})); }));
}); });
}); });
@Component({template: ` @Component({template: `
<mat-selection-list id="selection-list-1" (selectionChange)="onValueChange($ev <mat-selection-list
ent)"> id="selection-list-1"
(selectionChange)="onValueChange($event)"
[disableRipple]="listRippleDisabled">
<mat-list-option checkboxPosition="before" disabled="true" value="inbox"> <mat-list-option checkboxPosition="before" disabled="true" value="inbox">
Inbox (disabled selection-option) Inbox (disabled selection-option)
</mat-list-option> </mat-list-option>
<mat-list-option id="testSelect" checkboxPosition="before" class="test-nativ e-focus" <mat-list-option id="testSelect" checkboxPosition="before" class="test-nativ e-focus"
value="starred"> value="starred">
Starred Starred
</mat-list-option> </mat-list-option>
<mat-list-option checkboxPosition="before" value="sent-mail"> <mat-list-option checkboxPosition="before" value="sent-mail">
Sent Mail Sent Mail
</mat-list-option> </mat-list-option>
<mat-list-option checkboxPosition="before" value="drafts" *ngIf="showLastOpt ion"> <mat-list-option checkboxPosition="before" value="drafts" *ngIf="showLastOpt ion">
Drafts Drafts
</mat-list-option> </mat-list-option>
</mat-selection-list>`}) </mat-selection-list>`})
class SelectionListWithListOptions { class SelectionListWithListOptions {
showLastOption: boolean = true; showLastOption: boolean = true;
listRippleDisabled = false;
onValueChange(_change: MatSelectionListChange) {} onValueChange(_change: MatSelectionListChange) {}
} }
@Component({template: ` @Component({template: `
<mat-selection-list id="selection-list-2"> <mat-selection-list id="selection-list-2">
<mat-list-option checkboxPosition="after"> <mat-list-option checkboxPosition="after">
Inbox (disabled selection-option) Inbox (disabled selection-option)
</mat-list-option> </mat-list-option>
<mat-list-option id="testSelect" checkboxPosition="after"> <mat-list-option id="testSelect" checkboxPosition="after">
 End of changes. 5 change blocks. 
3 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)