-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
280 additions
and
16 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
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,13 @@ | ||
<span class="space"></span> | ||
|
||
<span class="survey-content"> | ||
<a href="{{surveyUrl}}" (click)="hideSurvey.next()"> | ||
<mat-icon class="survey-icon" [svgIcon]="icon" [attr.aria-label]="iconText"></mat-icon> | ||
</a> | ||
<a href="{{surveyUrl}}" (click)="hideSurvey.next()" class="survey-link">{{message}}</a> | ||
<a href="{{surveyUrl}}" (click)="hideSurvey.next()" class="survey-button">{{buttonText}}</a> | ||
</span> | ||
|
||
<button mat-icon-button class="close-button" aria-label="Close" (click)="hideSurvey.next()"> | ||
<mat-icon svgIcon="close"></mat-icon> | ||
</button> |
65 changes: 65 additions & 0 deletions
65
aio/src/app/layout/survey-link/survey-link.component.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,65 @@ | ||
import { NO_ERRORS_SCHEMA } from '@angular/core'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { SurveyLinkComponent } from './survey-link.component'; | ||
|
||
describe('TopMenuComponent', () => { | ||
let component: SurveyLinkComponent; | ||
let fixture: ComponentFixture<SurveyLinkComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ SurveyLinkComponent ], | ||
schemas: [NO_ERRORS_SCHEMA] | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SurveyLinkComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should display the message', () => { | ||
component.message = 'Some test message'; | ||
fixture.detectChanges(); | ||
expect(fixture.nativeElement.textContent).toContain('Some test message'); | ||
}); | ||
|
||
it('should display an icon', () => { | ||
component.icon = 'insert_comment'; | ||
component.iconText = 'Survey Icon'; | ||
fixture.detectChanges(); | ||
const iconElement = fixture.debugElement.query(By.css('.survey-icon')); | ||
expect(iconElement.properties['svgIcon']).toEqual('insert_comment'); | ||
expect(iconElement.attributes['aria-label']).toEqual('Survey Icon'); | ||
}); | ||
|
||
it('should display a button', () => { | ||
component.buttonText = 'click me'; | ||
fixture.detectChanges(); | ||
const button = fixture.debugElement.query(By.css('.survey-button')); | ||
expect(button.nativeElement.textContent).toEqual('click me'); | ||
}); | ||
|
||
it('should trigger hideSurvey output when any link is clicked', () => { | ||
const spy = jasmine.createSpy('hideSurvey handler'); | ||
component.hideSurvey.subscribe(() => spy()); | ||
const links = fixture.debugElement.queryAll(By.css('a')); | ||
expect(links.length).toBeGreaterThan(0); | ||
links.forEach(link => { | ||
spy.calls.reset(); | ||
link.triggerEventHandler('click', null); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
|
||
it('should trigger hideSurvey output when the close button is clicked', () => { | ||
const spy = jasmine.createSpy('hideSurvey handler'); | ||
component.hideSurvey.subscribe(() => spy()); | ||
const button = fixture.debugElement.query(By.css('.close-button')); | ||
spy.calls.reset(); | ||
button.triggerEventHandler('click', null); | ||
expect(spy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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 { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'aio-survey-link', | ||
templateUrl: 'survey-link.component.html', | ||
exportAs: 'surveyLink' | ||
}) | ||
export class SurveyLinkComponent { | ||
@Input() icon: string; | ||
@Input() iconText: string; | ||
@Input() message: string; | ||
@Input() buttonText: string; | ||
@Input() surveyUrl: string; | ||
@Output() hideSurvey = new EventEmitter(); | ||
} |
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,4 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
|
||
export const CurrentDateToken = new InjectionToken('CurrentDate'); | ||
export function currentDateProvider() { return new Date(); } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ | |
@import 'toc'; | ||
@import 'select-menu'; | ||
@import 'deploy-theme'; | ||
@import 'survey'; |
Oops, something went wrong.