Skip to content

Instantly share code, notes, and snippets.

@pferreir
Created November 15, 2019 08:27
Show Gist options
  • Save pferreir/8a04fb95e72abef5467a232d2e13cf8e to your computer and use it in GitHub Desktop.
Save pferreir/8a04fb95e72abef5467a232d2e13cf8e to your computer and use it in GitHub Desktop.
import React from 'react';
import {shallow} from 'enzyme';
import FileManager, {FileType} from '../components/FileManager';
const data = [
{
id: '1',
name: 'Source file',
contentTypes: ['text/plain'],
multiple: false,
files: [{filename: 'file1.txt', url: 'file1url', uuid: 'file1', claimed: true}],
},
{
id: '2',
name: 'PDF file',
contentTypes: ['application/pdf'],
multiple: false,
files: [{filename: 'file1.pdf', url: 'file1url', uuid: 'file2', claimed: true}],
},
{
id: '3',
name: 'Image files',
contentTypes: ['image/png'],
multiple: true,
files: [
{filename: 'image.png', url: 'file1url', uuid: 'file3', claimed: true},
{filename: 'image2.png', url: 'file2url', uuid: 'file4', claimed: true},
],
},
];
describe('File manager', () => {
it('Renders OK', () => {
const wrapper = shallow(<FileManager eventId="1" fileTypes={data} />);
expect(wrapper.find(FileType)).toHaveLength(3);
wrapper.find(FileType).forEach((node, i) => {
expect(node.prop('fileType')).toEqual(data[i]);
expect(node.prop('uploads')).toEqual({});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment