mirror of
				https://github.com/public-transport/db-vendo-client.git
				synced 2025-11-04 10:06:32 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			681 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			681 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const WEEK = 7 * 24 * 60 * 60 * 1000;
 | 
						|
 | 
						|
const testRemarks = async (cfg) => {
 | 
						|
	const {
 | 
						|
		test: t,
 | 
						|
		fetchRemarks,
 | 
						|
		validate,
 | 
						|
		when,
 | 
						|
	} = cfg;
 | 
						|
 | 
						|
	const res = await fetchRemarks({
 | 
						|
		results: 10,
 | 
						|
		from: when,
 | 
						|
		to: new Date(when + WEEK),
 | 
						|
	});
 | 
						|
	const {
 | 
						|
		remarks,
 | 
						|
		realtimeDataUpdatedAt,
 | 
						|
	} = res;
 | 
						|
 | 
						|
	for (let i = 0; i < res.remarks.length; i++) {
 | 
						|
		const rem = res.remarks[i];
 | 
						|
		const name = `res.remarks[${i}]`;
 | 
						|
		validate(t, rem, 'remark', name);
 | 
						|
	}
 | 
						|
 | 
						|
	// most endpoints currently don't provide this info for remarks()
 | 
						|
	if (realtimeDataUpdatedAt !== null) {
 | 
						|
		validate(t, realtimeDataUpdatedAt, 'realtimeDataUpdatedAt', 'res.realtimeDataUpdatedAt');
 | 
						|
	}
 | 
						|
};
 | 
						|
 | 
						|
export {
 | 
						|
	testRemarks,
 | 
						|
};
 |