Updated unit test
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-09-14 11:26:22 +02:00
parent c442073eae
commit 59efc24077
1 changed files with 17 additions and 4 deletions

View File

@ -24,17 +24,30 @@ describe('Salix', () => {
});
describe('viewportSelection()', () => {
it('should call to displayEditor() and updatePhotoPreview() methods', () => {
controller.displayEditor = jest.fn();
it('should call to the updatePhotoPreview() method when uploadMethod property is set to "computer"', () => {
controller.updatePhotoPreview = jest.fn();
const files = [{name: 'test.jpg'}];
controller.newPhoto.files = files;
controller.uploadMethod = 'computer';
controller.viewportSelection = {code: 'normal'};
expect(controller.displayEditor).toHaveBeenCalledWith();
expect(controller.updatePhotoPreview).toHaveBeenCalledWith(files);
const firstFile = files[0];
expect(controller.updatePhotoPreview).toHaveBeenCalledWith(firstFile);
});
it('should call to the updatePhotoPreview() method when uploadMethod property is set to "URL"', () => {
controller.updatePhotoPreview = jest.fn();
const url = 'http://gothamcity.com/batman.png';
controller.newPhoto.url = url;
controller.uploadMethod = 'URL';
controller.viewportSelection = {code: 'normal'};
expect(controller.updatePhotoPreview).toHaveBeenCalledWith(url);
});
});