2016-04-27 00:51:02 +03:00
|
|
|
describe('jquery', function () {
|
|
|
|
let $fixture = null;
|
|
|
|
|
|
|
|
beforeAll(function () {
|
|
|
|
$fixture = $('<div id="powerbi-fixture"></div>').appendTo(document.body);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(function () {
|
2016-04-28 02:40:13 +03:00
|
|
|
window.powerbi.reset($fixture.get(0));
|
2016-04-27 00:51:02 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('calling .powerbi on a jQuery object calls the internal powerbi.embed using the element from the jquery object', function () {
|
|
|
|
// Arrange
|
|
|
|
var powerbiServiceMock = jasmine.createSpyObj('powerbiServiceMock', ['embed']);
|
|
|
|
var originalPowerbi = window.powerbi;
|
|
|
|
window.powerbi = powerbiServiceMock;
|
|
|
|
|
|
|
|
var embedConfiguration = {
|
|
|
|
type: 'report',
|
|
|
|
accessToken: 'fakeToken',
|
|
|
|
embedUrl: 'https://embed.powerbi.com/embed?reportId=123'
|
|
|
|
};
|
|
|
|
|
|
|
|
// Act
|
|
|
|
$fixture.powerbi(embedConfiguration);
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
expect(powerbiServiceMock.embed).toHaveBeenCalledWith($fixture.get(0), embedConfiguration);
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
window.powerbi = originalPowerbi;
|
|
|
|
});
|
|
|
|
|
|
|
|
it('calling .powerbi on a jQuery object with embed configuration embeds iframe within element', function () {
|
|
|
|
// Arrange
|
|
|
|
var embedConfiguration = {
|
|
|
|
type: 'report',
|
|
|
|
accessToken: 'fakeToken',
|
|
|
|
embedUrl: 'https://embed.powerbi.com/embed?reportId=123'
|
|
|
|
};
|
|
|
|
|
|
|
|
// Act
|
|
|
|
$fixture.powerbi(embedConfiguration);
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
var iframe = $fixture.find('iframe');
|
|
|
|
expect(iframe.get(0)).not.toBeUndefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('calling .powerbi returns the jQuery object to allow chaining', function () {
|
|
|
|
// Arrange
|
|
|
|
var embedConfiguration = {
|
|
|
|
id: '123',
|
|
|
|
type: 'report',
|
|
|
|
accessToken: 'fakeToken',
|
|
|
|
embedUrl: 'https://embed.powerbi.com/embed?reportId=123'
|
|
|
|
};
|
|
|
|
|
|
|
|
// Act
|
|
|
|
var returnValue = $fixture.powerbi(embedConfiguration);
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
expect(returnValue).toBe($fixture);
|
|
|
|
});
|
|
|
|
});
|