-
-
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 daffCompactableMixin to a directive
- Loading branch information
1 parent
aa77469
commit faef6bc
Showing
9 changed files
with
110 additions
and
119 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 was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
libs/design/src/core/compactable/compactable.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,74 @@ | ||
import { | ||
Component, | ||
DebugElement, | ||
} from '@angular/core'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { DaffCompactableDirective } from './compactable.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<div daffCompactable [compact]="compact"></div>`, | ||
}) | ||
|
||
class WrapperComponent { | ||
compact: boolean; | ||
} | ||
|
||
describe('@daffodil/design | DaffCompactableDirective', () => { | ||
let wrapper: WrapperComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let directive: DaffCompactableDirective; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
WrapperComponent, | ||
], | ||
imports: [ | ||
DaffCompactableDirective, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css('[daffCompactable]')); | ||
|
||
directive = de.injector.get(DaffCompactableDirective); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
|
||
it('should take compact as an input', () => { | ||
expect(directive.compact).toEqual(wrapper.compact); | ||
}); | ||
|
||
it('should add a class of .daff-compact to the host element if compact is set to true', () => { | ||
wrapper.compact = true; | ||
fixture.detectChanges(); | ||
|
||
expect(de.classes).toEqual(jasmine.objectContaining({ | ||
'daff-compact': true, | ||
})); | ||
}); | ||
|
||
it('should not add a class of .daff-compact to the host element if compact is set to false', () => { | ||
wrapper.compact = false; | ||
fixture.detectChanges(); | ||
|
||
expect(de.classes['daff-skeleton']).toBeUndefined(); | ||
}); | ||
}); |
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,14 @@ | ||
import { | ||
Directive, | ||
HostBinding, | ||
Input, | ||
} from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[daffCompactable]', | ||
standalone: true, | ||
}) | ||
|
||
export class DaffCompactableDirective { | ||
@Input() @HostBinding('class.daff-compact') compact = false; | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { DaffCompactable } from './compactable'; | ||
export { daffCompactableMixin } from './compactable-mixin'; | ||
export { DaffCompactableDirective } from './compactable.directive'; |