@financial-times/n-concept-ids
Version:
A place to store concept ids as constants
33 lines (26 loc) • 1.23 kB
JavaScript
const { data, getPodcastByConceptid } = require('../src/podcasts');
describe('getPodcastByConceptid()', () => {
test('Get podcast by concept ID', () => {
expect(getPodcastByConceptid('11379aab-8b8e-44c8-9153-10be6eaf3f50')).toHaveProperty('conceptId', '11379aab-8b8e-44c8-9153-10be6eaf3f50');
});
test('Get podcast 16x9 image URL by concept ID', () => {
expect(getPodcastByConceptid('11379aab-8b8e-44c8-9153-10be6eaf3f50')).toHaveProperty('image16x9', expect.stringMatching(/https:\/\/\w+/));
});
test('With unknown conceptId', () => {
expect(getPodcastByConceptid('00000000-0000-0000-0000-000000000000')).toBeUndefined();
});
test('With no arguments', () => {
expect(getPodcastByConceptid()).toBeUndefined();
});
});
describe('data', () => {
test('Check data structure', () => {
expect(data).toBeInstanceOf(Array);
expect(data[0]).toHaveProperty('conceptId', expect.stringMatching(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/));
expect(data[0]).toHaveProperty('image16x9', expect.stringMatching(/https:\/\/\w+/));
});
test('Check if all podcast concepts are unique', () => {
const uniqueConcepts = new Set(data.map((podcast) => podcast.conceptId));
expect(uniqueConcepts.size).toBe(data.length);
});
});