testing_1.fakeAsync(function () {
     el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     invalidMsg = fixture.debugElement.query(browser_1.By.css('#invalid-msg'));
     fixture.detectChanges();
     testing_1.tick();
     testing_2.expect(el.nativeElement.className).toContain('ng-untouched');
     testing_2.expect(el.nativeElement.className).toContain('ng-pristine');
     testing_2.expect(invalidMsg.nativeElement.hidden).toBe(true);
     controller.model.isChecked = true;
     fixture.detectChanges();
     testing_1.tick();
     fixture.detectChanges();
     testing_2.expect(el.nativeElement.className).toContain('md-checkbox-checked');
     testing_2.expect(el.nativeElement.className).toContain('ng-dirty');
     testing_2.expect(el.nativeElement.className).toContain('ng-valid');
     var blur;
     if (BROWSER_SUPPORTS_EVENT_CONSTRUCTORS) {
         blur = new Event('blur');
     }
     else {
         blur = document.createEvent('UIEvent');
         blur.initUIEvent('blur', true, true, window, 0);
     }
     el.nativeElement.dispatchEvent(blur);
     fixture.detectChanges();
     testing_1.tick();
     testing_2.expect(el.nativeElement.className).toContain('ng-touched');
 })();
 return tcb.createAsync(demo_form_with_validations_shorthand_1.DemoFormWithValidationsShorthand).then(function (fixture) {
     el = fixture.debugElement.nativeElement;
     input = fixture.debugElement.query(browser_1.By.css("input")).nativeElement;
     form = fixture.debugElement.query(browser_1.By.css("form")).nativeElement;
     fixture.detectChanges();
     return fixture;
 });
 builder.createAsync(CheckboxMultiController).then(function (fixture) {
     fixture.detectChanges();
     var first = fixture.debugElement.query(browser_1.By.css('.md-checkbox:first-of-type'));
     var second = fixture.debugElement.query(browser_1.By.css('.md-checkbox:nth-of-type(2)'));
     testing_2.expect(first.nativeElement.id).toMatch(/^md\-checkbox\-\d$/g);
     testing_2.expect(second.nativeElement.id).toMatch(/^md\-checkbox\-\d$/g);
     testing_2.expect(first.nativeElement.id).not.toEqual(second.nativeElement.id);
 }).then(done).catch(done);
 builder.createAsync(CheckboxCustomTabindexController).then(function (f) {
     fixture = f;
     var tabindexController = fixture.componentInstance;
     tabindexController.isDisabled = true;
     fixture.detectChanges();
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.getAttribute('tabindex')).toEqual('-1');
     tabindexController.isDisabled = false;
     fixture.detectChanges();
     el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.getAttribute('tabindex')).toEqual(String(tabindexController.checkboxTabindex));
 }).then(done).catch(done);
 testing_2.it('applies a transition class when going from indeterminate -> checked', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     controller.isIndeterminate = true;
     fixture.detectChanges();
     controller.isChecked = true;
     fixture.detectChanges();
     testing_2.expect(el.nativeElement.className).not.toContain('md-checkbox-anim-unchecked-indeterminate');
     testing_2.expect(el.nativeElement.className).toContain('md-checkbox-anim-indeterminate-checked');
 });
 testing_2.it('does not apply any transition classes when there is nothing to transition', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     controller.isChecked = controller.isChecked;
     fixture.detectChanges();
     testing_2.expect(el.nativeElement.className).not.toMatch(/^md\-checkbox\-anim/g);
     controller.isIndeterminate = controller.isIndeterminate;
     fixture.detectChanges();
     testing_2.expect(el.nativeElement.className).not.toMatch(/^md\-checkbox\-anim/g);
 });
 testing_1.it('should correctly update the announce text', fakeAsyncTest(function () {
     var appFixture = null;
     builder.createAsync(TestApp).then(function (fixture) {
         appFixture = fixture;
     });
     testing_1.flushMicrotasks();
     var buttonElement = appFixture.debugElement
         .query(browser_1.By.css('button')).nativeElement;
     buttonElement.click();
     // This flushes our 100ms timeout for the screenreaders.
     testing_1.tick(100);
     testing_1.expect(liveEl.textContent).toBe('Test');
 }));
Пример #8
0
import { By } from 'angular2/platform/browser';
import { Scope } from 'angular2/core';
var debugElement;
class MyDirective {
}
// #docregion by_all
debugElement.query(By.all(), Scope.all);
// #enddocregion
// #docregion by_css
debugElement.query(By.css('[attribute]'), Scope.all);
// #enddocregion
// #docregion by_directive
debugElement.query(By.directive(MyDirective), Scope.all);
// #enddocregion
 builder.createAsync(CheckboxController).then(function (fixture) {
     fixture.detectChanges();
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.tabIndex).toEqual(0);
 }).then(done).catch(done);
 builder.createAsync(CheckboxController).then(function (fixture) {
     fixture.detectChanges();
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.getAttribute('aria-disabled')).toEqual('false');
 }).then(done).catch(done);
 builder.createAsync(CheckboxController).then(function (fixture) {
     fixture.detectChanges();
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     var label = el.nativeElement.querySelector('label');
     testing_2.expect(label.innerHTML.trim()).toEqual('<em>my</em> checkbox');
 }).then(done).catch(done);
 builder.createAsync(CheckboxCustomIdController).then(function (fixture) {
     fixture.detectChanges();
     var component = fixture.componentInstance;
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.id).toEqual(component.checkboxId);
 }).then(done).catch(done);
 testing_2.it('does not apply any transition classes when the component is initialized', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.className).not.toMatch(/^md\-checkbox\-anim/g);
 });
 testing_2.it('removes md-checkbox-indeterminate', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.className).not.toContain('md-checkbox-indeterminate');
 });
 testing_2.it('adds a "md-checkbox-disabled" class to the host element', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.className).toContain('md-checkbox-disabled');
 });
 testing_2.it('sets "aria-disabled" to "true" on the host element', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.getAttribute('aria-disabled')).toEqual('true');
 });
 builder.createAsync(CheckboxController).then(function (f) {
     fixture = f;
     controller = fixture.componentInstance;
     fixture.detectChanges();
     el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
 }).then(done).catch(done);
 testing_2.it('uses the newly changed tabindex when re-enabled', function () {
     tabindexController.isDisabled = false;
     fixture.detectChanges();
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.getAttribute('tabindex')).toEqual(String(newTabindex));
 });
 testing_2.it('keeps the tabindex at -1', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.getAttribute('tabindex')).toEqual('-1');
 });
Пример #20
0
import { By } from 'angular2/platform/browser';
var debugElement;
class MyDirective {
}
// #docregion by_all
debugElement.query(By.all());
// #enddocregion
// #docregion by_css
debugElement.query(By.css('[attribute]'));
// #enddocregion
// #docregion by_directive
debugElement.query(By.directive(MyDirective));
// #enddocregion
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJhbmd1bGFyMi9leGFtcGxlcy9wbGF0Zm9ybS9kb20vZGVidWcvdHMvYnkvYnkudHMiXSwibmFtZXMiOlsiTXlEaXJlY3RpdmUiXSwibWFwcGluZ3MiOiJPQUFPLEVBQUMsRUFBRSxFQUFDLE1BQU0sMkJBQTJCO0FBRzVDLElBQUksWUFBMEIsQ0FBQztBQUMvQjtBQUFtQkEsQ0FBQ0E7QUFFcEIsb0JBQW9CO0FBQ3BCLFlBQVksQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDLEdBQUcsRUFBRSxDQUFDLENBQUM7QUFDN0IsZ0JBQWdCO0FBRWhCLG9CQUFvQjtBQUNwQixZQUFZLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxHQUFHLENBQUMsYUFBYSxDQUFDLENBQUMsQ0FBQztBQUMxQyxnQkFBZ0I7QUFFaEIsMEJBQTBCO0FBQzFCLFlBQVksQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDLFNBQVMsQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO0FBQzlDLGdCQUFnQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7Qnl9IGZyb20gJ2FuZ3VsYXIyL3BsYXRmb3JtL2Jyb3dzZXInO1xuaW1wb3J0IHtEZWJ1Z0VsZW1lbnR9IGZyb20gJ2FuZ3VsYXIyL2NvcmUnO1xuXG52YXIgZGVidWdFbGVtZW50OiBEZWJ1Z0VsZW1lbnQ7XG5jbGFzcyBNeURpcmVjdGl2ZSB7fVxuXG4vLyAjZG9jcmVnaW9uIGJ5X2FsbFxuZGVidWdFbGVtZW50LnF1ZXJ5KEJ5LmFsbCgpKTtcbi8vICNlbmRkb2NyZWdpb25cblxuLy8gI2RvY3JlZ2lvbiBieV9jc3NcbmRlYnVnRWxlbWVudC5xdWVyeShCeS5jc3MoJ1thdHRyaWJ1dGVdJykpO1xuLy8gI2VuZGRvY3JlZ2lvblxuXG4vLyAjZG9jcmVnaW9uIGJ5X2RpcmVjdGl2ZVxuZGVidWdFbGVtZW50LnF1ZXJ5KEJ5LmRpcmVjdGl2ZShNeURpcmVjdGl2ZSkpO1xuLy8gI2VuZGRvY3JlZ2lvblxuIl19
 testing_2.it('sets an "md-checkbox-align-end" class on the host element', function () {
     var el = fixture.debugElement.query(browser_1.By.css('.md-checkbox'));
     testing_2.expect(el.nativeElement.className).toContain('md-checkbox-align-end');
 });