Skip to content

Instantly share code, notes, and snippets.

@ShaneRich5
Created April 30, 2020 18:27
Show Gist options
  • Save ShaneRich5/f313b63f98af1e1b3c0cf83f9393f706 to your computer and use it in GitHub Desktop.
Save ShaneRich5/f313b63f98af1e1b3c0cf83f9393f706 to your computer and use it in GitHub Desktop.
angular test
import { fakeAsync, tick } from '@angular/core/testing';
describe('brainstorming test', () => {
test('ngOnInit() should initiate autocomplete and its dataset', fakeAsync(() => {
// const mockedTemplateOptions = jest.fn() as any as FormlyTemplateOptions;
// component.to = mockedTemplateOptions;
// const mockedTemplateOptions = jest.spyOn(component.to, 'search').mockReturnValue('a');
component.ngOnInit();
component.searchDelay = 0;
component.dataset.subscribe(
(val: string) => {
expect(val).toBe('aaa');
// expect(mockedSearch).toBeCalled();
}
)
component.searchTerm.next('a')
component.searchTerm.next('a')
component.searchTerm.next('a')
tick();
expect(component.isLoading).toBe(false);
})
);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment