forked from microsoft/PowerBI-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.spec.ts
70 lines (58 loc) · 2.22 KB
/
test.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import * as service from '../src/service';
import * as factories from '../src/factories';
import * as utils from '../src/util';
// Avoid adding new tests to this file, create another spec file instead.
describe('embed', function () {
let powerbi: service.Service;
let container: HTMLDivElement;
let iframe: HTMLIFrameElement;
beforeEach(function () {
spyOn(utils, 'validateEmbedUrl').and.callFake(() => { return true; });
powerbi = new service.Service(factories.hpmFactory, factories.wpmpFactory, factories.routerFactory);
powerbi.accessToken = 'ABC123';
container = document.createElement('iframe');
container.setAttribute("powerbi-embed-url", "https://app.powerbi.com/reportEmbed?reportId=ABC123");
container.setAttribute("powerbi-type", "report");
document.body.appendChild(container);
powerbi.embed(container);
iframe = container.getElementsByTagName('iframe')[0];
});
afterEach(function () {
powerbi.reset(container);
container.remove();
powerbi.wpmp.stop();
});
describe('iframe', function () {
it('has a src', function () {
expect(iframe.src.length).toBeGreaterThan(0);
});
it('disables scrollbars by default', function () {
expect(iframe.getAttribute('scrolling')).toEqual('no');
});
it('sets width/height to 100%', function () {
expect(iframe.style.width).toEqual('100%');
expect(iframe.style.height).toEqual('100%');
});
});
describe('fullscreen', function () {
it('sets the iframe as the fullscreen element', function () {
let requestFullscreenSpy = jasmine.createSpy();
iframe.requestFullscreen = requestFullscreenSpy;
let report = powerbi.get(container);
report.fullscreen();
expect(requestFullscreenSpy).toHaveBeenCalled();
});
});
describe('exitFullscreen', function () {
it('clears the iframe fullscreen element', function () {
let requestFullscreenSpy = jasmine.createSpy();
iframe.requestFullscreen = requestFullscreenSpy;
let report = powerbi.get(container);
report.fullscreen();
report.exitFullscreen();
expect(requestFullscreenSpy).toHaveBeenCalled();
});
});
});