Skip to content

Commit

Permalink
Adds test to demonstrate issue with connected-overlay positions attr
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Dhillon committed Aug 10, 2016
1 parent 1bec551 commit eedd965
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/core/overlay/overlay-directives.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import {
import {Component, ViewChild} from '@angular/core';
import {ConnectedOverlayDirective, OverlayModule} from './overlay-directives';
import {OverlayContainer} from './overlay-container';
import {ConnectionPositionPair} from './position/connected-position';
import {ConnectedPositionStrategy} from './position/connected-position-strategy';


describe('Overlay directives', () => {
let builder: TestComponentBuilder;
let overlayContainerElement: HTMLElement;
let fixture: ComponentFixture<ConnectedOverlayDirectiveTest>;
let fixtureWithPositions: ComponentFixture<ConnectedOverlayDirectiveWithPositionsTest>;

beforeEach(async(() => {
TestBed.configureTestingModule({
Expand Down Expand Up @@ -67,6 +69,28 @@ describe('Overlay directives', () => {
let positions = strategy.positions;
expect(positions.length).toBeGreaterThan(0);
});

describe('with given position', () => {
beforeEach(async(() => {
builder.createAsync(ConnectedOverlayDirectiveWithPositionsTest).then(f => {
fixtureWithPositions = f;
fixtureWithPositions.detectChanges();
});
}));

it('should use a connected position strategy with a given set of positions', () => {
let testComponent: ConnectedOverlayDirectiveWithPositionsTest =
fixtureWithPositions.debugElement.componentInstance;
let overlayDirective = testComponent.connectedOverlayDirective;

let strategy =
<ConnectedPositionStrategy> overlayDirective.overlayRef.getState().positionStrategy;
expect(strategy) .toEqual(jasmine.any(ConnectedPositionStrategy));

let positions = strategy.positions;
expect(positions).toBe(testComponent.positions);
});
})
});


Expand All @@ -80,3 +104,20 @@ describe('Overlay directives', () => {
class ConnectedOverlayDirectiveTest {
@ViewChild(ConnectedOverlayDirective) connectedOverlayDirective: ConnectedOverlayDirective;
}


@Component({
template: `
<button overlay-origin #trigger="overlayOrigin">Toggle menu</button>
<template connected-overlay [origin]="trigger" [positions]="positions">
<p>Menu content</p>
</template>`,
})
class ConnectedOverlayDirectiveWithPositionsTest {
@ViewChild(ConnectedOverlayDirective) connectedOverlayDirective: ConnectedOverlayDirective;
positions: ConnectionPositionPair[] = [
new ConnectionPositionPair(
{originX: 'start', originY: 'bottom'},
{overlayX: 'end', overlayY: 'bottom'})
];
}

0 comments on commit eedd965

Please sign in to comment.