@@ -18,7 +18,7 @@ describe("Browser renderer", function () {
1818 ) ;
1919 } ) ;
2020
21- ifNotInPhantomIt ( "should draw an image directly" , function ( done ) {
21+ it ( "should draw an image directly" , function ( done ) {
2222 spyOn ( rasterizeHTML , "drawHTML" ) ;
2323
2424 browserRenderer
@@ -64,91 +64,82 @@ describe("Browser renderer", function () {
6464 ) ;
6565 } ;
6666
67- ifNotInPhantomIt (
68- "should draw the html page if url is not an image, disable caching and execute JavaScript" ,
69- function ( done ) {
70- var theUrl = "the url" ,
71- theHtml = "some html" ;
67+ it ( "should draw the html page if url is not an image, disable caching and execute JavaScript" , function ( done ) {
68+ var theUrl = "the url" ,
69+ theHtml = "some html" ;
7270
73- setUpRasterizeHtmlToBeSuccessful ( ) ;
71+ setUpRasterizeHtmlToBeSuccessful ( ) ;
72+
73+ spyOn ( util , "loadAsBlob" ) . and . callFake ( function ( ) {
74+ return testHelper . successfulPromise (
75+ new Blob ( [ theHtml ] , { type : "text/html" } )
76+ ) ;
77+ } ) ;
7478
75- spyOn ( util , "loadAsBlob" ) . and . callFake ( function ( ) {
76- return testHelper . successfulPromise (
77- new Blob ( [ theHtml ] , { type : "text/html" } )
79+ browserRenderer
80+ . render ( {
81+ url : theUrl ,
82+ width : 42 ,
83+ height : 7 ,
84+ } )
85+ . then ( function ( result ) {
86+ expect ( result . image ) . toBe ( "the image" ) ;
87+ expect ( rasterizeHTML . drawHTML ) . toHaveBeenCalledWith (
88+ theHtml ,
89+ {
90+ cache : "repeated" ,
91+ cacheBucket : jasmine . any ( Object ) ,
92+ width : 42 ,
93+ height : 7 ,
94+ executeJs : true ,
95+ executeJsTimeout : 50 ,
96+ baseUrl : theUrl ,
97+ }
7898 ) ;
99+
100+ done ( ) ;
79101 } ) ;
102+ } ) ;
80103
81- browserRenderer
82- . render ( {
83- url : theUrl ,
84- width : 42 ,
85- height : 7 ,
86- } )
87- . then ( function ( result ) {
88- expect ( result . image ) . toBe ( "the image" ) ;
89- expect ( rasterizeHTML . drawHTML ) . toHaveBeenCalledWith (
90- theHtml ,
91- {
92- cache : "repeated" ,
93- cacheBucket : jasmine . any ( Object ) ,
94- width : 42 ,
95- height : 7 ,
96- executeJs : true ,
97- executeJsTimeout : 50 ,
98- baseUrl : theUrl ,
99- }
100- ) ;
101-
102- done ( ) ;
103- } ) ;
104- }
105- ) ;
104+ it ( "should call the error handler if a page could not be rendered" , function ( done ) {
105+ setUpRasterizeHtmlToFail ( ) ;
106106
107- ifNotInPhantomIt (
108- "should call the error handler if a page could not be rendered" ,
109- function ( done ) {
110- setUpRasterizeHtmlToFail ( ) ;
111-
112- browserRenderer
113- . render ( {
114- url : testHelper . fixture ( "pageUnderTest.html" ) ,
115- width : 42 ,
116- height : 7 ,
117- } )
118- . then ( null , done ) ;
119- }
120- ) ;
107+ browserRenderer
108+ . render ( {
109+ url : testHelper . fixture ( "pageUnderTest.html" ) ,
110+ width : 42 ,
111+ height : 7 ,
112+ } )
113+ . then ( null , done ) ;
114+ } ) ;
121115
122- ifNotInPhantomIt (
123- "should report errors from rendering" ,
124- function ( done ) {
125- browserRenderer
126- . render ( {
127- url : testHelper . fixture ( "brokenPage.html" ) ,
128- width : 42 ,
129- height : 7 ,
130- } )
131- . then ( function ( result ) {
132- expect ( result . errors ) . not . toBeNull ( ) ;
133- expect ( result . errors . length ) . toBe ( 3 ) ;
134- result . errors . sort ( ) ;
135- expect ( result . errors ) . toEqual ( [
136- "Unable to load background-image " +
137- testHelper . fixture (
138- "background_image_does_not_exist.jpg"
139- ) ,
140- "Unable to load image " +
141- testHelper . fixture ( "image_does_not_exist.png" ) ,
142- "Unable to load stylesheet " +
143- testHelper . fixture ( "css_does_not_exist.css" ) ,
144- ] ) ;
145-
146- done ( ) ;
147- } ) ;
148- }
149- ) ;
116+ it ( "should report errors from rendering" , function ( done ) {
117+ browserRenderer
118+ . render ( {
119+ url : testHelper . fixture ( "brokenPage.html" ) ,
120+ width : 42 ,
121+ height : 7 ,
122+ } )
123+ . then ( function ( result ) {
124+ expect ( result . errors ) . not . toBeNull ( ) ;
125+ expect ( result . errors . length ) . toBe ( 3 ) ;
126+ result . errors . sort ( ) ;
127+ expect ( result . errors ) . toEqual ( [
128+ "Unable to load background-image " +
129+ testHelper . fixture (
130+ "background_image_does_not_exist.jpg"
131+ ) ,
132+ "Unable to load image " +
133+ testHelper . fixture ( "image_does_not_exist.png" ) ,
134+ "Unable to load stylesheet " +
135+ testHelper . fixture ( "css_does_not_exist.css" ) ,
136+ ] ) ;
137+
138+ done ( ) ;
139+ } ) ;
140+ } ) ;
150141
151- ifNotInPhantomIt ( "should render with hover effect" , function ( done ) {
142+ it ( "should render with hover effect" , function ( done ) {
152143 setUpRasterizeHtmlToBeSuccessful ( ) ;
153144
154145 browserRenderer
@@ -167,35 +158,32 @@ describe("Browser renderer", function () {
167158 } ) ;
168159 } ) ;
169160
170- ifNotInPhantomIt (
171- "should render with active/focus/target effect" ,
172- function ( done ) {
173- setUpRasterizeHtmlToBeSuccessful ( ) ;
174-
175- browserRenderer
176- . render ( {
177- url : testHelper . fixture ( "pageUnderTest.html" ) ,
178- width : 42 ,
179- height : 7 ,
180- active : ".someSelector" ,
181- focus : "#other" ,
182- target : "img" ,
183- } )
184- . then ( function ( ) {
185- expect ( rasterizeHTML . drawHTML ) . toHaveBeenCalledWith (
186- jasmine . any ( String ) ,
187- jasmine . objectContaining ( {
188- active : ".someSelector" ,
189- focus : "#other" ,
190- target : "img" ,
191- } )
192- ) ;
193- done ( ) ;
194- } ) ;
195- }
196- ) ;
161+ it ( "should render with active/focus/target effect" , function ( done ) {
162+ setUpRasterizeHtmlToBeSuccessful ( ) ;
163+
164+ browserRenderer
165+ . render ( {
166+ url : testHelper . fixture ( "pageUnderTest.html" ) ,
167+ width : 42 ,
168+ height : 7 ,
169+ active : ".someSelector" ,
170+ focus : "#other" ,
171+ target : "img" ,
172+ } )
173+ . then ( function ( ) {
174+ expect ( rasterizeHTML . drawHTML ) . toHaveBeenCalledWith (
175+ jasmine . any ( String ) ,
176+ jasmine . objectContaining ( {
177+ active : ".someSelector" ,
178+ focus : "#other" ,
179+ target : "img" ,
180+ } )
181+ ) ;
182+ done ( ) ;
183+ } ) ;
184+ } ) ;
197185
198- ifNotInPhantomIt ( "should properly render Unicode" , function ( done ) {
186+ it ( "should properly render Unicode" , function ( done ) {
199187 setUpRasterizeHtmlToBeSuccessful ( ) ;
200188
201189 browserRenderer
0 commit comments