-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: (CXSPA-8991) set aria-label attribute for navigation component b…
…utton #19653 (#19769) Closes: https://jira.tools.sap/browse/CXSPA-8991
- Loading branch information
Showing
12 changed files
with
306 additions
and
13 deletions.
There are no files selected for viewing
15 changes: 11 additions & 4 deletions
15
feature-libs/user/account/components/login/login.component.html
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
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
101 changes: 101 additions & 0 deletions
101
projects/storefrontlib/layout/a11y/on-dom-change/dom-change.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,101 @@ | ||
import { Component, ElementRef } from '@angular/core'; | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { DomChangeDirective } from './dom-change.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<div id="testElement" cxDomChange> | ||
<div class="targetElement"></div> | ||
</div> | ||
`, | ||
}) | ||
class TestHostComponent {} | ||
|
||
describe('DomChangeDirective', () => { | ||
// let component: TestHostComponent; | ||
let fixture: ComponentFixture<TestHostComponent>; | ||
let testElement: ElementRef; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TestHostComponent, DomChangeDirective], | ||
imports: [BrowserAnimationsModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
|
||
testElement = fixture.debugElement.query(By.directive(DomChangeDirective)); | ||
})); | ||
|
||
it('should emit when a child element is added', (done) => { | ||
const directive = fixture.debugElement | ||
.query(By.directive(DomChangeDirective)) | ||
.injector.get(DomChangeDirective); | ||
const newElement = document.createElement('div'); | ||
|
||
directive.cxDomChange.subscribe((mutation: MutationRecord) => { | ||
expect(mutation.type).toBe('childList'); | ||
done(); | ||
}); | ||
|
||
// Set DOM | ||
testElement.nativeElement.appendChild(newElement); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should emit when a child element is removed', (done) => { | ||
const directive = fixture.debugElement | ||
.query(By.directive(DomChangeDirective)) | ||
.injector.get(DomChangeDirective); | ||
const childElement = | ||
testElement.nativeElement.querySelector('.targetElement'); | ||
|
||
directive.cxDomChange.subscribe((mutation: MutationRecord) => { | ||
expect(mutation.type).toBe('childList'); | ||
done(); | ||
}); | ||
|
||
// Set DOM | ||
testElement.nativeElement.removeChild(childElement); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should filter mutations based on the target selector', (done) => { | ||
const directive = fixture.debugElement | ||
.query(By.directive(DomChangeDirective)) | ||
.injector.get(DomChangeDirective); | ||
directive.cxDomChangeTargetSelector = '.targetElement'; | ||
|
||
directive.cxDomChange.subscribe((mutation: MutationRecord) => { | ||
expect(mutation.target).toHaveClass('targetElement'); | ||
done(); | ||
}); | ||
|
||
// Set DOM | ||
const targetElement = | ||
testElement.nativeElement.querySelector('.targetElement'); | ||
targetElement.appendChild(document.createTextNode('Test Text')); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should not emit when mutations do not match target selector', () => { | ||
let called = false; | ||
const directive = fixture.debugElement | ||
.query(By.directive(DomChangeDirective)) | ||
.injector.get(DomChangeDirective); | ||
directive.cxDomChangeTargetSelector = '.non-matching-selector'; | ||
|
||
directive.cxDomChange.subscribe(() => { | ||
called = true; | ||
}); | ||
|
||
// Set DOM | ||
const newElement = document.createElement('div'); | ||
testElement.nativeElement.appendChild(newElement); | ||
fixture.detectChanges(); | ||
|
||
expect(called).toBe(false); | ||
}); | ||
}); |
Oops, something went wrong.