The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/dashboard-scene/saving/provisioned/utils/timestamp.test.ts

26 lines
979 B

import { generateTimestamp } from './timestamp';
describe('generateTimestamp', () => {
it('should generate a timestamp in the expected format', () => {
const timestamp = generateTimestamp();
// Check that the timestamp is a string
expect(typeof timestamp).toBe('string');
// Check that the timestamp follows the format YYYY-MM-DD-xxxxx
// where xxxxx is a random string of 5 alphabetic characters
expect(timestamp).toMatch(/^\d{4}-\d{2}-\d{2}-[a-zA-Z]{5}$/);
});
it('should generate unique timestamps', () => {
// Generate multiple timestamps and check that they're different
const timestamp1 = generateTimestamp();
const timestamp2 = generateTimestamp();
const timestamp3 = generateTimestamp();
// The date part might be the same, but the random part should make them different
expect(timestamp1).not.toBe(timestamp2);
expect(timestamp1).not.toBe(timestamp3);
expect(timestamp2).not.toBe(timestamp3);
});
});