@@ -79,84 +79,24 @@ describe('service', function () {
7979 } ) ;
8080
8181 describe ( 'init' , function ( ) {
82- describe ( 'embeds all components found in the DOM' , function ( ) {
83- let powerbi : service . Service ; // redefined for this scope
84-
85- beforeEach ( function ( ) {
86- powerbi = new service . Service ( factories . hpmFactory , factories . wpmpFactory , factories . routerFactory ) ;
87- powerbi . accessToken = 'ABC123' ;
88- } ) ;
89-
90- afterEach ( function ( ) {
91- powerbi . wpmp . stop ( ) ;
92- powerbi = null ;
93- } ) ;
94-
95- it ( 'should work with multiple elements without id' , function ( ) {
96- // Arrange
97- const elements = [
98- '<div powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=ABC123" powerbi-type="report"></div>' ,
99- '<div powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=XYZ456" powerbi-type="report"></div>' ,
100- ] ;
101-
102- elements . forEach ( element => {
103- $ ( element ) . appendTo ( '#powerbi-fixture' ) ;
104- } ) ;
105-
106- // Act
107- powerbi . init ( ) ;
108-
109- // Assert
110- // If embed element has iframe inside it, assume embed action occurred
111- const iframes = document . querySelectorAll ( '[powerbi-embed-url] iframe' ) ;
112- expect ( iframes . length ) . toEqual ( 2 ) ;
113- // Check the number of components controlled by powerbi
114- expect ( powerbi . getNumberOfComponents ( ) ) . toEqual ( 2 ) ;
115- } ) ;
116-
117- it ( 'should work with multiple elements with id' , function ( ) {
118- // Arrange
119- const elements = [
120- '<div id="first-report" powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=ABC123" powerbi-type="report"></div>' ,
121- '<div id="second-report" powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=XYZ456" powerbi-type="report"></div>' ,
122- ] ;
123-
124- elements . forEach ( element => {
125- $ ( element ) . appendTo ( '#powerbi-fixture' ) ;
126- } ) ;
127-
128- // Act
129- powerbi . init ( ) ;
82+ it ( 'embeds all components found in the DOM' , function ( ) {
83+ // Arrange
84+ const elements = [
85+ '<div id="reportContainer1" powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=ABC123" powerbi-type="report"></div>' ,
86+ '<div id="reportContainer2" powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=XYZ456" powerbi-type="report"></div>' ,
87+ ] ;
13088
131- // Assert
132- // If embed element has iframe inside it, assume embed action occurred
133- const iframes = document . querySelectorAll ( '[powerbi-embed-url] iframe' ) ;
134- expect ( iframes . length ) . toEqual ( 2 ) ;
135- // Check the number of components controlled by powerbi
136- expect ( powerbi . getNumberOfComponents ( ) ) . toEqual ( 2 ) ;
89+ elements . forEach ( element => {
90+ $ ( element ) . appendTo ( '#powerbi-fixture' ) ;
13791 } ) ;
13892
139- it ( 'should work with multiple elements with duplicated id' , function ( ) {
140- // Arrange
141- const elements = [
142- '<div id="report" powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=ABC123" powerbi-type="report"></div>' ,
143- '<div id="report" powerbi-embed-url="https://embedded.powerbi.com/appTokenReportEmbed?reportId=XYZ456" powerbi-type="report"></div>' ,
144- ] ;
145-
146- elements . forEach ( element => {
147- $ ( element ) . appendTo ( '#powerbi-fixture' ) ;
148- } ) ;
149-
150- // Act
151- powerbi . init ( ) ;
93+ // Act
94+ powerbi . init ( ) ;
15295
153- // Assert
154- // If embed element has iframe inside it, assume embed action occurred
155- const iframes = document . querySelectorAll ( '[powerbi-embed-url] iframe' ) ;
156- expect ( iframes . length ) . toEqual ( 2 ) ;
157- // Check the number of components controlled by powerbi
158- expect ( powerbi . getNumberOfComponents ( ) ) . toEqual ( 2 ) ;
159- } ) ;
96+ // Assert
97+ // If embed element has iframe inside it, assume embed action occurred
98+ const iframes = document . querySelectorAll ( '[powerbi-embed-url] iframe' ) ;
99+ expect ( iframes . length ) . toEqual ( 2 ) ;
160100 } ) ;
161101
162102 it ( 'embeds all components found in the DOM without id attribute' , function ( ) {
0 commit comments