<commit_before><commit_msg>Added ssrReducer tests<commit_after>import { createSuccessAction } from '../actions';
import ssrReducer from './ssr-reducer';

describe('reducers', () => {
  describe('ssrReducer', () => {
    it('returns empty array as default state', () => {
      expect(ssrReducer(undefined, {}, null)).toEqual([]);
    });

    it('doesnt do anything if ssr option is falsy', () => {
      const state = [];
      expect(ssrReducer(state, {}, null)).toBe(state);
    });

    it('appends request action type for success response when ssr option is server', () => {
      expect(
        ssrReducer(
          ['REQUEST'],
          createSuccessAction(
            { type: 'REQUEST', request: { url: '/' } },
            'data',
          ),
          'server',
        ),
      ).toEqual(['REQUEST', 'REQUEST']);
    });

    it('removes request action type for matching request action with ssrResponse when ssr option is client', () => {
      expect(
        ssrReducer(
          ['REQUEST', 'REQUEST'],

          {
            type: 'REQUEST',
            request: { url: '/' },
            meta: { ssrResponse: { data: 'data' } },
          },

          'client',
        ),
      ).toEqual(['REQUEST']);
    });

    it('doesnt do anything for not matching request action with ssrResponse when ssr option is client', () => {
      expect(
        ssrReducer(
          ['REQUEST', 'REQUEST'],

          {
            type: 'REQUEST2',
            request: { url: '/' },
            meta: { ssrResponse: { data: 'data' } },
          },

          'client',
        ),
      ).toEqual(['REQUEST', 'REQUEST']);
    });
  });
});
{'fraction_non_alphanumeric': 0.1689884918231375, 'fraction_numerical': 0.0006056935190793458, 'mean_word_length': 1.9447415329768272, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4822271', 'n_tokens_mistral': 472, 'n_tokens_neox': 457, 'n_words': 115}