File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
packages/scramjet/packages/runway/src/tests Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -90,4 +90,41 @@ export default [
9090 } ) ;
9191 } ,
9292 } ) ,
93+ serverTest ( {
94+ name : "linkheader-next-prev-xhr" ,
95+ start : async ( server , port ) => {
96+ const link = `<http://localhost:${ port } /page2>; rel="next", <http://localhost:${ port } /page0>; rel="prev"` ;
97+ server . on ( "request" , ( req , res ) => {
98+ if ( req . url === "/" ) {
99+ res . writeHead ( 200 , {
100+ "Content-Type" : "text/html" ,
101+ } ) ;
102+ res . end ( `
103+ <script>
104+ const xhr = new XMLHttpRequest();
105+ xhr.open("GET", "/page1");
106+ xhr.onload = () => {
107+ let next = xhr.getResponseHeader("Link");
108+ const expected = '${ link } ';
109+ if (next === expected) {
110+ __testPass("next link header is correct (xhr)");
111+ } else {
112+ __testFail("next link header is incorrect (xhr)", { actual: next, expected: expected });
113+ }
114+ };
115+ xhr.send();
116+ </script>
117+ ` ) ;
118+ } else if ( req . url === "/page1" ) {
119+ res . writeHead ( 200 , {
120+ Link : link ,
121+ } ) ;
122+ res . end ( "Page 1" ) ;
123+ } else {
124+ res . writeHead ( 404 ) ;
125+ res . end ( "Not found" ) ;
126+ }
127+ } ) ;
128+ } ,
129+ } ) ,
93130] ;
You can’t perform that action at this time.
0 commit comments