Skip to content

Commit

Permalink
test(disabled.directive): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kordrad committed Jul 10, 2024
1 parent ff02cfd commit 2583074
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
4 changes: 4 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default {
coverageProvider: 'v8',
moduleNameMapper: {
'^@ng-zen/cli/(.*)': '<rootDir>/projects/cli/src/$1',
'^ng-zen/components/(.*)':
'<rootDir>/projects/cli/schematics/components/files/$1',
'^ng-zen/directives/(.*)':
'<rootDir>/projects/cli/schematics/directives/files/$1',
},
preset: 'jest-preset-angular',
testEnvironment: 'jsdom',
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ZenDisabledComponent> =
TestBed.createComponent(ZenDisabledComponent);
component = fixture.componentInstance;
directive = fixture.debugElement.injector.get(ZenDisabledDirective);
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
expect(directive).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import { computed, Directive, HostBinding, model } from '@angular/core';
export class ZenDisabledDirective {
/** Model for the disabled state of the checkbox. */

readonly disabled = model<boolean | 'true' | 'false' | ''>(false, {
disabled = model<boolean | 'true' | 'false' | ''>(false, {
alias: 'zenDisabled',
});

/** @ignore */
readonly disabledBoolean = computed(() =>
disabledBoolean = computed(() =>
[true, 'true', ''].includes(this.disabled())
);

Expand Down

0 comments on commit 2583074

Please sign in to comment.