mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-01 14:41:32 +00:00
#68 close button
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { describe, expect, it, injectAsync, TestComponentBuilder, setBaseTestProviders, beforeEach } from 'angular2/testing';
|
||||
import { describe, expect, it, injectAsync, TestComponentBuilder, setBaseTestProviders } from 'angular2/testing';
|
||||
import { TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS } from 'angular2/platform/testing/browser';
|
||||
import { ViewerComponent } from './viewer.component';
|
||||
import { PDFJSmock } from './assets/PDFJS.mock';
|
||||
@@ -31,8 +31,10 @@ describe('Ng2-alfresco-viewer', () => {
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
|
||||
expect(element.querySelector('#viewer-the-canvas')).toBeDefined();
|
||||
expect(element.querySelector('#viewer-canvas-container')).toBeDefined();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-the-canvas')).not.toBeNull();
|
||||
expect(element.querySelector('#viewer-canvas-container')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -46,7 +48,8 @@ describe('Ng2-alfresco-viewer', () => {
|
||||
component.overlayMode = true;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-shadow-transparent')).toBeDefined();
|
||||
|
||||
expect(element.querySelector('#viewer-shadow-transparent')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -55,8 +58,11 @@ describe('Ng2-alfresco-viewer', () => {
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
expect(element.querySelector('#viewer-previous-page-button')).toBeDefined();
|
||||
expect(element.querySelector('#viewer-next-page-button')).toBeDefined();
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -65,11 +71,14 @@ describe('Ng2-alfresco-viewer', () => {
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-pagenumber-input')).toBeDefined();
|
||||
expect(element.querySelector('#viewer-total-pages')).toBeDefined();
|
||||
|
||||
expect(element.querySelector('#viewer-previous-page-page-button-input')).toBeDefined();
|
||||
expect(element.querySelector('#viewer-next-page-page-button-input')).toBeDefined();
|
||||
expect(element.querySelector('#viewer-previous-page-button')).not.toBeNull();
|
||||
expect(element.querySelector('#viewer-next-page-button')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -107,6 +116,37 @@ describe('Ng2-alfresco-viewer', () => {
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('Close button should be present', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
component.urlFile = 'fake-url-file';
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-close-button')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
it('if showViewer is false the viewer should be hide', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
component.showViewer = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#viewer-the-canvas')).toBeNull();
|
||||
expect(element.querySelector('#viewer-canvas-container')).toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('Attribute', () => {
|
||||
@@ -115,11 +155,57 @@ describe('Ng2-alfresco-viewer', () => {
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
component.showViewer = true;
|
||||
|
||||
expect(() => {
|
||||
component.urlFile = 'fake-url-file';
|
||||
component.ngOnChanges();
|
||||
}).toThrow();
|
||||
});
|
||||
}));
|
||||
|
||||
it('showViewer default value should be true', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
|
||||
expect(component.showViewer).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('if showViewer value is false the viewer should be hide', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let component = fixture.componentInstance;
|
||||
let element = fixture.nativeElement;
|
||||
component.urlFile = 'fake-url-file';
|
||||
component.showViewer = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-the-canvas')).toBeNull();
|
||||
expect(element.querySelector('#viewer-canvas-container')).toBeNull();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
describe('User interaction', () => {
|
||||
it('Click on close button should hide the viewer', injectAsync([TestComponentBuilder], (tcb: TestComponentBuilder) => {
|
||||
return tcb
|
||||
.createAsync(ViewerComponent)
|
||||
.then((fixture) => {
|
||||
let element = fixture.nativeElement;
|
||||
let component = fixture.componentInstance;
|
||||
spyOn(component, 'getPDFJS').and.returnValue(new PDFJSmock());
|
||||
component.urlFile = 'fake-url-file';
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-canvas-container')).not.toBeNull();
|
||||
element.querySelector('#viewer-close-button').click();
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-canvas-container')).toBeNull();
|
||||
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user