-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design)!: change daffTextAlignmentMixin to a directive (#2922)
BREAKING CHANGE: daffTextAlignmentMixin has been removed in favor of DaffTextAlignableDirective. Update usage by using the hostDirective feature.
- Loading branch information
Showing
10 changed files
with
188 additions
and
260 deletions.
There are no files selected for viewing
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
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
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
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
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
57 changes: 0 additions & 57 deletions
57
libs/design/src/core/text-alignable/text-alignable-mixin.ts
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
libs/design/src/core/text-alignable/text-alignable.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,86 @@ | ||
import { | ||
Component, | ||
DebugElement, | ||
} from '@angular/core'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { DaffTextAlignment } from './text-alignable'; | ||
import { DaffTextAlignableDirective } from './text-alignable.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<div daffTextAlignable [textAlignment]="textAlignment"></div>`, | ||
}) | ||
|
||
class WrapperComponent { | ||
textAlignment: DaffTextAlignment; | ||
} | ||
|
||
describe('@daffodil/design | DaffTextAlignableDirective', () => { | ||
let wrapper: WrapperComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let directive: DaffTextAlignableDirective; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
WrapperComponent, | ||
], | ||
imports: [ | ||
DaffTextAlignableDirective, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css('[daffTextAlignable]')); | ||
|
||
directive = de.injector.get(DaffTextAlignableDirective); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
|
||
it('should take textAlignment as an input', () => { | ||
expect(directive.textAlignment).toEqual(wrapper.textAlignment); | ||
}); | ||
|
||
it('should add a class of .daff-left to the host element if textAlignment is set to left', () => { | ||
wrapper.textAlignment = 'left'; | ||
fixture.detectChanges(); | ||
|
||
expect(directive.class).toEqual(jasmine.objectContaining({ | ||
'daff-left': true, | ||
})); | ||
}); | ||
|
||
it('should add a class of .daff-center to the host element if textAlignment is set to center', () => { | ||
wrapper.textAlignment = 'center'; | ||
fixture.detectChanges(); | ||
|
||
expect(directive.class).toEqual(jasmine.objectContaining({ | ||
'daff-center': true, | ||
})); | ||
}); | ||
|
||
it('should add a class of .daff-right to the host element if textAlignment is set to right', () => { | ||
wrapper.textAlignment = 'right'; | ||
fixture.detectChanges(); | ||
|
||
expect(directive.class).toEqual(jasmine.objectContaining({ | ||
'daff-right': true, | ||
})); | ||
}); | ||
}); |
Oops, something went wrong.