livekit-server-sdk
Version:
Server-side SDK for LiveKit
31 lines (27 loc) • 889 B
text/typescript
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { TrackSource } from '@livekit/protocol';
import { describe, expect, it } from 'vitest';
import { ClaimGrants, VideoGrant, claimsToJwtPayload } from './grants';
describe('ClaimGrants are parsed correctly', () => {
it('parses TrackSource correctly to strings', () => {
const grant: VideoGrant = {
canPublishSources: [
TrackSource.CAMERA,
TrackSource.MICROPHONE,
TrackSource.SCREEN_SHARE,
TrackSource.SCREEN_SHARE_AUDIO,
],
};
const claim: ClaimGrants = { video: grant };
const jwtPayload = claimsToJwtPayload(claim);
expect(jwtPayload.video).toBeTypeOf('object');
expect(jwtPayload.video?.canPublishSources).toEqual([
'camera',
'microphone',
'screen_share',
'screen_share_audio',
]);
});
});