Skip to content

Commit f772928

Browse files
authored
tests(viewDirective): add check for componentProvider
check extra trigger for $onInit (angular-ui#3735)
1 parent f087d5e commit f772928

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/viewDirectiveSpec.ts

+22
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,28 @@ describe('angular 1.5+ style .component()', function() {
13341334
expect(log).toBe('onInit;');
13351335
});
13361336

1337+
it('should only call $onInit() once with componentProvider', function() {
1338+
$stateProvider.state('route2cmp', {
1339+
componentProvider: () => 'ngComponent',
1340+
resolve: {
1341+
data: function() {
1342+
return 'DATA!';
1343+
},
1344+
},
1345+
});
1346+
1347+
const $state = svcs.$state,
1348+
$httpBackend = svcs.$httpBackend,
1349+
$q = svcs.$q;
1350+
1351+
$httpBackend.expectGET('/comp_tpl.html').respond('-{{ $ctrl.data }}-');
1352+
$state.transitionTo('route2cmp');
1353+
$q.flush();
1354+
$httpBackend.flush();
1355+
1356+
expect(log).toBe('onInit;');
1357+
});
1358+
13371359
it('should supply resolve data to "<", "=", "@" bindings', function() {
13381360
$stateProvider.state('bindingtypes', {
13391361
component: 'bindingTypes',

0 commit comments

Comments
 (0)