@zohodesk/dot
Version:
In this Library, we Provide Some Basic Components to Build Your Application
151 lines • 4.35 kB
JavaScript
import React from 'react';
import { render } from '@testing-library/react';
import Upload from "../Upload";
describe('Upload', () => {
const mockOnRemove = jest.fn();
const mockEleRef = jest.fn();
const size = ['small', 'medium'];
const palette = ['light', 'night'];
test('rendering the defult props', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, null));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the isPreview prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreview: true
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the isPreview prop is false', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreview: false
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the tooltip prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
tooltip: "Tooltip"
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the dataId prop with isPreview isPreviewType are true ', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
dataId: "TestdataId",
isPreview: true,
isPreviewType: true,
onRemove: mockOnRemove
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the dataId prop with isPreviewType is false', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
dataId: "TestdataId",
isPreview: true,
onRemove: mockOnRemove,
isPreviewType: false
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the dataSelectorId prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
dataSelectorId: "selectorId"
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the progressValue prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreview: true,
progressValue: "90"
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the iconName prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreviewType: false,
iconName: "ZD-close"
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the fileSize prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreviewType: false,
fileSize: "400kb"
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the imgSrc prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreviewType: true,
imgSrc: "http://sampleImageUrl.com"
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the isPreviewType true prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreviewType: true
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the isPreviewType false prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
isPreviewType: false
}));
expect(asFragment()).toMatchSnapshot();
});
test('rendering the onRemove prop', () => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
onRemove: mockOnRemove
}));
expect(asFragment()).toMatchSnapshot();
});
test.each(size)('rendering the size of - %s', size => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
size: size
}));
expect(asFragment()).toMatchSnapshot();
});
test.each(palette)('rendering the palette of - %s', palette => {
const {
asFragment
} = render( /*#__PURE__*/React.createElement(Upload, {
palette: palette
}));
expect(asFragment()).toMatchSnapshot();
});
test('eleRef prop is a function', () => {
render( /*#__PURE__*/React.createElement(Upload, {
getRef: mockEleRef
}));
expect(mockEleRef).toHaveBeenCalled();
});
});