slopus--happy
98e40dac97
CLI Smoke Test / smoke-test-linux (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-linux (24) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (24) (push) Has been cancelled
Expo App TypeScript typecheck / typecheck (push) Has been cancelled
52 行
1.7 KiB
TypeScript
52 行
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
getSessionRouteFromNotificationData,
|
|
getSessionRouteFromNotificationResponse,
|
|
} from './notificationRouting';
|
|
|
|
describe('getSessionRouteFromNotificationData', () => {
|
|
it('returns a session route when sessionId exists', () => {
|
|
expect(getSessionRouteFromNotificationData({ sessionId: 'session-123' })).toBe('/session/session-123');
|
|
});
|
|
|
|
it('encodes session ids that contain spaces', () => {
|
|
expect(getSessionRouteFromNotificationData({ sessionId: 'session 123' })).toBe('/session/session%20123');
|
|
});
|
|
|
|
it('returns null when sessionId is missing', () => {
|
|
expect(getSessionRouteFromNotificationData({ kind: 'done' })).toBeNull();
|
|
});
|
|
|
|
it('returns null for empty session ids', () => {
|
|
expect(getSessionRouteFromNotificationData({ sessionId: ' ' })).toBeNull();
|
|
});
|
|
|
|
it('uses a session url when present', () => {
|
|
expect(getSessionRouteFromNotificationData({ url: '/session/session-123' })).toBe('/session/session-123');
|
|
});
|
|
});
|
|
|
|
describe('getSessionRouteFromNotificationResponse', () => {
|
|
it('reads the route from content data', () => {
|
|
expect(getSessionRouteFromNotificationResponse({
|
|
notification: {
|
|
request: {
|
|
content: {
|
|
data: { sessionId: 'session-123' }
|
|
}
|
|
}
|
|
}
|
|
})).toBe('/session/session-123');
|
|
});
|
|
|
|
it('returns null when content data is missing', () => {
|
|
expect(getSessionRouteFromNotificationResponse({
|
|
notification: {
|
|
request: {
|
|
content: {}
|
|
}
|
|
}
|
|
})).toBeNull();
|
|
});
|
|
});
|