@@ -20,6 +20,34 @@ declare global {
2020 }
2121}
2222
23+ function ValidateDashboardConfigurationWorksAsExpected ( pageView : string , exceptionExpected : boolean , powerbi : service . Service ) {
24+ const embedUrl = `https://app.powerbi.com/dashboardEmbed` ;
25+ const component = $ ( `<div powerbi-embed-url="${ embedUrl } " powerbi-type="report"></div>` )
26+ . appendTo ( '#powerbi-fixture' ) ;
27+
28+ const dashboardEmbedConfig = {
29+ type : "dashboard" ,
30+ id : "fakeReportId" ,
31+ accessToken : "fakeAccessToken" ,
32+ embedUrl : "fakeEmbedUrl" ,
33+ pageView : pageView
34+ } ;
35+
36+ powerbi . embed ( component [ 0 ] , < any > dashboardEmbedConfig ) ;
37+
38+ var exceptionThrown = false ;
39+ // Act
40+ try {
41+ powerbi . embed ( component [ 0 ] , < any > dashboardEmbedConfig ) ;
42+ }
43+ catch ( e ) {
44+ exceptionThrown = true ;
45+ }
46+
47+ // Assert
48+ expect ( exceptionThrown ) . toBe ( exceptionExpected ) ;
49+ }
50+
2351let logMessages = ( window . __karma__ . config . args [ 0 ] === 'logMessages' ) ;
2452
2553describe ( 'service' , function ( ) {
@@ -218,6 +246,26 @@ describe('service', function () {
218246 expect ( attemptToEmbed ) . toThrowError ( ) ;
219247 } ) ;
220248
249+ it ( 'if attempting to embed a dashboard with an invalid pageView, throw error' , function ( ) {
250+ ValidateDashboardConfigurationWorksAsExpected ( "notValid" , true , powerbi ) ;
251+ } ) ;
252+
253+ it ( 'if attempting to embed a dashboard with a pageView equals fitToWidth, don\'t throw error' , function ( ) {
254+ ValidateDashboardConfigurationWorksAsExpected ( "fitToWidth" , false , powerbi ) ;
255+ } ) ;
256+
257+ it ( 'if attempting to embed a dashboard with a pageView equals oneColumn, don\'t throw error' , function ( ) {
258+ ValidateDashboardConfigurationWorksAsExpected ( "oneColumn" , false , powerbi ) ;
259+ } ) ;
260+
261+ it ( 'if attempting to embed a dashboard with a pageView equals actualSize, don\'t throw error' , function ( ) {
262+ ValidateDashboardConfigurationWorksAsExpected ( "actualSize" , false , powerbi ) ;
263+ } ) ;
264+
265+ it ( 'if attempting to embed a dashboard with an undefined pageView, don\'t throw error' , function ( ) {
266+ ValidateDashboardConfigurationWorksAsExpected ( undefined , false , powerbi ) ;
267+ } ) ;
268+
221269 it ( 'should get uqiqueId from config first' , function ( ) {
222270 // Arrange
223271 const testUniqueId = 'fakeUniqueId' ;
0 commit comments