Files
frontend-app-ora-grading/src/components/FilePopoverContent/index.test.jsx
leangseu-edx b2aac6036e feat: show file size in file popover (#47)
* feat: show file size in file popover

* chore: update file popover content's props
2022-01-19 11:13:39 -05:00

40 lines
1021 B
JavaScript

import React from 'react';
import { shallow } from 'enzyme';
import filesize from 'filesize';
import FilePopoverContent from '.';
jest.mock('filesize', () => (size) => `filesize(${size})`);
describe('FilePopoverContent', () => {
describe('component', () => {
const props = {
name: 'some file name',
description: 'long descriptive text...',
downloadURL: 'this-url-is.working',
size: 6000,
};
let el;
beforeEach(() => {
el = shallow(<FilePopoverContent {...props} />);
});
describe('snapshot', () => {
test('default', () => expect(el).toMatchSnapshot());
test('invalid size', () => {
el.setProps({
size: null,
});
expect(el).toMatchSnapshot();
});
});
describe('behavior', () => {
test('content', () => {
expect(el.text()).toContain(props.name);
expect(el.text()).toContain(props.description);
expect(el.text()).toContain(filesize(props.size));
});
});
});
});