Skip to content

Commit

Permalink
Fix failing spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Kolotinskiy committed Feb 6, 2024
1 parent 9ae7582 commit 2f0958f
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/lib/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,30 @@ describe('client', () => {

expect(Upload.prototype.setToken).toHaveBeenCalledWith(token);
expect(Upload.prototype.setSecurity).toHaveBeenCalledWith(defaultSecurity);
expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
expect(Upload.prototype.upload).toHaveBeenCalledWith(file, undefined);
});

it('should be able to upload file with alt text', async () => {
const client = new Client(defaultApikey);
const file = 'anyFile';
const uploadOptions = {
altText: 'alt',
};
const storeOptions = {};
const token = {};

jest.spyOn(Upload.prototype, 'upload').mockImplementation(() => Promise.resolve());

await client.upload(file, uploadOptions, storeOptions, token, defaultSecurity);

expect(Upload.prototype.setSession).toHaveBeenCalledWith({
apikey: defaultApikey,
urls: sessionURls,
});

expect(Upload.prototype.setToken).toHaveBeenCalledWith(token);
expect(Upload.prototype.setSecurity).toHaveBeenCalledWith(defaultSecurity);
expect(Upload.prototype.upload).toHaveBeenCalledWith(file, uploadOptions.altText);
});

it('should be able to upload file without token and security', async () => {
Expand All @@ -228,7 +251,7 @@ describe('client', () => {
urls: sessionURls,
});

expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
expect(Upload.prototype.upload).toHaveBeenCalledWith(file, undefined);
});

it('should emit error', async () => {
Expand Down

0 comments on commit 2f0958f

Please sign in to comment.