Skip to content

Commit

Permalink
refactor: move testing utilities to cdk
Browse files Browse the repository at this point in the history
* Deletes the duplicate testing utilities because angular#5386 just copied them to the CDK but didn't delete the old files.
* Introduces a secondary entry point (only inside of development right now) that allows us to use the testing utilities from the Material package tests
  • Loading branch information
devversion committed Jul 1, 2017
1 parent b00f838 commit e2c924c
Show file tree
Hide file tree
Showing 36 changed files with 60 additions and 170 deletions.
9 changes: 9 additions & 0 deletions src/cdk/keyboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export * from './keycodes';
2 changes: 1 addition & 1 deletion src/cdk/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export * from './platform/index';
export * from './portal/index';
export * from './rxjs/index';
export * from './observe-content/index';
export * from './keyboard/keycodes';
export * from './keyboard/index';
12 changes: 12 additions & 0 deletions src/cdk/testing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export * from './dispatch-events';
export * from './event-objects';
export * from './type-in-element';
export * from './wrapped-error-message';
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions src/cdk/tsconfig-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
"types": ["jasmine"],
"experimentalDecorators": true
},
"files": [
"./index.ts",
"./testing/index.ts"
],
"include": [
"**/*.spec.ts",
"index.ts"
"**/*.spec.ts"
]
}
4 changes: 1 addition & 3 deletions src/lib/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import {MdOption} from '../core/option/option';
import {MdInputContainer} from '../input/input-container';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {createKeyboardEvent} from '../core/testing/event-objects';
import {typeInElement} from '../core/testing/type-in-element';
import {createKeyboardEvent, dispatchFakeEvent, typeInElement} from '@angular/cdk/testing';
import {ScrollDispatcher} from '../core/overlay/scroll/scroll-dispatcher';
import {RxChain, map, startWith, filter} from '../core/rxjs/index';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {By} from '@angular/platform-browser';
import {MdCheckbox, MdCheckboxChange, MdCheckboxModule} from './index';
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
import {FakeViewportRuler} from '../core/overlay/position/fake-viewport-ruler';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {dispatchFakeEvent} from '@angular/cdk/testing';
import {RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from '../core/ripple/ripple-renderer';


Expand Down
2 changes: 1 addition & 1 deletion src/lib/chips/chip-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {By} from '@angular/platform-browser';
import {MdChip, MdChipList, MdChipsModule} from './index';
import {FocusKeyManager} from '../core/a11y/focus-key-manager';
import {SPACE, LEFT_ARROW, RIGHT_ARROW, TAB} from '../core/keyboard/keycodes';
import {createKeyboardEvent} from '../core/testing/event-objects';
import {createKeyboardEvent} from '@angular/cdk/testing';


describe('MdChipList', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/compatibility/compatibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
MD_ELEMENTS_SELECTOR,
getMdCompatibilityInvalidPrefixError,
} from './compatibility';
import {wrappedErrorMessage} from '../testing/wrapped-error-message';
import {wrappedErrorMessage} from '@angular/cdk/testing';


describe('Style compatibility', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/overlay/overlay-directives.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {OverlayContainer} from './overlay-container';
import {ConnectedPositionStrategy} from './position/connected-position-strategy';
import {ConnectedOverlayPositionChange} from './position/connected-position';
import {Directionality} from '../bidi/index';
import {dispatchKeyboardEvent} from '../testing/dispatch-events';
import {dispatchKeyboardEvent} from '@angular/cdk/testing';
import {ESCAPE} from '../keyboard/keycodes';


Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/overlay/scroll/scroll-dispatcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {inject, TestBed, async, fakeAsync, ComponentFixture, tick} from '@angular/core/testing';
import {NgModule, Component, ViewChild, ElementRef} from '@angular/core';
import {OverlayModule, Scrollable, ScrollDispatcher} from '../index';
import {dispatchFakeEvent} from '../../testing/dispatch-events';
import {dispatchFakeEvent} from '@angular/cdk/testing';

describe('Scroll Dispatcher', () => {

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/ripple/ripple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {TestBed, ComponentFixture, fakeAsync, tick, inject} from '@angular/core/
import {Component, ViewChild} from '@angular/core';
import {ViewportRuler} from '../overlay/position/viewport-ruler';
import {RIPPLE_FADE_OUT_DURATION, RIPPLE_FADE_IN_DURATION} from './ripple-renderer';
import {dispatchMouseEvent} from '../testing/dispatch-events';
import {dispatchMouseEvent} from '@angular/cdk/testing';
import {
MdRipple, MdRippleModule, MD_RIPPLE_GLOBAL_OPTIONS, RippleState, RippleGlobalOptions
} from './index';
Expand Down
4 changes: 1 addition & 3 deletions src/lib/core/style/focus-origin-monitor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {StyleModule} from './index';
import {By} from '@angular/platform-browser';
import {TAB} from '../keyboard/keycodes';
import {FocusOrigin, FocusOriginMonitor, TOUCH_BUFFER_MS} from './focus-origin-monitor';
import {
dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent
} from '../testing/dispatch-events';
import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing';


describe('FocusOriginMonitor', () => {
Expand Down
30 changes: 0 additions & 30 deletions src/lib/core/testing/dispatch-events.ts

This file was deleted.

62 changes: 0 additions & 62 deletions src/lib/core/testing/event-objects.ts

This file was deleted.

30 changes: 0 additions & 30 deletions src/lib/core/testing/jasmine-matchers.ts

This file was deleted.

6 changes: 1 addition & 5 deletions src/lib/datepicker/calendar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import {By} from '@angular/platform-browser';
import {MdMonthView} from './month-view';
import {MdYearView} from './year-view';
import {MdCalendarBody} from './calendar-body';
import {
dispatchFakeEvent,
dispatchKeyboardEvent,
dispatchMouseEvent
} from '../core/testing/dispatch-events';
import {dispatchFakeEvent, dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing';
import {
DOWN_ARROW,
END,
Expand Down
6 changes: 1 addition & 5 deletions src/lib/datepicker/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import {MdDatepickerInput} from './datepicker-input';
import {MdInputModule} from '../input/index';
import {MdNativeDateModule, DateAdapter, NativeDateAdapter} from '../core/datetime/index';
import {ESCAPE} from '../core';
import {
dispatchFakeEvent,
dispatchMouseEvent,
dispatchKeyboardEvent,
} from '../core/testing/dispatch-events';
import {dispatchFakeEvent, dispatchMouseEvent, dispatchKeyboardEvent} from '@angular/cdk/testing';


// When constructing a Date, the month is zero-based. This can be confusing, since people are
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {MdDialog, MD_DIALOG_DATA} from './dialog';
import {MdDialogContainer} from './dialog-container';
import {OverlayContainer, ESCAPE} from '../core';
import {MdDialogRef} from './dialog-ref';
import {dispatchKeyboardEvent} from '../core/testing/dispatch-events';
import {dispatchKeyboardEvent} from '@angular/cdk/testing';


describe('MdDialog', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/icon/icon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Component} from '@angular/core';
import {MdIconModule} from './index';
import {MdIconRegistry, getMdIconNoHttpProviderError} from './icon-registry';
import {getFakeSvgHttpResponse} from './fake-svgs';
import {wrappedErrorMessage} from '../core/testing/wrapped-error-message';
import {wrappedErrorMessage} from '@angular/cdk/testing';


/** Returns the CSS classes assigned to an element as a sorted array. */
Expand Down
3 changes: 1 addition & 2 deletions src/lib/input/input-container.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {MdInputModule} from './index';
import {MdInputContainer, MdInputDirective} from './input-container';
import {Platform} from '../core/platform/platform';
import {PlatformModule} from '../core/platform/index';
import {wrappedErrorMessage} from '../core/testing/wrapped-error-message';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {wrappedErrorMessage, dispatchFakeEvent} from '@angular/cdk/testing';
import {
getMdInputContainerDuplicatedHintError,
getMdInputContainerMissingMdInputError,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/menu/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {OverlayContainer} from '../core/overlay/overlay-container';
import {Directionality, Direction} from '../core/bidi/index';
import {extendObject} from '../core/util/object-extend';
import {ESCAPE} from '../core/keyboard/keycodes';
import {dispatchKeyboardEvent} from '../core/testing/dispatch-events';
import {dispatchKeyboardEvent} from '@angular/cdk/testing';


describe('MdMenu', () => {
Expand Down
5 changes: 1 addition & 4 deletions src/lib/paginator/paginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import {MdPaginator, PageEvent} from './paginator';
import {Component, ElementRef, ViewChild} from '@angular/core';
import {MdPaginatorIntl} from './paginator-intl';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {customMatchers} from '../core/testing/jasmine-matchers';
import {dispatchMouseEvent} from '../core/testing/dispatch-events';
import {dispatchMouseEvent} from '@angular/cdk/testing';


describe('MdPaginator', () => {
Expand All @@ -14,8 +13,6 @@ describe('MdPaginator', () => {
let paginator: MdPaginator;

beforeEach(async(() => {
jasmine.addMatchers(customMatchers);

TestBed.configureTestingModule({
imports: [
MdPaginatorModule,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/radio/radio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {By} from '@angular/platform-browser';
import {MdRadioGroup, MdRadioButton, MdRadioChange, MdRadioModule} from './index';
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
import {FakeViewportRuler} from '../core/overlay/position/fake-viewport-ruler';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {dispatchFakeEvent} from '@angular/cdk/testing';
import {RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from '../core/ripple/ripple-renderer';


Expand Down
3 changes: 1 addition & 2 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import {
} from '@angular/forms';
import {Subject} from 'rxjs/Subject';
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
import {dispatchFakeEvent, dispatchKeyboardEvent} from '../core/testing/dispatch-events';
import {wrappedErrorMessage} from '../core/testing/wrapped-error-message';
import {dispatchFakeEvent, dispatchKeyboardEvent, wrappedErrorMessage} from '@angular/cdk/testing';
import {ScrollDispatcher} from '../core/overlay/scroll/scroll-dispatcher';
import {
FloatPlaceholderType,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/slide-toggle/slide-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {async, ComponentFixture, TestBed, fakeAsync, tick} from '@angular/core/t
import {NgModel, FormsModule, ReactiveFormsModule, FormControl} from '@angular/forms';
import {MdSlideToggle, MdSlideToggleChange, MdSlideToggleModule} from './index';
import {TestGestureConfig} from '../slider/test-gesture-config';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {dispatchFakeEvent} from '@angular/cdk/testing';
import {RIPPLE_FADE_IN_DURATION, RIPPLE_FADE_OUT_DURATION} from '../core/ripple/ripple-renderer';

describe('MdSlideToggle', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/slider/slider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
RIGHT_ARROW,
UP_ARROW
} from '../core/keyboard/keycodes';
import {dispatchKeyboardEvent, dispatchMouseEvent} from '../core/testing/dispatch-events';
import {dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing';


describe('MdSlider', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sort/sort.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {Component, ElementRef, ViewChild} from '@angular/core';
import {MdSort, MdSortHeader, Sort, SortDirection, MdSortModule} from './index';
import {CdkTableModule, DataSource, CollectionViewer} from '@angular/cdk';
import {Observable} from 'rxjs/Observable';
import {dispatchMouseEvent} from '../core/testing/dispatch-events';
import {dispatchMouseEvent} from '@angular/cdk/testing';
import {
getMdSortDuplicateMdSortableIdError,
getMdSortHeaderMissingIdError,
getMdSortHeaderNotContainedWithinMdSortError
} from './sort-errors';
import {wrappedErrorMessage} from '../core/testing/wrapped-error-message';
import {wrappedErrorMessage} from '@angular/cdk/testing';
import {map} from '../core/rxjs/index';

describe('MdSort', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/tabs/tab-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Observable} from 'rxjs/Observable';
import {MdTab} from './tab';
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
import {FakeViewportRuler} from '../core/overlay/position/fake-viewport-ruler';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {dispatchFakeEvent} from '@angular/cdk/testing';


describe('MdTabGroup', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/tabs/tab-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {MdTabLabelWrapper} from './tab-label-wrapper';
import {RIGHT_ARROW, LEFT_ARROW, ENTER} from '../core/keyboard/keycodes';
import {FakeViewportRuler} from '../core/overlay/position/fake-viewport-ruler';
import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
import {dispatchKeyboardEvent} from '../core/testing/dispatch-events';
import {dispatchFakeEvent} from '../core/testing/dispatch-events';
import {dispatchFakeEvent, dispatchKeyboardEvent} from '@angular/cdk/testing';
import {Subject} from 'rxjs/Subject';
import {By} from '@angular/platform-browser';

Expand Down
Loading

0 comments on commit e2c924c

Please sign in to comment.