diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-18 18:10:10 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-18 18:10:10 +0000 |
commit | 85f7fa54f404f28b0f351c2be0f7a6e9d74fe65f (patch) | |
tree | b0f4a7578f374185fb649be904641cd79baa2ca0 /spec/frontend/snippets/utils/blob_spec.js | |
parent | a8a9c520128bffc1157db4dc1beaa215fc731c80 (diff) | |
download | gitlab-ce-85f7fa54f404f28b0f351c2be0f7a6e9d74fe65f.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/snippets/utils/blob_spec.js')
-rw-r--r-- | spec/frontend/snippets/utils/blob_spec.js | 73 |
1 files changed, 1 insertions, 72 deletions
diff --git a/spec/frontend/snippets/utils/blob_spec.js b/spec/frontend/snippets/utils/blob_spec.js index ba39b9fec36..c20cf2e6102 100644 --- a/spec/frontend/snippets/utils/blob_spec.js +++ b/spec/frontend/snippets/utils/blob_spec.js @@ -1,19 +1,12 @@ import { cloneDeep } from 'lodash'; -import { - SNIPPET_BLOB_ACTION_CREATE, - SNIPPET_BLOB_ACTION_UPDATE, - SNIPPET_BLOB_ACTION_MOVE, - SNIPPET_BLOB_ACTION_DELETE, -} from '~/snippets/constants'; import { decorateBlob, createBlob, diffAll } from '~/snippets/utils/blob'; +import { testEntries, createBlobsFromTestEntries } from '../test_utils'; jest.mock('lodash/uniqueId', () => arg => `${arg}fakeUniqueId`); const TEST_RAW_BLOB = { rawPath: '/test/blob/7/raw', }; -const CONTENT_1 = 'Lorem ipsum dolar\nSit amit\n\nGoodbye!\n'; -const CONTENT_2 = 'Lorem ipsum dolar sit amit.\n\nGoodbye!\n'; describe('~/snippets/utils/blob', () => { describe('decorateBlob', () => { @@ -41,70 +34,6 @@ describe('~/snippets/utils/blob', () => { }); describe('diffAll', () => { - // This object contains entries that contain an expected "diff" and the `id` - // or `origContent` that should be used to generate the expected diff. - const testEntries = { - created: { - id: 'blob_1', - diff: { - action: SNIPPET_BLOB_ACTION_CREATE, - filePath: '/new/file', - previousPath: '/new/file', - content: CONTENT_1, - }, - }, - deleted: { - id: 'blob_2', - diff: { - action: SNIPPET_BLOB_ACTION_DELETE, - filePath: '/src/delete/me', - previousPath: '/src/delete/me', - content: CONTENT_1, - }, - }, - updated: { - id: 'blob_3', - origContent: CONTENT_1, - diff: { - action: SNIPPET_BLOB_ACTION_UPDATE, - filePath: '/lorem.md', - previousPath: '/lorem.md', - content: CONTENT_2, - }, - }, - renamed: { - id: 'blob_4', - diff: { - action: SNIPPET_BLOB_ACTION_MOVE, - filePath: '/dolar.md', - previousPath: '/ipsum.md', - content: CONTENT_1, - }, - }, - renamedAndUpdated: { - id: 'blob_5', - origContent: CONTENT_1, - diff: { - action: SNIPPET_BLOB_ACTION_MOVE, - filePath: '/sit.md', - previousPath: '/sit/amit.md', - content: CONTENT_2, - }, - }, - }; - const createBlobsFromTestEntries = (entries, isOrig = false) => - entries.reduce( - (acc, { id, diff, origContent }) => - Object.assign(acc, { - [id]: { - id, - content: isOrig && origContent ? origContent : diff.content, - path: isOrig ? diff.previousPath : diff.filePath, - }, - }), - {}, - ); - it('should create diff from original files', () => { const origBlobs = createBlobsFromTestEntries( [ |