summaryrefslogtreecommitdiff
path: root/spec/frontend/repository/utils/commit_spec.js
blob: 65728e9cb24b152c2c757c7ba8d7e4fd287d1762 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { normalizeData } from '~/repository/utils/commit';

const mockData = [
  {
    commit: {
      id: '123',
      message: 'testing message',
      committed_date: '2019-01-01',
    },
    commit_path: `https://test.com`,
    commit_title_html: 'testing message',
    file_name: 'index.js',
  },
];

describe('normalizeData', () => {
  it('normalizes data into LogTreeCommit object', () => {
    expect(normalizeData(mockData, '/')).toEqual([
      {
        sha: '123',
        message: 'testing message',
        committedDate: '2019-01-01',
        commitPath: 'https://test.com',
        fileName: 'index.js',
        filePath: '/index.js',
        titleHtml: 'testing message',
        __typename: 'LogTreeCommit',
      },
    ]);
  });
});