@@ -1017,6 +1017,26 @@ describe('Protocol', function () {
1017
1017
} ) ;
1018
1018
} ) ;
1019
1019
1020
+ describe ( 'print' , function ( ) {
1021
+ it ( 'POST /report/print returns 202 if the request is valid' , function ( done ) {
1022
+ // Arrange
1023
+ iframeLoaded
1024
+ . then ( ( ) => {
1025
+ spyApp . print . and . returnValue ( Promise . resolve ( null ) ) ;
1026
+ // Act
1027
+ hpm . post < void > ( '/report/print' , null )
1028
+ . then ( response => {
1029
+ // Assert
1030
+ expect ( spyApp . print ) . toHaveBeenCalled ( ) ;
1031
+ expect ( response . statusCode ) . toEqual ( 202 ) ;
1032
+ // Cleanup
1033
+ spyApp . print . calls . reset ( ) ;
1034
+ done ( ) ;
1035
+ } ) ;
1036
+ } ) ;
1037
+ } ) ;
1038
+ } ) ;
1039
+
1020
1040
describe ( 'filters (report level)' , function ( ) {
1021
1041
it ( 'GET /report/filters returns 200 with body as array of filters' , function ( done ) {
1022
1042
// Arrange
@@ -2026,6 +2046,36 @@ describe('SDK-to-HPM', function () {
2026
2046
} ) ;
2027
2047
} ) ;
2028
2048
2049
+ describe ( 'print' , function ( ) {
2050
+ it ( 'report.print() sends POST /report/print' , function ( ) {
2051
+ // Arrange
2052
+ spyHpm . post . and . returnValue ( Promise . resolve ( {
2053
+ body : { }
2054
+ } ) ) ;
2055
+
2056
+ // Act
2057
+ report . print ( ) ;
2058
+
2059
+ // Assert
2060
+ expect ( spyHpm . post ) . toHaveBeenCalledWith ( '/report/print' , null , { uid : uniqueId } , iframe . contentWindow ) ;
2061
+ } ) ;
2062
+
2063
+ it ( 'report.print() returns promise that resolves if the request is accepted' , function ( done ) {
2064
+ // Arrange
2065
+ spyHpm . post . and . returnValue ( Promise . resolve ( {
2066
+ body : { }
2067
+ } ) ) ;
2068
+
2069
+ // Act
2070
+ report . print ( )
2071
+ . then ( ( ) => {
2072
+ // Assert
2073
+ expect ( spyHpm . post ) . toHaveBeenCalledWith ( '/report/print' , null , { uid : uniqueId } , iframe . contentWindow ) ;
2074
+ done ( ) ;
2075
+ } ) ;
2076
+ } ) ;
2077
+ } ) ;
2078
+
2029
2079
describe ( 'settings' , function ( ) {
2030
2080
it ( 'report.updateSettings(settings) sends PATCH /report/settings with settings object' , function ( ) {
2031
2081
// Arrange
@@ -3064,6 +3114,24 @@ describe('SDK-to-MockApp', function () {
3064
3114
} ) ;
3065
3115
} ) ;
3066
3116
3117
+ describe ( 'print' , function ( ) {
3118
+ it ( 'report.print() returns promise that resolves with null if the report print command was accepted' , function ( done ) {
3119
+ // Arrange
3120
+ iframeLoaded
3121
+ . then ( ( ) => {
3122
+ spyApp . print . and . returnValue ( Promise . resolve ( null ) ) ;
3123
+ // Act
3124
+ report . print ( )
3125
+ . then ( response => {
3126
+ // Assert
3127
+ expect ( spyApp . print ) . toHaveBeenCalled ( ) ;
3128
+ expect ( response ) . toEqual ( undefined ) ;
3129
+ done ( ) ;
3130
+ } ) ;
3131
+ } ) ;
3132
+ } ) ;
3133
+ } ) ;
3134
+
3067
3135
describe ( 'settings' , function ( ) {
3068
3136
it ( 'report.updateSettings(setting) returns promise that rejects with validation error if object is invalid' , function ( done ) {
3069
3137
// Arrange
0 commit comments