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:
Peter Bacon Darwin
2017-05-02 11:57:26 +01:00
committed by Matias Niemelä
parent cb5bc76766
commit a0b9c23100
4 changed files with 27 additions and 3 deletions
@@ -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 {