Add mock data and unit tests for Channels and Members APIs
This commit is contained in:
72
test/unit/apis/Reporting/ReportKind.test.ts
Normal file
72
test/unit/apis/Reporting/ReportKind.test.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import {describe, expect, it} from 'bun:test';
|
||||
import {ReportKind, ReportKindMapping, type ReportKindType} from '../../../../src/apis/Reporting/ReportKind';
|
||||
|
||||
describe('ReportKind', () => {
|
||||
describe('when accessing enum values', () => {
|
||||
it('should have Publishing as 0', () => {
|
||||
expect(ReportKind.Publishing).toBe(0);
|
||||
});
|
||||
|
||||
it('should have Viewing as 1', () => {
|
||||
expect(ReportKind.Viewing).toBe(1);
|
||||
});
|
||||
|
||||
it('should have Ingest as 2', () => {
|
||||
expect(ReportKind.Ingest).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ReportKindMapping', () => {
|
||||
describe('when converting from type string to enum', () => {
|
||||
it('should convert "Publishing" to ReportKind.Publishing', () => {
|
||||
const result = ReportKindMapping.convertReportKindTypeToReportKind('Publishing');
|
||||
expect(result).toBe(ReportKind.Publishing);
|
||||
});
|
||||
|
||||
it('should convert "Viewing" to ReportKind.Viewing', () => {
|
||||
const result = ReportKindMapping.convertReportKindTypeToReportKind('Viewing');
|
||||
expect(result).toBe(ReportKind.Viewing);
|
||||
});
|
||||
|
||||
it('should convert "IngestReport" to ReportKind.Ingest', () => {
|
||||
const result = ReportKindMapping.convertReportKindTypeToReportKind('IngestReport');
|
||||
expect(result).toBe(ReportKind.Ingest);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when converting from enum to type string', () => {
|
||||
it('should convert ReportKind.Publishing to "Publishing"', () => {
|
||||
const result = ReportKindMapping.convertReportKindToReportKindType(ReportKind.Publishing);
|
||||
expect(result).toBe('Publishing');
|
||||
});
|
||||
|
||||
it('should convert ReportKind.Viewing to "Viewing"', () => {
|
||||
const result = ReportKindMapping.convertReportKindToReportKindType(ReportKind.Viewing);
|
||||
expect(result).toBe('Viewing');
|
||||
});
|
||||
|
||||
it('should convert ReportKind.Ingest to "IngestReport"', () => {
|
||||
const result = ReportKindMapping.convertReportKindToReportKindType(ReportKind.Ingest);
|
||||
expect(result).toBe('IngestReport');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when performing roundtrip conversions', () => {
|
||||
const reportKindTypes: ReportKindType[] = ['Publishing', 'Viewing', 'IngestReport'];
|
||||
|
||||
it.each(reportKindTypes)('should preserve %s through type->enum->type conversion', kindType => {
|
||||
const enumValue = ReportKindMapping.convertReportKindTypeToReportKind(kindType);
|
||||
const backToType = ReportKindMapping.convertReportKindToReportKindType(enumValue);
|
||||
expect(backToType).toBe(kindType);
|
||||
});
|
||||
|
||||
const reportKinds = [ReportKind.Publishing, ReportKind.Viewing, ReportKind.Ingest];
|
||||
|
||||
it.each(reportKinds)('should preserve enum %d through enum->type->enum conversion', kindEnum => {
|
||||
const typeValue = ReportKindMapping.convertReportKindToReportKindType(kindEnum);
|
||||
const backToEnum = ReportKindMapping.convertReportKindTypeToReportKind(typeValue);
|
||||
expect(backToEnum).toBe(kindEnum);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user