"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib/chips/chip.spec.ts" between
material2-7.3.6.tar.gz and material2-7.3.7.tar.gz

About: material2 offers Material Design components for Angular.

chip.spec.ts  (material2-7.3.6):chip.spec.ts  (material2-7.3.7)
import {Directionality} from '@angular/cdk/bidi'; import {Directionality} from '@angular/cdk/bidi';
import {BACKSPACE, DELETE, SPACE} from '@angular/cdk/keycodes'; import {BACKSPACE, DELETE, SPACE} from '@angular/cdk/keycodes';
import {createKeyboardEvent, dispatchFakeEvent} from '@angular/cdk/testing'; import {createKeyboardEvent, dispatchFakeEvent} from '@angular/cdk/testing';
import {Component, DebugElement} from '@angular/core'; import {Component, DebugElement, ViewChild} from '@angular/core';
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions} from '@angular/material/ core'; import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions} from '@angular/material/ core';
import {By} from '@angular/platform-browser'; import {By} from '@angular/platform-browser';
import {Subject} from 'rxjs'; import {Subject} from 'rxjs';
import {MatChip, MatChipEvent, MatChipSelectionChange, MatChipsModule} from './i ndex'; import {MatChip, MatChipEvent, MatChipSelectionChange, MatChipsModule, MatChipLi st} from './index';
describe('Chips', () => { describe('Chips', () => {
let fixture: ComponentFixture<any>; let fixture: ComponentFixture<any>;
let chipDebugElement: DebugElement; let chipDebugElement: DebugElement;
let chipNativeElement: HTMLElement; let chipNativeElement: HTMLElement;
let chipInstance: MatChip; let chipInstance: MatChip;
let globalRippleOptions: RippleGlobalOptions; let globalRippleOptions: RippleGlobalOptions;
let dir = 'ltr'; let dir = 'ltr';
skipping to change at line 259 skipping to change at line 259
// Use the spacebar to deselect the chip // Use the spacebar to deselect the chip
chipInstance._handleKeydown(SPACE_EVENT); chipInstance._handleKeydown(SPACE_EVENT);
fixture.detectChanges(); fixture.detectChanges();
expect(chipInstance.selected).toBeFalsy(); expect(chipInstance.selected).toBeFalsy();
expect(testComponent.chipSelectionChange).toHaveBeenCalledTimes(2); expect(testComponent.chipSelectionChange).toHaveBeenCalledTimes(2);
expect(testComponent.chipSelectionChange).toHaveBeenCalledWith(CHIP_DE SELECTED_EVENT); expect(testComponent.chipSelectionChange).toHaveBeenCalledWith(CHIP_DE SELECTED_EVENT);
}); });
it('should have correct aria-selected', () => { it('should have correct aria-selected in single selection mode', () => {
expect(chipNativeElement.hasAttribute('aria-selected')).toBe(false);
testComponent.selected = true;
fixture.detectChanges();
expect(chipNativeElement.getAttribute('aria-selected')).toBe('true');
});
it('should have the correct aria-selected in multi-selection mode', () =
> {
testComponent.chipList.multiple = true;
fixture.detectChanges();
expect(chipNativeElement.getAttribute('aria-selected')).toBe('false'); expect(chipNativeElement.getAttribute('aria-selected')).toBe('false');
testComponent.selected = true; testComponent.selected = true;
fixture.detectChanges(); fixture.detectChanges();
expect(chipNativeElement.getAttribute('aria-selected')).toBe('true'); expect(chipNativeElement.getAttribute('aria-selected')).toBe('true');
}); });
}); });
describe('when selectable is false', () => { describe('when selectable is false', () => {
beforeEach(() => { beforeEach(() => {
testComponent.selectable = false; testComponent.selectable = false;
fixture.detectChanges(); fixture.detectChanges();
}); });
it('SPACE ignores selection', () => { it('SPACE ignores selection', () => {
const SPACE_EVENT: KeyboardEvent = createKeyboardEvent('keydown', SPAC E) as KeyboardEvent; const SPACE_EVENT: KeyboardEvent = createKeyboardEvent('keydown', SPAC E) as KeyboardEvent;
skipping to change at line 392 skipping to change at line 405
[color]="color" [selected]="selected" [disabled]="disabled" [color]="color" [selected]="selected" [disabled]="disabled"
(focus)="chipFocus($event)" (destroyed)="chipDestroy($event)" (focus)="chipFocus($event)" (destroyed)="chipDestroy($event)"
(selectionChange)="chipSelectionChange($event)" (selectionChange)="chipSelectionChange($event)"
(removed)="chipRemove($event)"> (removed)="chipRemove($event)">
{{name}} {{name}}
</mat-chip> </mat-chip>
</div> </div>
</mat-chip-list>` </mat-chip-list>`
}) })
class SingleChip { class SingleChip {
@ViewChild(MatChipList) chipList: MatChipList;
disabled: boolean = false; disabled: boolean = false;
name: string = 'Test'; name: string = 'Test';
color: string = 'primary'; color: string = 'primary';
selected: boolean = false; selected: boolean = false;
selectable: boolean = true; selectable: boolean = true;
removable: boolean = true; removable: boolean = true;
shouldShow: boolean = true; shouldShow: boolean = true;
chipFocus: (event?: MatChipEvent) => void = () => {}; chipFocus: (event?: MatChipEvent) => void = () => {};
chipDestroy: (event?: MatChipEvent) => void = () => {}; chipDestroy: (event?: MatChipEvent) => void = () => {};
 End of changes. 5 change blocks. 
3 lines changed or deleted 18 lines changed or added

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