Skip to content

Implement TestComponentBuilder #1812

Closed

Description

@tbosch

Implement requirements of #1146

@Component({
  selector: 'md-calendar-input'
})
@View({
  template: '<input [value]="dateAsString" type="text"><calendar-popup (select)="updateDate($event)">#</calendar-popup>',
  directives: [
    CalendarPopup
  ]
})
class MdCalendarInput {
  dateAsString:string;

  updateDate(newValue:Date) {
    this.dateAsString = newValue.toString();
  }
}

@Component({
  selector: 'calendar-popup'
})
@View({
  template: `
  <div style="overflow-y:scroll">
    <md-calendar-month *for="month in visibleMonths"></md-calendar-month>
  </div>
`
})
class CalendarPopup {

}

describe('calendar input', () => {

  it('should update the input value when the popup selects a value', inject([TestComponentBuilder, AsyncCompleter], (tcb, async) => {
    tcb
      .override(MdCalendarInput, component: {}, view: {directives:[bind(CalendarPopUp).toClass(SpyCalendarPopUp)], excludeDirectives:[]})
      .override(CalendarPopup, view: {template: 'mock view'})
      .override(TestEnvComp, view: { directives: [MdCalendarInput], template: `...` }, component: {services:[]})
      .create(TestEnvComp)
  }));

});

class TestComponentBuilder {
  constructor(parentInjector:Injector) {}
  override(type:Type, {view:ViewOverride, component:ComponentOverride, directive:DirectiveOveride}):TestComponentBuilder;
  createAsync(type:Type, {}:View):ComponentProxy;
  // later with special zones that allow micro leap:
  // create(type:Type, {}:View):ComponentProxy;
}

class ComponentProxy {
  componentInstance
  detectChanges
  hostElement
  triggerEvent
  // monitors when PUSH components call check() and checkOnce()
  changeDetectorSpy
}

...Overrides:
- contains excludes, includes
- need merge process

Activity

  1. self-assigned this
    on May 11, 2015
  2. jelbourn commented on May 11, 2015

    @jelbourn
    Contributor

    Related: #1609 and #1610

  3. tbosch commented on May 12, 2015

    @tbosch
    ContributorAuthor

    @matanlurey Do you have time to discuss this?

  4. vicb commented on May 12, 2015

    @vicb
    Contributor

    later with special zones that allow micro leap

    This should hopefuly be available this week, see #1837

  5. tbosch commented on May 12, 2015

    @tbosch
    ContributorAuthor

    Talked to @matanlurey: Also add a feature to the ComponentProxy to allow to query for a nested component.

  6. assigned and unassigned on May 18, 2015
  7. modified the milestones: M8: GT Customer (non-blocking), on May 18, 2015
  8. modified the milestones: , on May 20, 2015
  9. juliemr commented on May 22, 2015

    @juliemr
    Contributor

    Summary of differences from the existing test_bed

    • Should be ready to be made public (i.e. no exposing internal view)
    • Should provide an API to select child components, something like Angular Dart 1.x's element probe
    • Will allow chaining so partially created test components can be shared between tests

    This will eventually deprecate test_bed.

    Am I missing anything?

  10. 2 remaining items

  11. added 8 commits that reference this issue on May 27, 2015
    10004e9
    655587e
    51b4c3c
    f0b484f
    d68a5e0
    e822126
    14a557a
    c32dbad
  12. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  13. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions