@@ -37,7 +37,7 @@ describe("login", () => {
37
37
expect ( limiter . removeToken ( ) ) . toBe ( false )
38
38
} )
39
39
} )
40
- describe . only ( "/" , ( ) => {
40
+ describe ( "/login " , ( ) => {
41
41
let _codeServer : httpserver . HttpServer | undefined
42
42
function codeServer ( ) : httpserver . HttpServer {
43
43
if ( ! _codeServer ) {
@@ -60,20 +60,18 @@ describe("login", () => {
60
60
process . env . PASSWORD = previousEnvPassword
61
61
} )
62
62
63
- // TODO@jsjoeio fix this name of test
64
- it ( "should return an error" , async ( ) => {
65
- const resp = await codeServer ( ) . fetch ( "/" , { method : "POST" } )
66
- // TODO@jsjoeio um not sure why we are getting a 404
67
- expect ( resp . status ) . toBe ( 404 )
63
+ it ( "should return escaped HTML with 'Missing password' message" , async ( ) => {
64
+ const resp = await codeServer ( ) . fetch ( "/login" , { method : "POST" } )
68
65
69
- try {
70
- const content = JSON . parse ( await resp . text ( ) )
66
+ expect ( resp . status ) . toBe ( 200 )
71
67
72
- expect ( content . error ) . toMatch ( "ENOENT" )
73
- } catch ( error ) {
74
- console . log ( "heree" )
75
- console . error ( error )
76
- }
68
+ const htmlContent = await resp . text ( )
69
+
70
+ expect ( htmlContent ) . not . toContain ( ">" )
71
+ expect ( htmlContent ) . not . toContain ( "<" )
72
+ expect ( htmlContent ) . not . toContain ( '"' )
73
+ expect ( htmlContent ) . not . toContain ( "'" )
74
+ expect ( htmlContent ) . toContain ( "<div class="error">Missing password</div>" )
77
75
} )
78
76
} )
79
77
} )
0 commit comments