-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfirst_frame.test.js
41 lines (32 loc) · 1.27 KB
/
first_frame.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @jest-environment jsdom
*/
const $ = require('jquery');
global.$ = $;
const module = require('planttracer')
const first_frame_url = module.first_frame_url
describe('first_frame_url', () => {
// Mock API base URL and API key
const API_BASE = 'https://planttracer.com';
const api_key = 'abcdefghijklmnopqrstuvwxyz';
const movie_id = '600';
// Mock Date object to control the timestamp
beforeEach(() => {
global.API_BASE = API_BASE;
global.api_key = api_key;
});
test('should return a URL containing API base, api_key, and movie_id', () => {
const result = first_frame_url(movie_id);
// Check that the URL contains the base, api_key, movie_id, frame_number, and format
expect(result).toContain(`${API_BASE}api/get-frame?api_key=${api_key}&movie_id=${movie_id}&frame_number=0&format=jpeg`);
});
test('should include a timestamp in the URL', () => {
const result = first_frame_url(movie_id);
// Use regex to check that t= is followed by a numeric timestamp
expect(result).toMatch(/t=\d+/);
});
test('should include the correct movie ID in the URL', () => {
const result = first_frame_url('test_movie');
expect(result).toContain('movie_id=test_movie');
});
});