11import { writeMetadata , readMetadata , metadataFilename } from '../../src/utils/metadata.js' ;
2+ import { html } from '../test-data/offline-sites/gmod-wiki/recent-changes.js' ;
3+ import fetchMock from "jest-fetch-mock" ;
24import path from 'path' ;
35import fs from 'fs' ;
46import os from 'os' ;
@@ -16,19 +18,22 @@ describe('Metadata', () => {
1618 } ) ;
1719
1820 it ( 'should be able to write metadata' , async ( ) => {
21+ fetchMock . mockResponseOnce ( html , { url : 'https://wiki.facepunch.com/gmod/~recentchanges' } ) ;
1922 await writeMetadata ( 'https://wiki.facepunch.com/gmod' , outputDirectory ) ;
2023
2124 expect ( fs . existsSync ( path . join ( outputDirectory , metadataFilename ) ) ) . toBeTruthy ( ) ;
2225 } ) ;
2326
2427 it ( 'should be able to write metadata to a non-existing directory' , async ( ) => {
28+ fetchMock . mockResponseOnce ( html , { url : 'https://wiki.facepunch.com/gmod/~recentchanges' } ) ;
2529 const nonExistingDirectory = path . join ( outputDirectory , 'non-existing' ) ;
2630 await writeMetadata ( 'https://wiki.facepunch.com/gmod' , nonExistingDirectory ) ;
2731
2832 expect ( fs . existsSync ( path . join ( nonExistingDirectory , metadataFilename ) ) ) . toBeTruthy ( ) ;
2933 } ) ;
3034
3135 it ( 'should be able to read metadata' , async ( ) => {
36+ fetchMock . mockResponseOnce ( html , { url : 'https://wiki.facepunch.com/gmod/~recentchanges' } ) ;
3237 await writeMetadata ( 'https://wiki.facepunch.com/gmod' , outputDirectory ) ;
3338 const metadata = await readMetadata ( outputDirectory ) ;
3439
0 commit comments