<commit_before>jest.mock('../../gql');

import choosingReply from '../choosingReply';
import apiResult from '../__fixtures__/choosingReply';
import gql from '../../gql';

it('should select reply by replyId', async () => {
  gql.__push(apiResult.oneReply);

  const params = {
    data: {
      searchedText: '貼圖',
      foundArticleIds: [
        'AWDZYXxAyCdS-nWhumlz',
        '5483323992880-rumor',
        'AV-Urc0jyCdS-nWhuity',
        'AVsh8u7StKp96s659Dgq',
      ],
      selectedArticleId: 'AWDZYXxAyCdS-nWhumlz',
      foundReplies: [{ id: 'AWDZeeV0yCdS-nWhuml8', replyConnectionId: null }],
    },
    state: 'CHOOSING_REPLY',
    event: {
      type: 'postback',
      input: 1,
      timestamp: 1518964687709,
      postback: { data: '{"input":1,"issuedAt":1518964675191}' },
    },
    issuedAt: 1518964688672,
    userId: 'Uaddc74df8a3a176b901d9d648b0fc4fe',
    replies: [
      {
        type: 'text',
        text: '這篇文章有：\n0 則回應認為其 ❌ 含有不實訊息\n0 則回應認為其 ⭕ 含有真實訊息\n0 則回應認為其 💬 含有個人意見\n1 則回應認為其 ⚠️️ 不在查證範圍\n',
      },
    ],
    isSkipUser: false,
  };

  expect(await choosingReply(params)).toMatchSnapshot();
});

it('should handle invalid reply ids', async () => {
  gql.__push(apiResult.oneReply);

  const params = {
    data: {
      searchedText: '貼圖',
      foundArticleIds: [
        'AWDZYXxAyCdS-nWhumlz',
        '5483323992880-rumor',
        'AV-Urc0jyCdS-nWhuity',
        'AVsh8u7StKp96s659Dgq',
      ],
      selectedArticleId: 'AWDZYXxAyCdS-nWhumlz',
      foundReplies: [{ id: 'AWDZeeV0yCdS-nWhuml8', replyConnectionId: null }],
    },
    state: 'CHOOSING_REPLY',
    event: {
      type: 'text',
      input: '123',
      timestamp: 1518964687709,
    },
    issuedAt: 1518964688672,
    userId: 'Uaddc74df8a3a176b901d9d648b0fc4fe',
    replies: [
      {
        type: 'text',
        text: '這篇文章有：\n0 則回應認為其 ❌ 含有不實訊息\n0 則回應認為其 ⭕ 含有真實訊息\n0 則回應認為其 💬 含有個人意見\n1 則回應認為其 ⚠️️ 不在查證範圍\n',
      },
    ],
    isSkipUser: false,
  };

  expect(await choosingReply(params)).toMatchSnapshot();
});<commit_msg>Add omitted afterEach for choosingReply test<commit_after>jest.mock('../../gql');

import choosingReply from '../choosingReply';
import apiResult from '../__fixtures__/choosingReply';
import gql from '../../gql';

it('should select reply by replyId', async () => {
  gql.__push(apiResult.oneReply);

  const params = {
    data: {
      searchedText: '貼圖',
      foundArticleIds: [
        'AWDZYXxAyCdS-nWhumlz',
        '5483323992880-rumor',
        'AV-Urc0jyCdS-nWhuity',
        'AVsh8u7StKp96s659Dgq',
      ],
      selectedArticleId: 'AWDZYXxAyCdS-nWhumlz',
      foundReplies: [{ id: 'AWDZeeV0yCdS-nWhuml8', replyConnectionId: null }],
    },
    state: 'CHOOSING_REPLY',
    event: {
      type: 'postback',
      input: 1,
      timestamp: 1518964687709,
      postback: { data: '{"input":1,"issuedAt":1518964675191}' },
    },
    issuedAt: 1518964688672,
    userId: '<KEY>',
    replies: [
      {
        type: 'text',
        text: '這篇文章有：\n0 則回應認為其 ❌ 含有不實訊息\n0 則回應認為其 ⭕ 含有真實訊息\n0 則回應認為其 💬 含有個人意見\n1 則回應認為其 ⚠️️ 不在查證範圍\n',
      },
    ],
    isSkipUser: false,
  };

  expect(await choosingReply(params)).toMatchSnapshot();
});

it('should handle invalid reply ids', async () => {
  gql.__push(apiResult.oneReply);

  const params = {
    data: {
      searchedText: '貼圖',
      foundArticleIds: [
        'AWDZYXxAyCdS-nWhumlz',
        '5483323992880-rumor',
        'AV-Urc0jyCdS-nWhuity',
        'AVsh8u7StKp96s659Dgq',
      ],
      selectedArticleId: 'AWDZYXxAyCdS-nWhumlz',
      foundReplies: [{ id: 'AWDZeeV0yCdS-nWhuml8', replyConnectionId: null }],
    },
    state: 'CHOOSING_REPLY',
    event: {
      type: 'text',
      input: '123',
      timestamp: 1518964687709,
    },
    issuedAt: 1518964688672,
    userId: '<KEY>',
    replies: [
      {
        type: 'text',
        text: '這篇文章有：\n0 則回應認為其 ❌ 含有不實訊息\n0 則回應認為其 ⭕ 含有真實訊息\n0 則回應認為其 💬 含有個人意見\n1 則回應認為其 ⚠️️ 不在查證範圍\n',
      },
    ],
    isSkipUser: false,
  };

  expect(await choosingReply(params)).toMatchSnapshot();
});

afterEach(() => {
  gql.__reset();
});
{'fraction_non_alphanumeric': 0.15341326156104723, 'fraction_numerical': 0.0685099094690482, 'mean_word_length': 2.7062556663644606, 'pattern_counts': {'":': 4, '<': 5, '<?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': '1075056', 'n_tokens_mistral': 2001, 'n_tokens_neox': 1971, 'n_words': 271}