import { TemplateRef, ViewContainerRef } from '@angular/core';
import { LocalizationService, } from '../services';
import { LocalisationReadyDirective } from './localisation-ready.directive';
import { DictionariesService } from './../../modules/components/page-filters/services/dictionaries-service';

describe('LocalisationReadyDirective', () => {
    let locale: LocalizationService;
    let dicts: DictionariesService;
    let tempalte: TemplateRef<any>;
    let view: ViewContainerRef;
    let directive: LocalisationReadyDirective;
    beforeEach(() => {
        dicts = {
            ready$: Promise.resolve()
        } as any
        locale = {
            ready$: Promise.resolve()
        } as any;
        tempalte = {} as any;
        view = {
            createEmbeddedView: jasmine.createSpy().withArgs(tempalte).and.callThrough(),
        } as any;
        directive = new LocalisationReadyDirective(dicts, locale, tempalte, view);
    });
    it('should wait for localisation to be ready and the create view', async () => {
        await directive.ngOnInit();
        expect(view.createEmbeddedView).toHaveBeenCalled();
    });
});
