Example #1
0
describe('msm menu component', () => {
    let tcb; //test component builder
    let service;

    beforeEachProviders(() => [
        TestComponentBuilder,
        msmMenu,
        msmService, //,
        RouteRegistry,
        provide(Location, {useClass: SpyLocation}),
        provide(ROUTER_PRIMARY_COMPONENT, {useValue: myStuffManager}),
        provide(Router, {useClass: RootRouter})
    ]);

    beforeEach(inject([TestComponentBuilder, msmService], (_tcb, _service) => {
        tcb = _tcb;
        service = _service;
    }));

    it('it should render the categories menu', () => {
        tcb.createAsync(msmMenu).then(fixture => {
            let _msmMenu = fixture.componentInstance,
                element = fixture.nativeElement;
            _msmMenu.categories = service.getCategories();
            fixture.detectChanges(); //trigger change detection
            expect(element.querySelectorAll('li', '.content-list').length).toBe(3);
        });
    });
});
describe('ToggleTodoBtnComponent test', () => {
  let tcb;

  beforeEachProviders(() => [
    TestComponentBuilder,
    TodoInputComponent,
  ]);

  beforeEach(inject([TestComponentBuilder], _tcb => {
    tcb = _tcb;
  }));

  it('should emit onToggle event', (done) => {
    tcb.createAsync(TodoInputComponent).then(fixture => {
      const component = fixture.componentInstance;
      const test = { expectCalled() { } };
      const spy = spyOn(test, 'expectCalled');

      component.onAddTodo.subscribe(() => test.expectCalled());

      component.addTodo('Test');
      expect(test.expectCalled).toHaveBeenCalled();

      spy.calls.reset();

      component.addTodo('');
      expect(test.expectCalled).not.toHaveBeenCalled();

      done();
    }).catch(e => done.fail(e));
  });
});
describe('AddCardBtnComponent test', () => {
  let tcb;

  beforeEachProviders(() => [
    TestComponentBuilder,
    AddCardBtnComponent,
  ]);

  beforeEach(inject([TestComponentBuilder], _tcb => {
    tcb = _tcb;
  }));

  it('emit onAddRow event', (done) => {
    tcb.createAsync(AddCardBtnComponent).then(fixture => {
      const component = fixture.componentInstance;
      const element = fixture.nativeElement;
      const test = {
        expectCalled() { },
      };

      spyOn(test, 'expectCalled');
      component.onAddCard.subscribe(() => test.expectCalled());

      element.querySelector('.add-card').click();

      expect(test.expectCalled).toHaveBeenCalled();

      done();
    }).catch(e => done.fail(e));
  });
});
Example #4
0
File: spec.js Project: mswift42/lr2
describe('AboutMe Component', () => {

    beforeEachProviders(()=> [AboutMe]);
    it('should create the app',
       inject([AboutMe], (app: AboutMe) => {
           expect(app).toBeTruthy();
       }));
});
testing_1.describe('MyCreateAccount Component', function () {
    testing_1.beforeEachProviders(function () { return []; });
    testing_1.it('should ...', testing_1.injectAsync([testing_2.TestComponentBuilder], function (tcb) {
        return tcb.createAsync(my_create_account_component_1.MyCreateAccountComponent).then(function (fixture) {
            fixture.detectChanges();
        });
    }));
});
testing_1.describe('App', function () {
    testing_1.beforeEachProviders(function () { return [
        app_component_1.AppComponent
    ]; });
    testing_1.it('should work', testing_1.inject([app_component_1.AppComponent], function (app) {
        // Add real test here
        testing_1.expect(2).toBe(2);
    }));
});
describe('App', () => {
    beforeEachProviders(() => [
        AppComponent
    ]);
    it ('should work', inject([AppComponent], (app: AppComponent) => {
        // Add real test here
        expect(2).toBe(2);
    }));
});
describe('App', function () {
    // provide our implementations or mocks to the dependency injector
    testing_1.beforeEachProviders(function () { return [
        app_service_1.AppState,
        app_component_1.App
    ]; });
    testing_1.it('should have a url', testing_1.inject([app_component_1.App], function (app) {
        expect(app.url).toEqual('https://twitter.com/datatype_void');
    }));
});
describe('Hello', () => {
  beforeEachProviders(() => [Greeter]);

  it('renders greeting', async(inject([TestComponentBuilder], (tcb) => {
    tcb.createAsync(Hello)
      .then((fixture) => {
        fixture.detectChanges();
        var expectation = fixture.debugElement.nativeElement.textContent.trim();
        expect(expectation).toHaveText('Hello, Angular2!');
      });
  })));
});
Example #10
0
testing_1.describe('About', function () {
    beforeAll(function () {
        spyOn(ng_react_1.NGReact, 'initialize');
    });
    // provide our implementations or mocks to the dependency injector
    testing_1.beforeEachProviders(function () { return [
        index_async_1.About
    ]; });
    testing_1.it('should log ngOnInit', testing_1.inject([index_async_1.About], function (about) {
        about.ngOnInit();
        expect(ng_react_1.NGReact.initialize).toHaveBeenCalled();
    }));
});
 testing_1.describe('MarkerManager', function () {
     testing_1.beforeEachProviders(function () { return [
         core_1.provide(core_1.NgZone, { useFactory: function () { return new core_1.NgZone({ enableLongStackTrace: true }); } }),
         marker_manager_1.MarkerManager,
         bing_map_marker_1.BingMapMarker,
         core_1.provide(bing_maps_api_wrapper_1.BingMapsAPIWrapper, { useValue: jasmine.createSpyObj('BingMapsAPIWrapper', ['createMarker']) })
     ]; });
     testing_1.describe('Create a new marker', function () {
         testing_1.it('should call the mapsApiWrapper when creating a new marker', testing_1.inject([marker_manager_1.MarkerManager, bing_maps_api_wrapper_1.BingMapsAPIWrapper], function (markerManager, apiWrapper) {
             var newMarker = new bing_map_marker_1.BingMapMarker(markerManager);
             newMarker.latitude = 34.4;
             newMarker.longitude = 22.3;
             newMarker.label = 'A';
             markerManager.addMarker(newMarker);
             testing_1.expect(apiWrapper.createMarker)
                 .toHaveBeenCalledWith({ position: { lat: 34.4, lng: 22.3 }, label: 'A', draggable: false, icon: undefined });
         }));
     });
     testing_1.describe('Delete a marker', function () {
         testing_1.it('should set the map to null when deleting a existing marker', testing_1.inject([marker_manager_1.MarkerManager, bing_maps_api_wrapper_1.BingMapsAPIWrapper], function (markerManager, apiWrapper) {
             var newMarker = new bing_map_marker_1.BingMapMarker(markerManager);
             newMarker.latitude = 34.4;
             newMarker.longitude = 22.3;
             newMarker.label = 'A';
             var markerInstance = jasmine.createSpyObj('Marker', ['setMap']);
             apiWrapper.createMarker.and.returnValue(Promise.resolve(markerInstance));
             markerManager.addMarker(newMarker);
             markerManager.deleteMarker(newMarker)
                 .then(function () { testing_1.expect(markerInstance.setMap).toHaveBeenCalledWith(null); });
         }));
     });
     testing_1.describe('set marker icon', function () {
         testing_1.it('should update that marker via setIcon method when the markerUrl changes', testing_1.async(testing_1.inject([marker_manager_1.MarkerManager, bing_maps_api_wrapper_1.BingMapsAPIWrapper], function (markerManager, apiWrapper) {
             var newMarker = new bing_map_marker_1.BingMapMarker(markerManager);
             newMarker.latitude = 34.4;
             newMarker.longitude = 22.3;
             newMarker.label = 'A';
             var markerInstance = jasmine.createSpyObj('Marker', ['setMap', 'setIcon']);
             apiWrapper.createMarker.and.returnValue(Promise.resolve(markerInstance));
             markerManager.addMarker(newMarker);
             testing_1.expect(apiWrapper.createMarker)
                 .toHaveBeenCalledWith({ position: { lat: 34.4, lng: 22.3 }, label: 'A', draggable: false, icon: undefined });
             var iconUrl = 'http://angular-maps.com/icon.png';
             newMarker.iconUrl = iconUrl;
             return markerManager.updateIcon(newMarker).then(function () {
                 testing_1.expect(markerInstance.setIcon).toHaveBeenCalledWith(iconUrl);
             });
         })));
     });
 });
testing_1.describe('Component: Navbar', function () {
    var builder;
    testing_1.beforeEachProviders(function () { return [navbar_component_1.NavbarComponent]; });
    testing_1.beforeEach(testing_1.inject([testing_2.TestComponentBuilder], function (tcb) { builder = tcb; }));
    testing_1.it('should inject the component', testing_1.inject([navbar_component_1.NavbarComponent], function (component) {
        testing_1.expect(component).toBeTruthy();
    }));
    testing_1.it('should create the component', testing_1.inject([], function () {
        return builder.createAsync(NavbarComponentTestController)
            .then(function (fixture) {
            var query = fixture.debugElement.query(platform_browser_1.By.directive(navbar_component_1.NavbarComponent));
            testing_1.expect(query).toBeTruthy();
            testing_1.expect(query.componentInstance).toBeTruthy();
        });
    }));
});
describe('OrganisationFormComponent', () => {
	// setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
	beforeEachProviders(() => [APP_REDUCERS_PROVIDER]);

	it('should render data in form', injectAsync([TestComponentBuilder], (tcb) => {
		return tcb.createAsync(OrganisationFormComponent).then((componentFixture) => {
			const element = componentFixture.nativeElement;
			componentFixture.componentInstance.data = fullOrg;
			componentFixture.componentInstance.users = [];
			componentFixture.detectChanges();
			expect(element.querySelector('[ngcontrol="name"]').value).toBe('Nulla');
			expect(element.querySelector('[ngcontrol="address"]').value).toBe('this address');
			expect(element.querySelector('[ngcontrol="description"]').value).toBe('this description');
		});
	}));

});
testing_1.describe('Component: ViewSingle', function () {
    var builder;
    testing_1.beforeEachProviders(function () { return [view_single_component_1.ViewSingleComponent]; });
    testing_1.beforeEach(testing_1.inject([testing_2.TestComponentBuilder], function (tcb) {
        builder = tcb;
    }));
    testing_1.it('should inject the component', testing_1.inject([view_single_component_1.ViewSingleComponent], function (component) {
        testing_1.expect(component).toBeTruthy();
    }));
    // it('should have ', inject([ViewSingleComponent],
    //     (component: ViewSingleComponent) => {
    //   expect(component).toBeTruthy();
    // }));
    testing_1.beforeEach(function () {
        this.vsc = new view_single_component_1.ViewSingleComponent();
    });
    testing_1.it('should have hello property', function () {
        testing_1.expect(this.vsc.id).toBe('router');
    });
    testing_1.it('should create the component', testing_1.inject([], function () {
        return builder.createAsync(ViewSingleComponentTestController)
            .then(function (fixture) {
            var query = fixture.debugElement.query(platform_browser_1.By.directive(view_single_component_1.ViewSingleComponent));
            testing_1.expect(query).toBeTruthy();
            testing_1.expect(query.componentInstance).toBeTruthy();
        });
    }));
    // it('should render', inject([], () => {
    //   return builder.createAsync(ViewSingleComponentTestController)
    //     .then((fixture: ComponentFixture<any>) => {
    //       let query = fixture.debugElement.query(By.directive(ViewSingleComponent));
    //       expect(query).toBeTruthy();
    //       expect(query.componentInstance).toBeTruthy();
    //     });
    // }));
    //
    //
    // it('should render list', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
    //   return tcb.createAsync(ViewSingleComponent).then((componentFixture: ComponentFixture) => {
    //     const element = componentFixture.nativeElement;
    //     componentFixture.componentInstance.users = ['John'];
    //     componentFixture.detectChanges();
    //     expect(element.querySelectorAll('span').length).toBe(1);
    //   });
    // }));
});
describe( 'App', () => {

  // variables
  let app;

  beforeEachProviders( () => {
    // init a new instance of the underlying class
    app = new AppComponent();
  } );

  // the lame duck
  it( `true is true`, () => {
    expect( true ).toBe( true );
  } );

  // do some actual testing
  it( `should be constructed`, () => {
    expect( app ).not.toBe( undefined );
  } );

} );
testing_1.describe('Overlay directives', function () {
    var builder;
    var overlayContainerElement;
    var fixture;
    testing_1.beforeEachProviders(function () { return [
        overlay_1.Overlay,
        overlay_position_builder_1.OverlayPositionBuilder,
        viewport_ruler_1.ViewportRuler,
        core_1.provide(overlay_1.OVERLAY_CONTAINER_TOKEN, { useFactory: function () {
                overlayContainerElement = document.createElement('div');
                return overlayContainerElement;
            } })
    ]; });
    testing_1.beforeEach(testing_1.inject([testing_2.TestComponentBuilder], function (tcb) {
        builder = tcb;
    }));
    testing_1.beforeEach(testing_1.async(function () {
        builder.createAsync(ConnectedOverlayDirectiveTest).then(function (f) {
            fixture = f;
            fixture.detectChanges();
        });
    }));
    testing_1.it("should create an overlay and attach the directive's template", function () {
        testing_1.expect(overlayContainerElement.textContent).toContain('Menu content');
    });
    testing_1.it('should destroy the overlay when the directive is destroyed', testing_1.fakeAsync(function () {
        fixture.destroy();
        testing_1.flushMicrotasks();
        testing_1.expect(overlayContainerElement.textContent.trim()).toBe('');
    }));
    testing_1.it('should use a connected position strategy with a default set of positions', function () {
        var testComponent = fixture.debugElement.componentInstance;
        var overlayDirective = testComponent.connectedOverlayDirective;
        var strategy = overlayDirective.overlayRef.getState().positionStrategy;
        testing_1.expect(strategy).toEqual(jasmine.any(connected_position_strategy_1.ConnectedPositionStrategy));
        var positions = strategy.positions;
        testing_1.expect(positions.length).toBeGreaterThan(0);
    });
});
testing_1.describe('Component: Dashboard', function () {
    var builder;
    var MockRouter = (function () {
        function MockRouter() {
        }
        MockRouter.prototype.navigate = function () { };
        return MockRouter;
    }());
    testing_1.beforeEachProviders(function () { return [dashboard_component_1.DashboardComponent, shared_1.ProductService, core_1.provide(router_1.Router, { useClass: MockRouter })]; });
    testing_1.beforeEach(testing_1.inject([testing_2.TestComponentBuilder], function (tcb) {
        builder = tcb;
    }));
    testing_1.it('should inject the component', testing_1.inject([dashboard_component_1.DashboardComponent], function (component) {
        testing_1.expect(component).toBeTruthy();
    }));
    testing_1.it('should create the component', testing_1.inject([], function () {
        return builder.createAsync(DashboardComponentTestController)
            .then(function (fixture) {
            var query = fixture.debugElement.query(platform_browser_1.By.directive(dashboard_component_1.DashboardComponent));
            testing_1.expect(query).toBeTruthy();
            testing_1.expect(query.componentInstance).toBeTruthy();
        });
    }));
});
Example #18
0
testing_1.describe('todo_component', function () {
    testing_1.beforeEachProviders(function () { return [core_1.provide(todo_service_1.TodoService, { useClass: MockTodoService })]; });
    testing_1.describe('creation', function () {
        testing_1.it('should create the component correctly', testing_1.async(testing_1.inject([testing_1.TestComponentBuilder], function (tcb) {
            return tcb.createAsync(todo_cmp_1.TodoCmp).then(function (fixture) {
                fixture.detectChanges();
                var compiled = fixture.debugElement.nativeElement;
                testing_1.expect(compiled).toBeDefined();
            });
        })));
        testing_1.it('should inicialize the cmp correctly', testing_1.async(testing_1.inject([testing_1.TestComponentBuilder], function (tcb) {
            return tcb.createAsync(todo_cmp_1.TodoCmp).then(function (fixture) {
                var instance = fixture.debugElement.componentInstance;
                spyOn(instance, '_getAll').and.callFake(function () { });
                fixture.detectChanges();
                testing_1.expect(instance._getAll).toHaveBeenCalled();
            });
        })));
        testing_1.it('should call add correctly', testing_1.async(testing_1.inject([testing_1.TestComponentBuilder], function (tcb) {
            return tcb.createAsync(todo_cmp_1.TodoCmp).then(function (fixture) {
                fixture.detectChanges();
                var instance = fixture.debugElement.componentInstance;
                var _todoMsg = 'yo';
                instance.add(_todoMsg);
            });
        })));
        testing_1.it('should call remove correctly', testing_1.async(testing_1.inject([testing_1.TestComponentBuilder], function (tcb) {
            return tcb.createAsync(todo_cmp_1.TodoCmp).then(function (fixture) {
                fixture.detectChanges();
                var instance = fixture.debugElement.componentInstance;
                var _id = 'abc123';
                instance.remove(_id);
            });
        })));
    });
});
Example #19
0
describe('Title', function () {
    testing_1.beforeEachProviders(function () { return [
        http_1.BaseRequestOptions,
        testing_2.MockBackend,
        {
            provide: http_1.Http,
            useFactory: function (backend, defaultOptions) {
                return new http_1.Http(backend, defaultOptions);
            },
            deps: [testing_2.MockBackend, http_1.BaseRequestOptions]
        },
        title_service_1.Title
    ]; });
    testing_1.it('should have http', testing_1.inject([title_service_1.Title], function (title) {
        expect(!!title.http).toEqual(true);
    }));
    testing_1.it('should get data from the server', testing_1.inject([title_service_1.Title], function (title) {
        spyOn(console, 'log');
        expect(console.log).not.toHaveBeenCalled();
        title.getData();
        expect(console.log).toHaveBeenCalled();
        expect(title.getData()).toEqual({ value: 'AngularClass' });
    }));
});
testing_1.describe('MyEvents Service', function () {
    testing_1.beforeEachProviders(function () { return [my_events_service_1.MyEventsService]; });
    testing_1.it('should ...', testing_1.inject([my_events_service_1.MyEventsService], function (service) {
    }));
});
testing_1.describe('MdIcon', function () {
    testing_1.beforeEachProviders(function () { return [
        icon_registry_1.MdIconRegistry,
        http_1.HTTP_PROVIDERS,
        testing_3.MockBackend,
        core_1.provide(http_1.XHRBackend, { useExisting: testing_3.MockBackend }),
    ]; });
    var builder;
    var mdIconRegistry;
    var httpRequestUrls;
    testing_1.beforeEach(testing_1.inject([testing_2.TestComponentBuilder, icon_registry_1.MdIconRegistry, testing_3.MockBackend], function (tcb, mir, mockBackend) {
        builder = tcb;
        mdIconRegistry = mir;
        // Keep track of requests so we can verify caching behavior.
        // Return responses for the SVGs defined in fake-svgs.ts.
        httpRequestUrls = [];
        mockBackend.connections.subscribe(function (connection) {
            var url = connection.request.url;
            httpRequestUrls.push(url);
            connection.mockRespond(fake_svgs_1.getFakeSvgHttpResponse(url));
        });
    }));
    testing_1.describe('Ligature icons', function () {
        testing_1.it('should add material-icons class by default', function (done) {
            return builder.createAsync(MdIconLigatureTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                testComponent.iconName = 'home';
                fixture.detectChanges();
                testing_1.expect(sortedClassNames(mdIconElement)).toEqual(['material-icons']);
                done();
            });
        });
        testing_1.it('should use alternate icon font if set', function (done) {
            mdIconRegistry.setDefaultFontSetClass('myfont');
            return builder.createAsync(MdIconLigatureTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                testComponent.iconName = 'home';
                fixture.detectChanges();
                testing_1.expect(sortedClassNames(mdIconElement)).toEqual(['myfont']);
                done();
            });
        });
    });
    testing_1.describe('Icons from URLs', function () {
        testing_1.it('should fetch SVG icon from URL and inline the content', function (done) {
            return builder.createAsync(MdIconFromSvgUrlTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                var svgElement;
                testComponent.iconUrl = 'cat.svg';
                fixture.detectChanges();
                // An <svg> element should have been added as a child of <md-icon>.
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                // Default attributes should be set.
                testing_1.expect(svgElement.getAttribute('height')).toBe('100%');
                testing_1.expect(svgElement.getAttribute('height')).toBe('100%');
                // Make sure SVG content is taken from response.
                verifyPathChildElement(svgElement, 'meow');
                // Change the icon, and the SVG element should be replaced.
                testComponent.iconUrl = 'dog.svg';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'woof');
                testing_1.expect(httpRequestUrls).toEqual(['cat.svg', 'dog.svg']);
                // Using an icon from a previously loaded URL should not cause another HTTP request.
                testComponent.iconUrl = 'cat.svg';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'meow');
                testing_1.expect(httpRequestUrls).toEqual(['cat.svg', 'dog.svg']);
                done();
            });
        });
        testing_1.it('should register icon URLs by name', function (done) {
            mdIconRegistry.addSvgIcon('fluffy', 'cat.svg');
            mdIconRegistry.addSvgIcon('fido', 'dog.svg');
            return builder.createAsync(MdIconFromSvgNameTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                var svgElement;
                testComponent.iconName = 'fido';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'woof');
                // The aria label should be taken from the icon name.
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('fido');
                // Change the icon, and the SVG element should be replaced.
                testComponent.iconName = 'fluffy';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'meow');
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('fluffy');
                testing_1.expect(httpRequestUrls).toEqual(['dog.svg', 'cat.svg']);
                // Using an icon from a previously loaded URL should not cause another HTTP request.
                testComponent.iconName = 'fido';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'woof');
                testing_1.expect(httpRequestUrls).toEqual(['dog.svg', 'cat.svg']);
                done();
            });
        });
        testing_1.it('should extract icon from SVG icon set', function (done) {
            mdIconRegistry.addSvgIconSetInNamespace('farm', 'farm-set-1.svg');
            return builder.createAsync(MdIconFromSvgNameTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                var svgElement;
                var svgChild;
                testComponent.iconName = 'farm:pig';
                fixture.detectChanges();
                testing_1.expect(mdIconElement.childNodes.length).toBe(1);
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                testing_1.expect(svgElement.childNodes.length).toBe(1);
                svgChild = svgElement.childNodes[0];
                // The first <svg> child should be the <g id="pig"> element.
                testing_1.expect(svgChild.tagName.toLowerCase()).toBe('g');
                testing_1.expect(svgChild.getAttribute('id')).toBe('pig');
                verifyPathChildElement(svgChild, 'oink');
                // The aria label should be taken from the icon name (without the icon set portion).
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('pig');
                // Change the icon, and the SVG element should be replaced.
                testComponent.iconName = 'farm:cow';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                svgChild = svgElement.childNodes[0];
                // The first <svg> child should be the <g id="cow"> element.
                testing_1.expect(svgChild.tagName.toLowerCase()).toBe('g');
                testing_1.expect(svgChild.getAttribute('id')).toBe('cow');
                verifyPathChildElement(svgChild, 'moo');
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('cow');
                done();
            });
        });
        testing_1.it('should allow multiple icon sets in a namespace', function (done) {
            mdIconRegistry.addSvgIconSetInNamespace('farm', 'farm-set-1.svg');
            mdIconRegistry.addSvgIconSetInNamespace('farm', 'farm-set-2.svg');
            mdIconRegistry.addSvgIconSetInNamespace('arrows', 'arrow-set.svg');
            return builder.createAsync(MdIconFromSvgNameTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                var svgElement;
                var svgChild;
                testComponent.iconName = 'farm:pig';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                testing_1.expect(svgElement.childNodes.length).toBe(1);
                svgChild = svgElement.childNodes[0];
                // The <svg> child should be the <g id="pig"> element.
                testing_1.expect(svgChild.tagName.toLowerCase()).toBe('g');
                testing_1.expect(svgChild.getAttribute('id')).toBe('pig');
                testing_1.expect(svgChild.childNodes.length).toBe(1);
                verifyPathChildElement(svgChild, 'oink');
                // The aria label should be taken from the icon name (without the namespace).
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('pig');
                // Both icon sets registered in the 'farm' namespace should have been fetched.
                testing_1.expect(httpRequestUrls.sort()).toEqual(['farm-set-1.svg', 'farm-set-2.svg']);
                // Change the icon name to one that appears in both icon sets. The icon from the set that
                // was registered last should be used (with id attribute of 'moo moo' instead of 'moo'),
                // and no additional HTTP request should be made.
                testComponent.iconName = 'farm:cow';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                svgChild = svgElement.childNodes[0];
                // The first <svg> child should be the <g id="cow"> element.
                testing_1.expect(svgChild.tagName.toLowerCase()).toBe('g');
                testing_1.expect(svgChild.getAttribute('id')).toBe('cow');
                testing_1.expect(svgChild.childNodes.length).toBe(1);
                verifyPathChildElement(svgChild, 'moo moo');
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('cow');
                testing_1.expect(httpRequestUrls.sort()).toEqual(['farm-set-1.svg', 'farm-set-2.svg']);
                done();
            });
        });
        testing_1.it('should not wrap <svg> elements in icon sets in another svg tag', function (done) {
            mdIconRegistry.addSvgIconSet('arrow-set.svg');
            return builder.createAsync(MdIconFromSvgNameTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                var svgElement;
                testComponent.iconName = 'left-arrow';
                fixture.detectChanges();
                // arrow-set.svg stores its icons as nested <svg> elements, so they should be used
                // directly and not wrapped in an outer <svg> tag like the <g> elements in other sets.
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'left');
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('left-arrow');
                done();
            });
        });
        testing_1.it('should return unmodified copies of icons from URLs', function (done) {
            return builder.createAsync(MdIconFromSvgUrlTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                var svgElement;
                testComponent.iconUrl = 'cat.svg';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'meow');
                // Modify the SVG element by setting a viewBox attribute.
                svgElement.setAttribute('viewBox', '0 0 100 100');
                // Switch to a different icon.
                testComponent.iconUrl = 'dog.svg';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'woof');
                // Switch back to the first icon. The viewBox attribute should not be present.
                testComponent.iconUrl = 'cat.svg';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'meow');
                testing_1.expect(svgElement.getAttribute('viewBox')).toBeFalsy();
                done();
            });
        });
        testing_1.it('should return unmodified copies of icons from icon sets', function (done) {
            mdIconRegistry.addSvgIconSet('arrow-set.svg');
            return builder.createAsync(MdIconFromSvgNameTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                var svgElement;
                testComponent.iconName = 'left-arrow';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'left');
                // Modify the SVG element by setting a viewBox attribute.
                svgElement.setAttribute('viewBox', '0 0 100 100');
                // Switch to a different icon.
                testComponent.iconName = 'right-arrow';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'right');
                // Switch back to the first icon. The viewBox attribute should not be present.
                testComponent.iconName = 'left-arrow';
                fixture.detectChanges();
                svgElement = verifyAndGetSingleSvgChild(mdIconElement);
                verifyPathChildElement(svgElement, 'left');
                testing_1.expect(svgElement.getAttribute('viewBox')).toBeFalsy();
                done();
            });
        });
    });
    testing_1.describe('custom fonts', function () {
        testing_1.it('should apply CSS classes for custom font and icon', function (done) {
            mdIconRegistry.registerFontClassAlias('f1', 'font1');
            mdIconRegistry.registerFontClassAlias('f2');
            return builder.createAsync(MdIconCustomFontCssTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                testComponent.fontSet = 'f1';
                testComponent.fontIcon = 'house';
                fixture.detectChanges();
                testing_1.expect(sortedClassNames(mdIconElement)).toEqual(['font1', 'house']);
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('house');
                testComponent.fontSet = 'f2';
                testComponent.fontIcon = 'igloo';
                fixture.detectChanges();
                testing_1.expect(sortedClassNames(mdIconElement)).toEqual(['f2', 'igloo']);
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('igloo');
                testComponent.fontSet = 'f3';
                testComponent.fontIcon = 'tent';
                fixture.detectChanges();
                testing_1.expect(sortedClassNames(mdIconElement)).toEqual(['f3', 'tent']);
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('tent');
                done();
            });
        });
    });
    testing_1.describe('aria label', function () {
        testing_1.it('should set aria label from text content if not specified', function (done) {
            return builder.createAsync(MdIconLigatureTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                testComponent.iconName = 'home';
                fixture.detectChanges();
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('home');
                testComponent.iconName = 'hand';
                fixture.detectChanges();
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('hand');
                done();
            });
        });
        testing_1.it('should use alt tag if aria label is not specified', function (done) {
            return builder.createAsync(MdIconLigatureWithAriaBindingTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                testComponent.iconName = 'home';
                testComponent.altText = 'castle';
                fixture.detectChanges();
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('castle');
                testComponent.ariaLabel = 'house';
                fixture.detectChanges();
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('house');
                done();
            });
        });
        testing_1.it('should use provided aria label rather than icon name', function (done) {
            return builder.createAsync(MdIconLigatureWithAriaBindingTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                testComponent.iconName = 'home';
                testComponent.ariaLabel = 'house';
                fixture.detectChanges();
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('house');
                done();
            });
        });
        testing_1.it('should use provided aria label rather than font icon', function (done) {
            return builder.createAsync(MdIconCustomFontCssTestApp).then(function (fixture) {
                var testComponent = fixture.debugElement.componentInstance;
                var mdIconElement = fixture.debugElement.nativeElement.querySelector('md-icon');
                testComponent.fontSet = 'f1';
                testComponent.fontIcon = 'house';
                testComponent.ariaLabel = 'home';
                fixture.detectChanges();
                testing_1.expect(mdIconElement.getAttribute('aria-label')).toBe('home');
                done();
            });
        });
    });
});
testing_1.describe('Cycconcept Service', function () {
    testing_1.beforeEachProviders(function () { return [cycconcept_service_1.CycconceptService]; });
    testing_1.it('should ...', testing_1.inject([cycconcept_service_1.CycconceptService], function (service) {
        testing_1.expect(service).toBeTruthy();
    }));
});
Example #23
0
testing_1.describe('myComponent', function () {
    testing_1.beforeEachProviders([]);
    testing_1.describe('creation', function () {
    });
});
/* tslint:disable:no-unused-variable */
"use strict";
var testing_1 = require('@angular/core/testing');
var app_component_1 = require('./app.component');
testing_1.beforeEachProviders(function () { return [app_component_1.AppComponent]; });
testing_1.describe('App: MyDreamApp', function () {
    testing_1.it('should create the app', testing_1.inject([app_component_1.AppComponent], function (app) {
        testing_1.expect(app).toBeTruthy();
    }));
    testing_1.it('should have as title \'app works!\'', testing_1.inject([app_component_1.AppComponent], function (app) {
        testing_1.expect(app.title).toEqual('app works!');
    }));
});
//# sourceMappingURL=app.component.spec.js.map
Example #25
0
testing_1.describe('myFactory', function () {
    testing_1.beforeEachProviders([]);
    testing_1.describe('creation', function () {
    });
});
Example #26
0
/* tslint:disable:no-unused-variable */
"use strict";
var testing_1 = require('@angular/core/testing');
var home_component_1 = require('./home.component');
testing_1.beforeEachProviders(function () { return [home_component_1.HomeComponent]; });
testing_1.describe('Home Component : ', function () {
    testing_1.it('should create the app', testing_1.inject([home_component_1.HomeComponent], function (app) {
        testing_1.expect(app).toBeTruthy();
    }));
    testing_1.it('should say \'We Start Here\'', testing_1.inject([home_component_1.HomeComponent], function (app) {
        testing_1.expect(app.message.name).toBeTruthy('');
    }));
});

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9jb21wb25lbnRzL2hvbWUvaG9tZS5jb21wb25lbnQuc3BlYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSx1Q0FBdUM7O0FBRXZDLHdCQUFxRyx1QkFBdUIsQ0FBQyxDQUFBO0FBQzdILCtCQUE4QixrQkFBa0IsQ0FBQyxDQUFBO0FBRWpELDZCQUFtQixDQUFDLGNBQU0sT0FBQSxDQUFFLDhCQUFhLENBQUUsRUFBakIsQ0FBaUIsQ0FBQyxDQUFDO0FBRTdDLGtCQUFRLENBQUMsbUJBQW1CLEVBQUU7SUFDNUIsWUFBRSxDQUFDLHVCQUF1QixFQUN4QixnQkFBTSxDQUFDLENBQUUsOEJBQWEsQ0FBRSxFQUFFLFVBQUUsR0FBa0I7UUFDNUMsZ0JBQU0sQ0FBRSxHQUFHLENBQUUsQ0FBQyxVQUFVLEVBQUUsQ0FBQztJQUM3QixDQUFDLENBQUMsQ0FDSCxDQUFDO0lBQ0YsWUFBRSxDQUFDLDhCQUE4QixFQUMvQixnQkFBTSxDQUFDLENBQUUsOEJBQWEsQ0FBRSxFQUFFLFVBQUUsR0FBa0I7UUFDNUMsZ0JBQU0sQ0FBRSxHQUFHLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBRSxDQUFDLFVBQVUsQ0FBRSxFQUFFLENBQUUsQ0FBQztJQUM5QyxDQUFDLENBQUMsQ0FDSCxDQUFDO0FBQ0osQ0FBQyxDQUFDLENBQUMiLCJmaWxlIjoiYXBwL2NvbXBvbmVudHMvaG9tZS9ob21lLmNvbXBvbmVudC5zcGVjLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyogdHNsaW50OmRpc2FibGU6bm8tdW51c2VkLXZhcmlhYmxlICovXG5cbmltcG9ydCB7IGJlZm9yZUVhY2gsIGJlZm9yZUVhY2hQcm92aWRlcnMsIGRlc2NyaWJlLCB4ZGVzY3JpYmUsIGV4cGVjdCwgaXQsIHhpdCwgYXN5bmMsIGluamVjdCB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUvdGVzdGluZyc7XG5pbXBvcnQgeyBIb21lQ29tcG9uZW50IH0gZnJvbSAnLi9ob21lLmNvbXBvbmVudCc7XG5cbmJlZm9yZUVhY2hQcm92aWRlcnMoKCkgPT4gWyBIb21lQ29tcG9uZW50IF0pO1xuXG5kZXNjcmliZSgnSG9tZSBDb21wb25lbnQgOiAnLCAoKSA9PiB7XG4gIGl0KCdzaG91bGQgY3JlYXRlIHRoZSBhcHAnLFxuICAgIGluamVjdChbIEhvbWVDb21wb25lbnQgXSwgKCBhcHA6IEhvbWVDb21wb25lbnQgKSA9PiB7XG4gICAgICBleHBlY3QoIGFwcCApLnRvQmVUcnV0aHkoKTtcbiAgICB9KVxuICApO1xuICBpdCgnc2hvdWxkIHNheSBcXCdXZSBTdGFydCBIZXJlXFwnJyxcbiAgICBpbmplY3QoWyBIb21lQ29tcG9uZW50IF0sICggYXBwOiBIb21lQ29tcG9uZW50ICkgPT4ge1xuICAgICAgZXhwZWN0KCBhcHAubWVzc2FnZS5uYW1lICkudG9CZVRydXRoeSggJycgKTtcbiAgICB9KVxuICApO1xufSk7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
"use strict";
var testing_1 = require('@angular/core/testing');
var ng2_boilerplate_router_component_1 = require('../app/ng2-boilerplate-router.component');
testing_1.beforeEachProviders(function () { return [ng2_boilerplate_router_component_1.Ng2BoilerplateRouterAppComponent]; });
testing_1.describe('App: Ng2BoilerplateRouter', function () {
    testing_1.it('should create the app', testing_1.inject([ng2_boilerplate_router_component_1.Ng2BoilerplateRouterAppComponent], function (app) {
        testing_1.expect(app).toBeTruthy();
    }));
    testing_1.it('should have as title \'ng2-boilerplate-router works!\'', testing_1.inject([ng2_boilerplate_router_component_1.Ng2BoilerplateRouterAppComponent], function (app) {
        testing_1.expect(app.title).toEqual('ng2-boilerplate-router works!');
    }));
});
//# sourceMappingURL=ng2-boilerplate-router.component.spec.js.map
Example #28
0
/* tslint:disable:no-unused-variable */
"use strict";
var testing_1 = require('@angular/core/testing');
var app_1 = require('./app');
testing_1.beforeEachProviders(function () { return [app_1.App]; });
testing_1.describe('App: Grouple', function () {
    testing_1.it('should create the app', testing_1.inject([app_1.App], function (app) {
        testing_1.expect(app).toBeTruthy();
    }));
    testing_1.it('should have as title \'Grouple\'', testing_1.inject([app_1.App], function (app) {
        testing_1.expect(app.title).toEqual('Grouple');
    }));
});
//# sourceMappingURL=app.spec.js.map
 testing_1.describe('MdLiveAnnouncer', function () {
     var live;
     var builder;
     var liveEl;
     testing_1.beforeEachProviders(function () { return [live_announcer_1.MdLiveAnnouncer]; });
     testing_1.beforeEach(testing_1.inject([testing_2.TestComponentBuilder, live_announcer_1.MdLiveAnnouncer], function (tcb, _live) {
         builder = tcb;
         live = _live;
         liveEl = getLiveElement();
     }));
     afterEach(function () {
         // In our tests we always remove the current live element, because otherwise we would have
         // multiple live elements due multiple service instantiations.
         liveEl.parentNode.removeChild(liveEl);
     });
     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(platform_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');
     }));
     testing_1.it('should correctly update the politeness attribute', fakeAsyncTest(function () {
         var appFixture = null;
         builder.createAsync(TestApp).then(function (fixture) {
             appFixture = fixture;
         });
         testing_1.flushMicrotasks();
         live.announce('Hey Google', 'assertive');
         // This flushes our 100ms timeout for the screenreaders.
         testing_1.tick(100);
         testing_1.expect(liveEl.textContent).toBe('Hey Google');
         testing_1.expect(liveEl.getAttribute('aria-live')).toBe('assertive');
     }));
     testing_1.it('should apply the aria-live value polite by default', fakeAsyncTest(function () {
         var appFixture = null;
         builder.createAsync(TestApp).then(function (fixture) {
             appFixture = fixture;
         });
         testing_1.flushMicrotasks();
         live.announce('Hey Google');
         // This flushes our 100ms timeout for the screenreaders.
         testing_1.tick(100);
         testing_1.expect(liveEl.textContent).toBe('Hey Google');
         testing_1.expect(liveEl.getAttribute('aria-live')).toBe('polite');
     }));
     testing_1.it('should allow to use a custom live element', fakeAsyncTest(function () {
         var customLiveEl = document.createElement('div');
         // We need to reset our test injector here, because it is already instantiated above.
         testing_1.getTestInjector().reset();
         testing_1.getTestInjector().addProviders([
             core_1.provide(live_announcer_1.LIVE_ANNOUNCER_ELEMENT_TOKEN, { useValue: customLiveEl }),
             live_announcer_1.MdLiveAnnouncer
         ]);
         var injector = testing_1.getTestInjector().createInjector();
         var liveService = injector.get(live_announcer_1.MdLiveAnnouncer);
         liveService.announce('Custom Element');
         // This flushes our 100ms timeout for the screenreaders.
         testing_1.tick(100);
         testing_1.expect(customLiveEl.textContent).toBe('Custom Element');
     }));
 });
Example #30
0
testing_1.describe('MdRadio', function () {
    var builder;
    var dispatcher;
    testing_1.beforeEachProviders(function () { return [
        forms_1.disableDeprecatedForms(),
        forms_1.provideForms(),
        core_1.provide(unique_selection_dispatcher_1.MdUniqueSelectionDispatcher, { useFactory: function () {
                dispatcher = new unique_selection_dispatcher_1.MdUniqueSelectionDispatcher();
                return dispatcher;
            } })
    ]; });
    testing_1.beforeEach(testing_1.inject([testing_2.TestComponentBuilder], function (tcb) {
        builder = tcb;
    }));
    testing_1.describe('inside of a group', function () {
        var fixture;
        var groupDebugElement;
        var groupNativeElement;
        var radioDebugElements;
        var radioNativeElements;
        var groupInstance;
        var radioInstances;
        var testComponent;
        testing_1.beforeEach(testing_1.async(function () {
            builder.createAsync(RadiosInsideRadioGroup).then(function (f) {
                fixture = f;
                fixture.detectChanges();
                testComponent = fixture.debugElement.componentInstance;
                groupDebugElement = fixture.debugElement.query(platform_browser_1.By.directive(radio_1.MdRadioGroup));
                groupNativeElement = groupDebugElement.nativeElement;
                groupInstance = groupDebugElement.injector.get(radio_1.MdRadioGroup);
                radioDebugElements = fixture.debugElement.queryAll(platform_browser_1.By.directive(radio_1.MdRadioButton));
                radioNativeElements = radioDebugElements.map(function (debugEl) { return debugEl.nativeElement; });
                radioInstances = radioDebugElements.map(function (debugEl) { return debugEl.componentInstance; });
            });
        }));
        testing_1.it('should set individual radio names based on the group name', function () {
            expect(groupInstance.name).toBeTruthy();
            for (var _i = 0, radioInstances_1 = radioInstances; _i < radioInstances_1.length; _i++) {
                var radio = radioInstances_1[_i];
                expect(radio.name).toBe(groupInstance.name);
            }
        });
        testing_1.it('should disable click interaction when the group is disabled', function () {
            testComponent.isGroupDisabled = true;
            fixture.detectChanges();
            radioNativeElements[0].click();
            expect(radioInstances[0].checked).toBe(false);
        });
        testing_1.it('should set alignment based on the group alignment', function () {
            testComponent.alignment = 'end';
            fixture.detectChanges();
            for (var _i = 0, radioInstances_2 = radioInstances; _i < radioInstances_2.length; _i++) {
                var radio = radioInstances_2[_i];
                expect(radio.align).toBe('end');
            }
            testComponent.alignment = 'start';
            fixture.detectChanges();
            for (var _a = 0, radioInstances_3 = radioInstances; _a < radioInstances_3.length; _a++) {
                var radio = radioInstances_3[_a];
                expect(radio.align).toBe('start');
            }
        });
        testing_1.it('should disable each individual radio when the group is disabled', function () {
            testComponent.isGroupDisabled = true;
            fixture.detectChanges();
            for (var _i = 0, radioInstances_4 = radioInstances; _i < radioInstances_4.length; _i++) {
                var radio = radioInstances_4[_i];
                expect(radio.disabled).toBe(true);
            }
        });
        testing_1.it('should update the group value when one of the radios changes', function () {
            expect(groupInstance.value).toBeFalsy();
            radioInstances[0].checked = true;
            fixture.detectChanges();
            expect(groupInstance.value).toBe('fire');
            expect(groupInstance.selected).toBe(radioInstances[0]);
        });
        testing_1.it('should update the group and radios when one of the radios is clicked', function () {
            expect(groupInstance.value).toBeFalsy();
            radioNativeElements[0].click();
            fixture.detectChanges();
            expect(groupInstance.value).toBe('fire');
            expect(groupInstance.selected).toBe(radioInstances[0]);
            expect(radioInstances[0].checked).toBe(true);
            expect(radioInstances[1].checked).toBe(false);
            radioNativeElements[1].click();
            fixture.detectChanges();
            expect(groupInstance.value).toBe('water');
            expect(groupInstance.selected).toBe(radioInstances[1]);
            expect(radioInstances[0].checked).toBe(false);
            expect(radioInstances[1].checked).toBe(true);
        });
        testing_1.it('should check a radio upon interaction with the underlying native radio button', function () {
            var nativeRadioInput = radioNativeElements[0].querySelector('input');
            nativeRadioInput.click();
            fixture.detectChanges();
            expect(radioInstances[0].checked).toBe(true);
            expect(groupInstance.value).toBe('fire');
            expect(groupInstance.selected).toBe(radioInstances[0]);
        });
        testing_1.it('should emit a change event from radio buttons', testing_1.fakeAsync(function () {
            expect(radioInstances[0].checked).toBe(false);
            var changeSpy = jasmine.createSpy('radio change listener');
            radioInstances[0].change.subscribe(changeSpy);
            radioInstances[0].checked = true;
            fixture.detectChanges();
            testing_1.tick();
            expect(changeSpy).toHaveBeenCalled();
            radioInstances[0].checked = false;
            fixture.detectChanges();
            testing_1.tick();
            expect(changeSpy).toHaveBeenCalledTimes(2);
        }));
        testing_1.it('should emit a change event from the radio group', testing_1.fakeAsync(function () {
            expect(groupInstance.value).toBeFalsy();
            var changeSpy = jasmine.createSpy('radio-group change listener');
            groupInstance.change.subscribe(changeSpy);
            groupInstance.value = 'fire';
            fixture.detectChanges();
            testing_1.tick();
            expect(changeSpy).toHaveBeenCalled();
            groupInstance.value = 'water';
            fixture.detectChanges();
            testing_1.tick();
            expect(changeSpy).toHaveBeenCalledTimes(2);
        }));
        // TODO(jelbourn): test this in an e2e test with *real* focus, rather than faking
        // a focus / blur event.
        testing_1.it('should focus individual radio buttons', function () {
            var nativeRadioInput = radioNativeElements[0].querySelector('input');
            expect(nativeRadioInput.classList).not.toContain('md-radio-focused');
            dispatchFocusChangeEvent('focus', nativeRadioInput);
            fixture.detectChanges();
            expect(radioNativeElements[0].classList).toContain('md-radio-focused');
            dispatchFocusChangeEvent('blur', nativeRadioInput);
            fixture.detectChanges();
            expect(radioNativeElements[0].classList).not.toContain('md-radio-focused');
        });
        testing_1.it('should update the group and radios when updating the group value', function () {
            expect(groupInstance.value).toBeFalsy();
            testComponent.groupValue = 'fire';
            fixture.detectChanges();
            expect(groupInstance.value).toBe('fire');
            expect(groupInstance.selected).toBe(radioInstances[0]);
            expect(radioInstances[0].checked).toBe(true);
            expect(radioInstances[1].checked).toBe(false);
            testComponent.groupValue = 'water';
            fixture.detectChanges();
            expect(groupInstance.value).toBe('water');
            expect(groupInstance.selected).toBe(radioInstances[1]);
            expect(radioInstances[0].checked).toBe(false);
            expect(radioInstances[1].checked).toBe(true);
        });
        testing_1.it('should deselect all of the checkboxes when the group value is cleared', function () {
            radioInstances[0].checked = true;
            expect(groupInstance.value).toBeTruthy();
            groupInstance.value = null;
            expect(radioInstances.every(function (radio) { return !radio.checked; })).toBe(true);
        });
    });
    testing_1.describe('group with ngModel', function () {
        var fixture;
        var groupDebugElement;
        var groupNativeElement;
        var radioDebugElements;
        var radioNativeElements;
        var groupInstance;
        var radioInstances;
        var testComponent;
        var groupNgControl;
        testing_1.beforeEach(testing_1.async(function () {
            builder.createAsync(RadioGroupWithNgModel).then(function (f) {
                fixture = f;
                fixture.detectChanges();
                testComponent = fixture.debugElement.componentInstance;
                groupDebugElement = fixture.debugElement.query(platform_browser_1.By.directive(radio_1.MdRadioGroup));
                groupNativeElement = groupDebugElement.nativeElement;
                groupInstance = groupDebugElement.injector.get(radio_1.MdRadioGroup);
                groupNgControl = groupDebugElement.injector.get(forms_1.NgControl);
                radioDebugElements = fixture.debugElement.queryAll(platform_browser_1.By.directive(radio_1.MdRadioButton));
                radioNativeElements = radioDebugElements.map(function (debugEl) { return debugEl.nativeElement; });
                radioInstances = radioDebugElements.map(function (debugEl) { return debugEl.componentInstance; });
            });
        }));
        testing_1.it('should set individual radio names based on the group name', function () {
            expect(groupInstance.name).toBeTruthy();
            for (var _i = 0, radioInstances_5 = radioInstances; _i < radioInstances_5.length; _i++) {
                var radio = radioInstances_5[_i];
                expect(radio.name).toBe(groupInstance.name);
            }
            groupInstance.name = 'new name';
            for (var _a = 0, radioInstances_6 = radioInstances; _a < radioInstances_6.length; _a++) {
                var radio = radioInstances_6[_a];
                expect(radio.name).toBe(groupInstance.name);
            }
        });
        testing_1.it('should check the corresponding radio button on group value change', function () {
            expect(groupInstance.value).toBeFalsy();
            for (var _i = 0, radioInstances_7 = radioInstances; _i < radioInstances_7.length; _i++) {
                var radio = radioInstances_7[_i];
                expect(radio.checked).toBeFalsy();
            }
            groupInstance.value = 'vanilla';
            for (var _a = 0, radioInstances_8 = radioInstances; _a < radioInstances_8.length; _a++) {
                var radio = radioInstances_8[_a];
                expect(radio.checked).toBe(groupInstance.value === radio.value);
            }
            expect(groupInstance.selected.value).toBe(groupInstance.value);
        });
        testing_1.it('should have the correct control state initially and after interaction', testing_1.fakeAsync(function () {
            // The control should start off valid, pristine, and untouched.
            expect(groupNgControl.valid).toBe(true);
            expect(groupNgControl.pristine).toBe(true);
            expect(groupNgControl.touched).toBe(false);
            // After changing the value programmatically, the control should become dirty (not pristine),
            // but remain untouched.
            radioInstances[1].checked = true;
            fixture.detectChanges();
            testing_1.tick();
            expect(groupNgControl.valid).toBe(true);
            expect(groupNgControl.pristine).toBe(false);
            expect(groupNgControl.touched).toBe(false);
            // After a user interaction occurs (such as a click), the control should remain dirty and
            // now also be touched.
            radioNativeElements[2].click();
            fixture.detectChanges();
            testing_1.tick();
            expect(groupNgControl.valid).toBe(true);
            expect(groupNgControl.pristine).toBe(false);
            expect(groupNgControl.touched).toBe(true);
        }));
        testing_1.it('should update the ngModel value when selecting a radio button', testing_1.fakeAsync(function () {
            radioInstances[1].checked = true;
            fixture.detectChanges();
            testing_1.tick();
            expect(testComponent.modelValue).toBe('chocolate');
        }));
    });
    testing_1.describe('group with ngModel and change event', function () {
        var fixture;
        var groupDebugElement;
        var groupNativeElement;
        var radioDebugElements;
        var radioNativeElements;
        var groupInstance;
        var radioInstances;
        var testComponent;
        var groupNgControl;
        testing_1.beforeEach(testing_1.async(function () {
            builder.createAsync(RadioGroupWithNgModel).then(function (f) {
                fixture = f;
                testComponent = fixture.componentInstance;
                groupDebugElement = fixture.debugElement.query(platform_browser_1.By.directive(radio_1.MdRadioGroup));
                groupNativeElement = groupDebugElement.nativeElement;
                groupInstance = groupDebugElement.injector.get(radio_1.MdRadioGroup);
                groupNgControl = groupDebugElement.injector.get(forms_1.NgControl);
                radioDebugElements = fixture.debugElement.queryAll(platform_browser_1.By.directive(radio_1.MdRadioButton));
                radioNativeElements = radioDebugElements.map(function (debugEl) { return debugEl.nativeElement; });
                radioInstances = radioDebugElements.map(function (debugEl) { return debugEl.componentInstance; });
                fixture.detectChanges();
            });
        }));
        testing_1.it('should update the model before firing change event', testing_1.fakeAsync(function () {
            expect(testComponent.modelValue).toBeUndefined();
            expect(testComponent.lastEvent).toBeUndefined();
            groupInstance.value = 'chocolate';
            fixture.detectChanges();
            testing_1.tick();
            expect(testComponent.modelValue).toBe('chocolate');
            expect(testComponent.lastEvent.value).toBe('chocolate');
        }));
    });
    testing_1.describe('as standalone', function () {
        var fixture;
        var radioDebugElements;
        var seasonRadioInstances;
        var weatherRadioInstances;
        var fruitRadioInstances;
        var fruitRadioNativeInputs;
        var testComponent;
        testing_1.beforeEach(testing_1.async(function () {
            builder.createAsync(StandaloneRadioButtons).then(function (f) {
                var fruitRadioNativeElements;
                fixture = f;
                fixture.detectChanges();
                testComponent = fixture.debugElement.componentInstance;
                radioDebugElements = fixture.debugElement.queryAll(platform_browser_1.By.directive(radio_1.MdRadioButton));
                seasonRadioInstances = radioDebugElements
                    .filter(function (debugEl) { return debugEl.componentInstance.name == 'season'; })
                    .map(function (debugEl) { return debugEl.componentInstance; });
                weatherRadioInstances = radioDebugElements
                    .filter(function (debugEl) { return debugEl.componentInstance.name == 'weather'; })
                    .map(function (debugEl) { return debugEl.componentInstance; });
                fruitRadioInstances = radioDebugElements
                    .filter(function (debugEl) { return debugEl.componentInstance.name == 'fruit'; })
                    .map(function (debugEl) { return debugEl.componentInstance; });
                fruitRadioNativeElements = radioDebugElements
                    .filter(function (debugEl) { return debugEl.componentInstance.name == 'fruit'; })
                    .map(function (debugEl) { return debugEl.nativeElement; });
                fruitRadioNativeInputs = [];
                for (var _i = 0, fruitRadioNativeElements_1 = fruitRadioNativeElements; _i < fruitRadioNativeElements_1.length; _i++) {
                    var element = fruitRadioNativeElements_1[_i];
                    fruitRadioNativeInputs.push(element.querySelector('input'));
                }
            });
        }));
        testing_1.it('should uniquely select radios by a name', function () {
            seasonRadioInstances[0].checked = true;
            weatherRadioInstances[1].checked = true;
            fixture.detectChanges();
            expect(seasonRadioInstances[0].checked).toBe(true);
            expect(seasonRadioInstances[1].checked).toBe(false);
            expect(seasonRadioInstances[2].checked).toBe(false);
            expect(weatherRadioInstances[0].checked).toBe(false);
            expect(weatherRadioInstances[1].checked).toBe(true);
            expect(weatherRadioInstances[2].checked).toBe(false);
            seasonRadioInstances[1].checked = true;
            fixture.detectChanges();
            expect(seasonRadioInstances[0].checked).toBe(false);
            expect(seasonRadioInstances[1].checked).toBe(true);
            expect(seasonRadioInstances[2].checked).toBe(false);
            expect(weatherRadioInstances[0].checked).toBe(false);
            expect(weatherRadioInstances[1].checked).toBe(true);
            expect(weatherRadioInstances[2].checked).toBe(false);
            weatherRadioInstances[2].checked = true;
            expect(seasonRadioInstances[0].checked).toBe(false);
            expect(seasonRadioInstances[1].checked).toBe(true);
            expect(seasonRadioInstances[2].checked).toBe(false);
            expect(weatherRadioInstances[0].checked).toBe(false);
            expect(weatherRadioInstances[1].checked).toBe(false);
            expect(weatherRadioInstances[2].checked).toBe(true);
        });
        testing_1.it('should add aria-label attribute to the underlying input element if defined', function () {
            expect(fruitRadioNativeInputs[0].getAttribute('aria-label')).toBe('Banana');
        });
        testing_1.it('should not add aria-label attribute if not defined', function () {
            expect(fruitRadioNativeInputs[1].hasAttribute('aria-label')).toBeFalsy();
        });
        testing_1.it('should change aria-label attribute if property is changed at runtime', function () {
            expect(fruitRadioNativeInputs[0].getAttribute('aria-label')).toBe('Banana');
            fruitRadioInstances[0].ariaLabel = 'Pineapple';
            fixture.detectChanges();
            expect(fruitRadioNativeInputs[0].getAttribute('aria-label')).toBe('Pineapple');
        });
        testing_1.it('should add aria-labelledby attribute to the underlying input element if defined', function () {
            expect(fruitRadioNativeInputs[0].getAttribute('aria-labelledby')).toBe('xyz');
        });
        testing_1.it('should not add aria-labelledby attribute if not defined', function () {
            expect(fruitRadioNativeInputs[1].hasAttribute('aria-labelledby')).toBeFalsy();
        });
        testing_1.it('should change aria-labelledby attribute if property is changed at runtime', function () {
            expect(fruitRadioNativeInputs[0].getAttribute('aria-labelledby')).toBe('xyz');
            fruitRadioInstances[0].ariaLabelledby = 'uvw';
            fixture.detectChanges();
            expect(fruitRadioNativeInputs[0].getAttribute('aria-labelledby')).toBe('uvw');
        });
    });
});