Skip to content

Commit

Permalink
test(api/file): fix tests after release of new requests library with …
Browse files Browse the repository at this point in the history
…hotfixes

* build(check): move check to build command, fix array content in checks

* test(api/file): fix tests after release of new requests library with hotfixes
  • Loading branch information
pcholuj authored Feb 13, 2020
1 parent a295093 commit c550821
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/lib/api/file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('FileAPI', () => {
const resp = await metadata(mockedSession, 'fakeHandle');

expect(resp).toEqual({ handle: 'fakeHandle' });
expect(methodMocked).toHaveBeenLastCalledWith('fakeApiUrl/fakeHandle/metadata', { params: {} });
expect(methodMocked).toHaveBeenLastCalledWith('fakeApiUrl/fakeHandle/metadata', { params: {}, filestackHeaders: false });
});

it('should call correct metadata with options', async () => {
Expand All @@ -68,7 +68,7 @@ describe('FileAPI', () => {
const resp = await metadata(mockedSession, 'fakeHandle', { size: true });

expect(resp).toEqual({ handle: 'fakeHandle' });
expect(methodMocked).toHaveBeenLastCalledWith('fakeApiUrl/fakeHandle/metadata', { params: { size: true } });
expect(methodMocked).toHaveBeenLastCalledWith('fakeApiUrl/fakeHandle/metadata', { params: { size: true }, filestackHeaders: false });
});

it('should throw on wrong option', async () => {
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('FileAPI', () => {
);

expect(resp).toEqual({ data: {} });
expect(deleteMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { params: { key: 'fakeApikey', policy: 'fakeP', signature: 'fakeS' } });
expect(deleteMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { params: { key: 'fakeApikey', policy: 'fakeP', signature: 'fakeS' }, filestackHeaders: false });
});

it('should respect skip storage option', async () => {
Expand All @@ -127,7 +127,7 @@ describe('FileAPI', () => {
);

expect(resp).toEqual({ data: {} });
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { params: { key: 'fakeApikey', policy: 'fakeP', signature: 'fakeS', skip_storage: true } });
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { params: { key: 'fakeApikey', policy: 'fakeP', signature: 'fakeS', skip_storage: true }, filestackHeaders: false });
});

it('should throw on empty handle', () => {
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('FileAPI', () => {
const resp = await retrieve(mockedSession, 'fakeHandle');

expect(resp).toEqual({});
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { method: 'GET', params: { key: 'fakeApikey' } });
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { method: 'GET', params: { key: 'fakeApikey' }, filestackHeaders: false });
});

it('should make correct retrieve request (HEAD)', async () => {
Expand All @@ -192,7 +192,7 @@ describe('FileAPI', () => {
});

expect(resp).toEqual({ type: 'test' });
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { method: 'HEAD', params: { key: 'fakeApikey' } });
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', { method: 'HEAD', params: { key: 'fakeApikey' }, filestackHeaders: false });
});

it('should make correct retrieve request with provided security', async () => {
Expand All @@ -211,6 +211,7 @@ describe('FileAPI', () => {
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle', {
method: 'GET',
params: { key: 'fakeApikey', policy: 'fakeP', signature: 'fakeS' },
filestackHeaders: false,
});
});

Expand All @@ -224,7 +225,7 @@ describe('FileAPI', () => {
});

expect(resp).toEqual({});
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle+txt', { method: 'GET', params: { key: 'fakeApikey' } });
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle+txt', { method: 'GET', params: { key: 'fakeApikey' }, filestackHeaders: false });
});

it('should make correct retrieve request with metadata', async () => {
Expand All @@ -237,7 +238,7 @@ describe('FileAPI', () => {
});

expect(resp).toEqual({});
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle/metadata', { method: 'GET', params: { key: 'fakeApikey' } });
expect(methodMocked).toHaveBeenCalledWith('fakeApiUrl/fakeHandle/metadata', { method: 'GET', params: { key: 'fakeApikey' }, filestackHeaders: false });
});

it('should throw an error on empty handle', () => {
Expand Down

0 comments on commit c550821

Please sign in to comment.