|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0; you may not use this file except in compliance with the Elastic License |
| 5 | + * 2.0. |
| 6 | + */ |
| 7 | + |
| 8 | +import { MAX_FILE_SIZE } from '../../common/constants'; |
| 9 | +import { createMockFilesSetup } from '@kbn/files-plugin/public/mocks'; |
| 10 | +import { registerCaseFileKinds } from '.'; |
| 11 | +import type { FilesConfig } from './types'; |
| 12 | + |
| 13 | +describe('ui files index', () => { |
| 14 | + describe('registerCaseFileKinds', () => { |
| 15 | + const mockFilesSetup = createMockFilesSetup(); |
| 16 | + |
| 17 | + beforeEach(() => { |
| 18 | + jest.clearAllMocks(); |
| 19 | + }); |
| 20 | + |
| 21 | + describe('allowedMimeTypes', () => { |
| 22 | + const config: FilesConfig = { |
| 23 | + allowedMimeTypes: ['abc'], |
| 24 | + maxSize: undefined, |
| 25 | + }; |
| 26 | + |
| 27 | + beforeEach(() => { |
| 28 | + registerCaseFileKinds(config, mockFilesSetup); |
| 29 | + }); |
| 30 | + |
| 31 | + it('sets cases allowed mime types to abc', () => { |
| 32 | + expect(mockFilesSetup.registerFileKind.mock.calls[0][0].allowedMimeTypes).toEqual(['abc']); |
| 33 | + }); |
| 34 | + |
| 35 | + it('sets observability allowed mime types to abc', () => { |
| 36 | + expect(mockFilesSetup.registerFileKind.mock.calls[1][0].allowedMimeTypes).toEqual(['abc']); |
| 37 | + }); |
| 38 | + |
| 39 | + it('sets securitySolution allowed mime types to 100 mb', () => { |
| 40 | + expect(mockFilesSetup.registerFileKind.mock.calls[2][0].allowedMimeTypes).toEqual(['abc']); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + describe('max file size', () => { |
| 45 | + describe('default max file size', () => { |
| 46 | + const config: FilesConfig = { |
| 47 | + allowedMimeTypes: [], |
| 48 | + maxSize: undefined, |
| 49 | + }; |
| 50 | + |
| 51 | + beforeEach(() => { |
| 52 | + registerCaseFileKinds(config, mockFilesSetup); |
| 53 | + }); |
| 54 | + |
| 55 | + it('sets cases max file size to 100 mb', () => { |
| 56 | + expect(mockFilesSetup.registerFileKind.mock.calls[0][0].maxSizeBytes).toEqual( |
| 57 | + MAX_FILE_SIZE |
| 58 | + ); |
| 59 | + }); |
| 60 | + |
| 61 | + it('sets observability max file size to 100 mb', () => { |
| 62 | + expect(mockFilesSetup.registerFileKind.mock.calls[1][0].maxSizeBytes).toEqual( |
| 63 | + MAX_FILE_SIZE |
| 64 | + ); |
| 65 | + }); |
| 66 | + |
| 67 | + it('sets securitySolution max file size to 100 mb', () => { |
| 68 | + expect(mockFilesSetup.registerFileKind.mock.calls[2][0].maxSizeBytes).toEqual( |
| 69 | + MAX_FILE_SIZE |
| 70 | + ); |
| 71 | + }); |
| 72 | + }); |
| 73 | + |
| 74 | + describe('custom file size', () => { |
| 75 | + const config: FilesConfig = { |
| 76 | + allowedMimeTypes: [], |
| 77 | + maxSize: 5, |
| 78 | + }; |
| 79 | + |
| 80 | + beforeEach(() => { |
| 81 | + registerCaseFileKinds(config, mockFilesSetup); |
| 82 | + }); |
| 83 | + |
| 84 | + it('sets cases max file size to 5', () => { |
| 85 | + expect(mockFilesSetup.registerFileKind.mock.calls[0][0].maxSizeBytes).toEqual(5); |
| 86 | + }); |
| 87 | + |
| 88 | + it('sets observability max file size to 5', () => { |
| 89 | + expect(mockFilesSetup.registerFileKind.mock.calls[1][0].maxSizeBytes).toEqual(5); |
| 90 | + }); |
| 91 | + |
| 92 | + it('sets securitySolution max file size to 5', () => { |
| 93 | + expect(mockFilesSetup.registerFileKind.mock.calls[2][0].maxSizeBytes).toEqual(5); |
| 94 | + }); |
| 95 | + }); |
| 96 | + }); |
| 97 | + }); |
| 98 | +}); |
0 commit comments