@@ -1037,6 +1037,26 @@ describe('Protocol', function () {
10371037 } ) ;
10381038 } ) ;
10391039
1040+ describe ( 'refresh' , function ( ) {
1041+ it ( 'POST /report/refresh returns 202 if the request is valid' , function ( done ) {
1042+ // Arrange
1043+ iframeLoaded
1044+ . then ( ( ) => {
1045+ spyApp . refreshData . and . returnValue ( Promise . resolve ( null ) ) ;
1046+ // Act
1047+ hpm . post < void > ( '/report/refresh' , null )
1048+ . then ( response => {
1049+ // Assert
1050+ expect ( spyApp . refreshData ) . toHaveBeenCalled ( ) ;
1051+ expect ( response . statusCode ) . toEqual ( 202 ) ;
1052+ // Cleanup
1053+ spyApp . refreshData . calls . reset ( ) ;
1054+ done ( ) ;
1055+ } ) ;
1056+ } ) ;
1057+ } ) ;
1058+ } ) ;
1059+
10401060 describe ( 'filters (report level)' , function ( ) {
10411061 it ( 'GET /report/filters returns 200 with body as array of filters' , function ( done ) {
10421062 // Arrange
@@ -2076,6 +2096,36 @@ describe('SDK-to-HPM', function () {
20762096 } ) ;
20772097 } ) ;
20782098
2099+ describe ( 'refresh' , function ( ) {
2100+ it ( 'report.refresh() sends POST /report/refresh' , function ( ) {
2101+ // Arrange
2102+ spyHpm . post . and . returnValue ( Promise . resolve ( {
2103+ body : { }
2104+ } ) ) ;
2105+
2106+ // Act
2107+ report . refresh ( ) ;
2108+
2109+ // Assert
2110+ expect ( spyHpm . post ) . toHaveBeenCalledWith ( '/report/refresh' , null , { uid : uniqueId } , iframe . contentWindow ) ;
2111+ } ) ;
2112+
2113+ it ( 'report.refresh() returns promise that resolves if the request is accepted' , function ( done ) {
2114+ // Arrange
2115+ spyHpm . post . and . returnValue ( Promise . resolve ( {
2116+ body : { }
2117+ } ) ) ;
2118+
2119+ // Act
2120+ report . refresh ( )
2121+ . then ( ( ) => {
2122+ // Assert
2123+ expect ( spyHpm . post ) . toHaveBeenCalledWith ( '/report/refresh' , null , { uid : uniqueId } , iframe . contentWindow ) ;
2124+ done ( ) ;
2125+ } ) ;
2126+ } ) ;
2127+ } ) ;
2128+
20792129 describe ( 'settings' , function ( ) {
20802130 it ( 'report.updateSettings(settings) sends PATCH /report/settings with settings object' , function ( ) {
20812131 // Arrange
@@ -3132,6 +3182,24 @@ describe('SDK-to-MockApp', function () {
31323182 } ) ;
31333183 } ) ;
31343184
3185+ describe ( 'refresh' , function ( ) {
3186+ it ( 'report.refresh() returns promise that resolves with null if the report refresh command was accepted' , function ( done ) {
3187+ // Arrange
3188+ iframeLoaded
3189+ . then ( ( ) => {
3190+ spyApp . refreshData . and . returnValue ( Promise . resolve ( null ) ) ;
3191+ // Act
3192+ report . refresh ( )
3193+ . then ( response => {
3194+ // Assert
3195+ expect ( spyApp . refreshData ) . toHaveBeenCalled ( ) ;
3196+ expect ( response ) . toEqual ( undefined ) ;
3197+ done ( ) ;
3198+ } ) ;
3199+ } ) ;
3200+ } ) ;
3201+ } ) ;
3202+
31353203 describe ( 'settings' , function ( ) {
31363204 it ( 'report.updateSettings(setting) returns promise that rejects with validation error if object is invalid' , function ( done ) {
31373205 // Arrange
0 commit comments