-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add unit tests for newsroom-videos scripts (#1988)
Co-authored-by: akshatnema <[email protected]>%0ACo-authored-by: Akshat Nema <[email protected]>%0ACo-authored-by: akshatnema <[email protected]>
- Loading branch information
1 parent
4d92a68
commit c175f86
Showing
3 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"summary": "Event 1", | ||
"start": { | ||
"dateTime": "2023-07-23T10:00:00Z" | ||
}, | ||
"htmlLink": "https://www.example.com/event1" | ||
}, | ||
{ | ||
"summary": "Event 2", | ||
"start": { | ||
"dateTime": "2023-07-24T15:30:00Z" | ||
}, | ||
"htmlLink": "https://www.example.com/event2" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { buildNewsroomVideos } from '../../../scripts/build-newsroom-videos'; | ||
|
||
describe('Newsroom Videos', () => { | ||
// eslint-disable-next-line cypress/no-async-tests | ||
it('fetches and saves newsroom videos', async () => { | ||
// Define the data that the API should return (stubbed response) | ||
const stubbedResponse = { | ||
items: [ | ||
{ | ||
snippet: { | ||
thumbnails: { | ||
high: { | ||
url: 'https://example.com/image.jpg', | ||
}, | ||
}, | ||
title: 'Test Video 1', | ||
description: 'This is a test video 1', | ||
}, | ||
id: { | ||
videoId: 'videoId1', | ||
}, | ||
}, | ||
{ | ||
snippet: { | ||
thumbnails: { | ||
high: { | ||
url: 'https://example.com/image2.jpg', | ||
}, | ||
}, | ||
title: 'Test Video 2', | ||
description: 'This is a test video 2', | ||
}, | ||
id: { | ||
videoId: 'videoId2', | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
// Intercept the API request and stub the response | ||
cy.intercept('GET', 'https://youtube.googleapis.com/youtube/v3/search*', { | ||
statusCode: 200, | ||
body: stubbedResponse, | ||
}).as('getYoutubeVideos'); | ||
|
||
// Manually trigger the function | ||
await buildNewsroomVideos().then((videoData) => { | ||
expect(videoData).to.exist; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters