-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design): add form label directive (#529)
- Loading branch information
1 parent
70e8fdf
commit a23b9ee
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
libs/design/src/atoms/form/form-label/form-label.directive.spec.ts
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { Component, DebugElement } from '@angular/core'; | ||
import { By } from '@angular/platform-browser'; | ||
import { DaffFormLabelDirective } from './form-label.directive'; | ||
|
||
@Component({ | ||
template: `<div daffFormLabel>Label</div>` | ||
}) | ||
|
||
class WrapperComponent {} | ||
|
||
describe('DaffFormLabelDirective', () => { | ||
let wrapper: WrapperComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
DaffFormLabelDirective, | ||
WrapperComponent | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css('[daffFormLabel]')); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
}); | ||
|
||
describe('[daffFormLabel]', () => { | ||
it('should add a class of "daff-form-label" to the host element', () => { | ||
expect(de.classes).toEqual(jasmine.objectContaining({ | ||
'daff-form-label': true, | ||
})); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
libs/design/src/atoms/form/form-label/form-label.directive.ts
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Directive, HostBinding } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[daffFormLabel]' | ||
}) | ||
|
||
export class DaffFormLabelDirective { | ||
|
||
@HostBinding('class.daff-form-label') class = true; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
libs/design/src/atoms/form/form-label/form-label.module.ts
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { DaffFormLabelDirective } from '../form-label/form-label.directive'; | ||
|
||
@NgModule({ | ||
exports: [ | ||
DaffFormLabelDirective | ||
], | ||
declarations: [ | ||
DaffFormLabelDirective | ||
] | ||
}) | ||
|
||
export class DaffFormLabelModule {} |