From 02a7c2730fe60c6a134aaafd0f39f44c73350518 Mon Sep 17 00:00:00 2001 From: Kordrad Date: Wed, 10 Jul 2024 12:41:26 +0200 Subject: [PATCH] test(disabled.directive): fix tests --- jest.config.ts | 4 +++ .../files/disabled/disabled.directive.spec.ts | 30 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 4a27584..13fb0a8 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -12,6 +12,10 @@ export default { coverageProvider: 'v8', moduleNameMapper: { '^@ng-zen/cli/(.*)': '/projects/cli/src/$1', + '^ng-zen/components/(.*)': + '/projects/cli/schematics/components/files/$1', + '^ng-zen/directives/(.*)': + '/projects/cli/schematics/directives/files/$1', }, preset: 'jest-preset-angular', testEnvironment: 'jsdom', diff --git a/projects/cli/schematics/directives/files/disabled/disabled.directive.spec.ts b/projects/cli/schematics/directives/files/disabled/disabled.directive.spec.ts index def02b1..c3b2719 100644 --- a/projects/cli/schematics/directives/files/disabled/disabled.directive.spec.ts +++ b/projects/cli/schematics/directives/files/disabled/disabled.directive.spec.ts @@ -1,8 +1,34 @@ +import { Component } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; + import { ZenDisabledDirective } from './disabled.directive'; +import { ZenHostDirective } from './index'; + +@Component({ + template: ``, + hostDirectives: [ZenHostDirective], + standalone: true, +}) +class ZenDisabledComponent {} describe('ZenDisabledDirective', () => { - it('should create an instance', () => { - const directive = new ZenDisabledDirective(); + let component: ZenDisabledComponent; + let directive: ZenDisabledDirective; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ZenDisabledComponent], + }).compileComponents(); + + const fixture: ComponentFixture = + TestBed.createComponent(ZenDisabledComponent); + component = fixture.componentInstance; + directive = fixture.debugElement.injector.get(ZenDisabledDirective); + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); expect(directive).toBeTruthy(); }); });