import { HostMetadataResponseModel, HostMetadataResponseSchema, } from './host-metadata-response.model'; import { HostSchema } from './host.model'; describe('HostMetadataResponse', () => { describe('#toSchema', () => { it('should build a schema object from HostSchema', () => { const hostSchema: HostSchema = { billing: { account_type: 'free', end_date: 'Tue, 03 Nov 2020 22:43:13 GMT', minutes: 100, payments: [], }, core_configuration: { editor_configuration: {}, media_configuration: { media: [], media_types: [], }, }, created_at: 'Wed, 21 Oct 2020 02:04:44 GMT', credentials: [ { key: 'test-credential-key', }, ], identification: { email: 'test-email', family_name: 'test-family-name', given_name: 'test-given-name', issuer_metadata: {}, nickname: 'test-nickname', picture: 'test-picture', sub: 'test-sub', updated_at: 'test-data', }, owner: { client_id: 'test-client', user_id: 'test-user', }, schema_version: 1, stream_configuration: { authentication: { stream_password: 'test-pass', }, description: 'Test description', interaction_library: [ { group_id: 'test-group-id', group_name: 'test-group-name', // TODO: Eventually need better typing/tests around // this metadata field metadata: [], }, ], limits: { maximum_attendees: 27, maximum_streams_per_day: 23, maximum_time_per_stream: 88, }, options: { attendee: { enable_2fa: false, enable_camera: false, enable_chat: false, enable_microphone: false, enable_multiple_hosts: false, enable_password: false, enable_private_messages: false, }, host: { enable_camera: true, enable_microphone: true, }, }, stream_id: 1234, stream_secret: 'redacted', stream_slug: 'test-slug', title: 'Test Title', }, }; const hostMetadataResponseSchema: HostMetadataResponseSchema = { billing: { account_type: 'free', end_date: 'Tue, 03 Nov 2020 22:43:13 GMT', minutes: 100, }, core_configuration: { editor_configuration: {}, media_configuration: { media: [], media_types: [], }, }, created_at: 'Wed, 21 Oct 2020 02:04:44 GMT', identification: { email: 'test-email', family_name: 'test-family-name', given_name: 'test-given-name', }, stream_configuration: { authentication: { stream_password: 'test-pass', }, description: 'Test description', interaction_library: [ { group_id: 'test-group-id', group_name: 'test-group-name', // TODO: Eventually need better typing/tests around // this metadata field metadata: [], }, ], limits: { maximum_attendees: 27, maximum_streams_per_day: 23, maximum_time_per_stream: 88, }, options: { attendee: { enable_2fa: false, enable_camera: false, enable_chat: false, enable_microphone: false, enable_multiple_hosts: false, enable_password: false, enable_private_messages: false, }, host: { enable_camera: true, enable_microphone: true, }, }, stream_id: 1234, stream_slug: 'test-slug', title: 'Test Title', }, }; process.env.MAXIMUM_ATTENDEES_PER_STREAM = '30'; const model = new HostMetadataResponseModel(hostSchema); const newSchema = model.toSchema(); expect(newSchema).toStrictEqual(hostMetadataResponseSchema); }); }); });