mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
feat(aio): support hiding the copy button on code-examole components
In the API docs there are occasions where we do not wish the code snippet to have a copy button. This commit supports that by providing a new `hideCopy` attribute.
This commit is contained in:
committed by
Matias Niemelä
parent
cb5bc76766
commit
a0b9c23100
@@ -179,6 +179,13 @@ describe('CodeComponent', () => {
|
||||
});
|
||||
|
||||
describe('copy button', () => {
|
||||
|
||||
it('should be hidden if the `hideCopy` input is true', () => {
|
||||
hostComponent.hideCopy = true;
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.query(By.css('button'))).toBe(null);
|
||||
});
|
||||
|
||||
it('should call copier service when clicked', () => {
|
||||
const copierService: CopierService = TestBed.get(CopierService);
|
||||
const spy = spyOn(copierService, 'copyText');
|
||||
@@ -224,7 +231,7 @@ describe('CodeComponent', () => {
|
||||
selector: 'aio-host-comp',
|
||||
template: `
|
||||
<aio-code md-no-ink [code]="code" [language]="language"
|
||||
[linenums]="linenums" [path]="path" [region]="region"></aio-code>
|
||||
[linenums]="linenums" [path]="path" [region]="region" [hideCopy]="hideCopy"></aio-code>
|
||||
`
|
||||
})
|
||||
class HostComponent {
|
||||
@@ -233,6 +240,7 @@ class HostComponent {
|
||||
linenums: boolean | number | string;
|
||||
path: string;
|
||||
region: string;
|
||||
hideCopy: boolean;
|
||||
}
|
||||
|
||||
class TestLogger {
|
||||
|
||||
Reference in New Issue
Block a user