File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -59,11 +59,30 @@ test('page-loader', async () => {
5959 expect ( downloadedScript ) . toBe ( 'js {}' )
6060} )
6161
62- test ( 'page-loader no such directory ' , async ( ) => {
62+ test ( 'page-loader: network errors ' , async ( ) => {
6363 nock ( 'https://ru.hexlet.io' )
6464 . get ( '/courses' )
65+ . reply ( 404 )
66+ nock ( 'https://ru.hexlet.io' )
67+ . get ( '/assets/professions/nodejs.png' )
68+ . reply ( 500 )
69+
70+ await expect ( downloadPage ( 'https://ru.hexlet.io/courses' , tempDir ) )
71+ . rejects
72+ . toThrow ( 'Cant get https://ru.hexlet.io/courses - Request failed with status code 404' )
73+ await expect ( downloadPage ( 'https://ru.hexlet.io/assets/professions/nodejs.png' , tempDir ) )
74+ . rejects
75+ . toThrow ( 'Cant get https://ru.hexlet.io/assets/professions/nodejs.png - Request failed with status code 500' )
76+ } )
77+
78+ test ( 'page-loader: file operation errors' , async ( ) => {
79+ nock ( 'https://ru.hexlet.io' )
80+ . get ( '/courses' )
81+ . times ( 2 )
6582 . reply ( 200 , html )
6683
67- await expect ( downloadPage ( 'https://ru.hexlet.io/courses' , 'unexistingDir' ) )
68- . rejects . toThrow ( )
84+ await expect ( downloadPage ( 'https://ru.hexlet.io/courses' , '/unexisting' ) )
85+ . rejects . toThrow ( 'ERROR: No such output directory - /unexisting' )
86+ await expect ( downloadPage ( 'https://ru.hexlet.io/courses' , '/root' ) )
87+ . rejects . toThrow ( 'ERROR: No access to output directory - /root' )
6988} )
You can’t perform that action at this time.
0 commit comments