<commit_before>const mockHttp = jest.genMockFromModule('../common/http');
jest.mock('../common/http', () => mockHttp);

const { api } = require('.'); // need to use require because of jest mocks being weird

describe('api', () => {
  beforeEach(() => {
    mockHttp.get = jest.fn();
    mockHttp.post = jest.fn();
    mockHttp.postForm = jest.fn();
    mockHttp.put = jest.fn();
    mockHttp.patch = jest.fn();
    mockHttp.simpleFetch = jest.fn();
  });

  it('can authenticate with a phone number', () => {
    const phoneNumber = '1234567';
    const controlCode = '123123123';
    mockHttp.post.mockImplementationOnce(() =>
      Promise.resolve({
        challengeCode: controlCode,
      }),
    );
    expect(mockHttp.post).not.toHaveBeenCalled();
    return api.authenticateWithPhoneNumber(phoneNumber).then(givenControlCode => {
      expect(givenControlCode).toBe(controlCode);
      expect(mockHttp.post).toHaveBeenCalledTimes(1);
      expect(mockHttp.post).toHaveBeenCalledWith('/authenticate', {
        phoneNumber,
      });
    });
  });

  it('can authenticate with identity code', () => {
    const identityCode = '1223445567';
    const controlCode = '123123123';
    mockHttp.post.mockImplementationOnce(() =>
      Promise.resolve({
        challengeCode: controlCode,
      }),
    );
    expect(mockHttp.post).not.toHaveBeenCalled();
    return api.authenticateWithIdCode(identityCode).then(givenControlCode => {
      expect(givenControlCode).toBe(controlCode);
      expect(mockHttp.post).toHaveBeenCalledTimes(1);
      expect(mockHttp.post).toHaveBeenCalledWith('/authenticate', {
        identityCode,
      });
    });
  });
<commit_msg>Fixed test<commit_after>const mockHttp = jest.genMockFromModule('../common/http');
jest.mock('../common/http', () => mockHttp);

const { api } = require('.'); // need to use require because of jest mocks being weird

describe('api', () => {
  beforeEach(() => {
    mockHttp.get = jest.fn();
    mockHttp.post = jest.fn();
    mockHttp.postForm = jest.fn();
    mockHttp.put = jest.fn();
    mockHttp.patch = jest.fn();
    mockHttp.simpleFetch = jest.fn();
  });

  it('can authenticate with a phone number', () => {
    const phoneNumber = '1234567';
    const controlCode = '123123123';
    mockHttp.post.mockImplementationOnce(() =>
      Promise.resolve({
        challengeCode: controlCode,
      }),
    );
    expect(mockHttp.post).not.toHaveBeenCalled();
    return api.authenticateWithPhoneNumber(phoneNumber).then(givenControlCode => {
      expect(givenControlCode).toBe(controlCode);
      expect(mockHttp.post).toHaveBeenCalledTimes(1);
      expect(mockHttp.post).toHaveBeenCalledWith('/authenticate', {
        value: phoneNumber,
        type: 'MOBILE_ID',
      });
    });
  });

  it('can authenticate with identity code', () => {
    const identityCode = '1223445567';
    const controlCode = '123123123';
    mockHttp.post.mockImplementationOnce(() =>
      Promise.resolve({
        challengeCode: controlCode,
      }),
    );
    expect(mockHttp.post).not.toHaveBeenCalled();
    return api.authenticateWithIdCode(identityCode).then(givenControlCode => {
      expect(givenControlCode).toBe(controlCode);
      expect(mockHttp.post).toHaveBeenCalledTimes(1);
      expect(mockHttp.post).toHaveBeenCalledWith('/authenticate', {
        value: identityCode,
        type: 'SMART_ID',
      });
    });
  });

{'fraction_non_alphanumeric': 0.1559741024131842, 'fraction_numerical': 0.02177751618599176, 'mean_word_length': 3.3688946015424164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '5888408', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1016, 'n_words': 161}