-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: π setInput should run host dc
β Closes: #539
- Loading branch information
1 parent
3d7500a
commit c40a2a6
Showing
3 changed files
with
1,420 additions
and
1,439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
import { of } from 'rxjs'; | ||
import { createHostFactory, SpectatorHost } from '@ngneat/spectator'; | ||
import { Component, Input } from '@angular/core'; | ||
import { createComponentFactory, Spectator } from '@ngneat/spectator'; | ||
|
||
import { QueryService } from '../query.service'; | ||
@Component({ | ||
selector: 'app-foo', | ||
template: '', | ||
host: { | ||
'[class.bar]': 'bar', | ||
}, | ||
}) | ||
class FooComponent { | ||
@Input() bar!: boolean; | ||
} | ||
|
||
import { AsyncComponent } from './async.component'; | ||
|
||
describe('ZippyComponent', () => { | ||
let host: SpectatorHost<AsyncComponent>; | ||
|
||
const createHost = createHostFactory({ | ||
component: AsyncComponent, | ||
mocks: [QueryService] | ||
describe('FooComponenent', () => { | ||
const createComponent = createComponentFactory({ | ||
component: FooComponent, | ||
}); | ||
|
||
it('should work', () => { | ||
const { component } = createHost(`<app-async></app-async>`); | ||
expect(component).toBeDefined(); | ||
}); | ||
let spectator: Spectator<FooComponent>; | ||
|
||
it('should be falsy', () => { | ||
host = createHost(`<app-async></app-async>`); | ||
expect(host.query('p')).not.toExist(); | ||
beforeEach(() => { | ||
spectator = createComponent(); | ||
}); | ||
|
||
it('should be truthy', () => { | ||
host = createHost(`<app-async></app-async>`, { detectChanges: false }); | ||
const queryService = host.inject(QueryService); | ||
queryService.select.and.returnValue(of(true)); | ||
host.detectChanges(); | ||
expect(host.query('p')).toExist(); | ||
it('should set the class name "bar"', () => { | ||
spectator.setInput({ bar: true }); | ||
|
||
expect(spectator.element).toHaveClass('bar'); | ||
}); | ||
}); |
Oops, something went wrong.