@@ -639,6 +639,40 @@ describe('service', function () {
639639 // Assert
640640 expect ( report . createConfig . datasetId ) . toEqual ( testDatasetId ) ;
641641 } ) ;
642+
643+ it ( 'theme should be in create config if exists is embedConfig' , function ( ) {
644+ // Arrange
645+
646+ const testDatasetId = "ABC123" ;
647+ const accessToken = 'ABC123' ;
648+ const theme = { themeJson : { name : "Theme ABC 123" } } ;
649+ const embedUrl = `https://app.powerbi.com/reportEmbed?datasetId=${ testDatasetId } ` ;
650+ const $reportContainer = $ ( `<div powerbi-embed-url="${ embedUrl } "</div>` )
651+ . appendTo ( '#powerbi-fixture' ) ;
652+
653+ // Act
654+ const report = powerbi . createReport ( $reportContainer [ 0 ] , { embedUrl : embedUrl , accessToken : accessToken , theme : theme } ) ;
655+
656+ // Assert
657+ expect ( report . createConfig . theme ) . toEqual ( theme ) ;
658+ } ) ;
659+
660+ it ( 'theme should be undefined in create config if not exists is embedConfig' , function ( ) {
661+ // Arrange
662+
663+ const testDatasetId = "ABC123" ;
664+ const accessToken = 'ABC123' ;
665+ const theme = { themeJson : { name : "Theme ABC 123" } } ;
666+ const embedUrl = `https://app.powerbi.com/reportEmbed?datasetId=${ testDatasetId } ` ;
667+ const $reportContainer = $ ( `<div powerbi-embed-url="${ embedUrl } "</div>` )
668+ . appendTo ( '#powerbi-fixture' ) ;
669+
670+ // Act
671+ const report = powerbi . createReport ( $reportContainer [ 0 ] , { embedUrl : embedUrl , accessToken : accessToken } ) ;
672+
673+ // Assert
674+ expect ( report . createConfig . theme ) . toBeUndefined ( ) ;
675+ } ) ;
642676 } ) ;
643677
644678 describe ( 'reports' , function ( ) {
@@ -725,6 +759,40 @@ describe('service', function () {
725759 // Assert
726760 expect ( ( < embed . IEmbedConfiguration > report . config ) . id ) . toEqual ( testReportId ) ;
727761 } ) ;
762+
763+ it ( 'theme should be in report config if exists is embedConfig' , function ( ) {
764+ // Arrange
765+ const testReportId = "ABC123" ;
766+ const embedUrl = `https://app.powerbi.com/reportEmbed?reportId=${ testReportId } ` ;
767+ const $reportContainer = $ ( `<div powerbi-embed-url="${ embedUrl } " powerbi-type="report" powerbi-report-id></div>` )
768+ . appendTo ( '#powerbi-fixture' ) ;
769+
770+ const theme = { themeJson : { name : "Theme ABC 123" } } ;
771+ const configuration : embed . IEmbedConfiguration = { theme : theme } ;
772+
773+ // Act
774+ const report = powerbi . embed ( $reportContainer [ 0 ] , configuration ) ;
775+
776+ // Assert
777+ expect ( ( < embed . IEmbedConfiguration > report . config ) . theme ) . toEqual ( theme ) ;
778+ } ) ;
779+
780+ it ( 'theme should be undefined in report config if not exists is embedConfig' , function ( ) {
781+ // Arrange
782+ const testReportId = "ABC123" ;
783+ const embedUrl = `https://app.powerbi.com/reportEmbed?reportId=${ testReportId } ` ;
784+ const $reportContainer = $ ( `<div powerbi-embed-url="${ embedUrl } " powerbi-type="report" powerbi-report-id></div>` )
785+ . appendTo ( '#powerbi-fixture' ) ;
786+
787+ const theme = { themeJson : { name : "Theme ABC 123" } } ;
788+ const configuration : embed . IEmbedConfiguration = { } ;
789+
790+ // Act
791+ const report = powerbi . embed ( $reportContainer [ 0 ] , configuration ) ;
792+
793+ // Assert
794+ expect ( ( < embed . IEmbedConfiguration > report . config ) . theme ) . toBeUndefined ( ) ;
795+ } ) ;
728796 } ) ;
729797
730798 xdescribe ( 'tiles' , function ( ) {
@@ -3795,6 +3863,53 @@ describe('SDK-to-HPM', function () {
37953863 } ) ;
37963864 } ) ;
37973865 } ) ;
3866+
3867+ describe ( 'theme' , function ( ) {
3868+ it ( 'report.applyTheme(theme) sends PUT /report/theme with theme in body' , function ( ) {
3869+ // Arrange
3870+ const testData = {
3871+ theme : {
3872+ themeJson : {
3873+ name : "Theme ABC 123"
3874+ }
3875+ } ,
3876+ response : {
3877+ body : null
3878+ }
3879+ } ;
3880+
3881+ spyHpm . post . and . returnValue ( Promise . resolve ( testData . response ) ) ;
3882+ report . applyTheme ( testData . theme )
3883+ . then ( ( ) => {
3884+ spyHpm . post . calls . reset ( ) ;
3885+
3886+ // Act
3887+ report . reload ( ) ;
3888+
3889+ // Assert
3890+ expect ( spyHpm . post ) . toHaveBeenCalledWith ( '/report/load' , jasmine . objectContaining ( testData . theme ) , { uid : uniqueId , sdkSessionId : sdkSessionId } , iframe . contentWindow ) ;
3891+ } ) ;
3892+ } ) ;
3893+
3894+ it ( 'report.resetTheme() sends PUT /report/theme with empty object as theme in body' , function ( ) {
3895+ // Arrange
3896+ const response = {
3897+ body : null
3898+ } ;
3899+
3900+ spyHpm . post . and . returnValue ( Promise . resolve ( response ) ) ;
3901+ report . resetTheme ( )
3902+ . then ( ( ) => {
3903+ spyHpm . post . calls . reset ( ) ;
3904+
3905+ // Act
3906+ report . reload ( ) ;
3907+
3908+ // Assert
3909+ expect ( spyHpm . post ) . toHaveBeenCalledWith ( '/report/load' , jasmine . objectContaining ( { } ) , { uid : uniqueId , sdkSessionId : sdkSessionId } , iframe . contentWindow ) ;
3910+ } ) ;
3911+ } ) ;
3912+ } ) ;
37983913 } ) ;
37993914
38003915 describe ( 'SDK-to-Router (Event subscription)' , function ( ) {
0 commit comments