Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Dec 15, 2024
1 parent 628fa46 commit 20e0918
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,8 @@ export class QueryService {
private getRequestHandlerId(window: PerWindowState, isSubscription: boolean) {
const defaultRequestHandlerId = window.query.requestHandlerId ?? HTTP_HANDLER_ID;

if (isSubscription) {
if (!window.query.subscriptionUseDefaultRequestHandler) {
return window.query.subscriptionRequestHandlerId ?? WEBSOCKET_HANDLER_ID;
}
if (isSubscription && !window.query.subscriptionUseDefaultRequestHandler) {
return window.query.subscriptionRequestHandlerId ?? WEBSOCKET_HANDLER_ID;
}

return defaultRequestHandlerId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { describe } from '@jest/globals';
import { getInitialState } from './query.reducer';
import { AltairConfig, setAltairConfig } from 'altair-graphql-core/build/config';

describe('initialState', () => {
it('should return correct initialSubscriptionRequestHandlerId', () => {
const altairConfig = new AltairConfig({
initialSubscriptionRequestHandlerId: 'graphql-sse',
});
setAltairConfig(altairConfig);

const initialState = getInitialState();

expect(initialState.subscriptionRequestHandlerId).toBe('graphql-sse');
});
});

0 comments on commit 20e0918

Please sign in to comment.