1- import { WebSocketExpress } from 'websocket-express' ;
21import request from 'superwstest' ;
32import { TestLogger } from './TestLogger' ;
43import { testConfig } from './testConfig' ;
5- import { testServerRunner , addressToString } from './testServerRunner' ;
4+ import { testServerRunner } from './testServerRunner' ;
65import { appFactory } from '../app' ;
6+ import { getAddressURL , requestHandler , WebListener } from 'web-listener' ;
77
88describe ( 'API static content' , ( ) => {
99 describe ( 'Embedded' , ( ) => {
@@ -18,7 +18,7 @@ describe('API static content', () => {
1818 . get ( '/' )
1919 . expect ( 200 )
2020 . expect ( 'Content-Type' , / t e x t \/ h t m l / )
21- . expect ( 'Vary' , 'Accept-Encoding ' ) ;
21+ . expect ( 'Vary' , 'accept-encoding ' ) ;
2222
2323 expect ( response . text ) . toContain ( '<title>Example Static Resource</title>' ) ;
2424 } ) ;
@@ -43,7 +43,7 @@ describe('API static content', () => {
4343 . expect ( 200 )
4444 . expect ( 'Content-Type' , / t e x t \/ h t m l / )
4545 . expect ( 'Content-Encoding' , 'gzip' )
46- . expect ( 'Vary' , 'Accept-Encoding ' ) ;
46+ . expect ( 'Vary' , 'accept-encoding ' ) ;
4747
4848 expect ( response . text ) . toContain (
4949 '<title>Example Compressed Static Resource</title>' ,
@@ -57,7 +57,7 @@ describe('API static content', () => {
5757 . get ( '/foobar' )
5858 . expect ( 200 )
5959 . expect ( 'Content-Type' , / t e x t \/ h t m l / )
60- . expect ( 'Vary' , 'Accept-Encoding ' ) ;
60+ . expect ( 'Vary' , 'accept-encoding ' ) ;
6161
6262 expect ( response . text ) . toContain ( '<title>Example Static Resource</title>' ) ;
6363 } ) ;
@@ -71,7 +71,7 @@ describe('API static content', () => {
7171 . expect ( 200 )
7272 . expect ( 'Content-Type' , / t e x t \/ h t m l / )
7373 . expect ( 'Content-Encoding' , 'gzip' )
74- . expect ( 'Vary' , 'Accept-Encoding ' ) ;
74+ . expect ( 'Vary' , 'accept-encoding ' ) ;
7575
7676 expect ( response . text ) . toContain ( '<title>Example Static Resource</title>' ) ;
7777 } ) ;
@@ -84,7 +84,7 @@ describe('API static content', () => {
8484 . expect ( 200 ) ;
8585
8686 const vary = response . header [ 'vary' ] || '' ;
87- expect ( vary ) . not ( toContain ( 'Content-Type ' ) ) ;
87+ expect ( vary ) . not ( toContain ( 'content-type ' ) ) ;
8888 } ) ;
8989
9090 it ( 'adds common headers' , async ( props ) => {
@@ -134,18 +134,17 @@ describe('API static content', () => {
134134
135135 describe ( 'Proxy' , ( ) => {
136136 const PROXY = testServerRunner ( ( ) => {
137- const proxyApp = new WebSocketExpress ( ) ;
138- proxyApp . get ( '/' , ( _ , res ) => {
139- res . send ( 'proxied content here' ) ;
140- } ) ;
141- return { run : proxyApp . createServer ( ) } ;
137+ const proxyApp = new WebListener (
138+ requestHandler ( ( _ , res ) => res . end ( 'proxied content here' ) ) ,
139+ ) ;
140+ return { run : proxyApp } ;
142141 } ) ;
143142
144143 const PROPS = testServerRunner ( async ( getTyped ) => ( {
145144 run : await appFactory (
146145 new TestLogger ( ) ,
147146 testConfig ( {
148- forwardHost : addressToString ( getTyped ( PROXY ) . server . address ( ) ) ,
147+ forwardHost : getAddressURL ( getTyped ( PROXY ) . server . address ( ) ) ,
149148 } ) ,
150149 ) ,
151150 } ) ) ;
0 commit comments