Skip to content

Commit

Permalink
Adds test for setting an accept-language header
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Paul committed Aug 27, 2019
1 parent 390b70d commit 1150869
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/__mocks__/axios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export default {
create: jest.fn(() => Promise.resolve({})),
create: jest.fn(() => ({
defaults: {
headers: {
common: {},
},
},
})),
delete: jest.fn(() => Promise.resolve({ data: {} })),
get: jest.fn(() => Promise.resolve({ data: {} })),
patch: jest.fn(() => Promise.resolve({ data: {} })),
Expand Down
12 changes: 12 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,15 @@ it('can access the forms resource', async () => {

expect(instance.forms()).toBeInstanceOf(Form.prototype.constructor);
});

it('can set an accepted language header', async () => {
const instance = new OpenApi('admin');

instance.locale('es');

const object = JSON.parse(JSON.stringify(instance));

expect(object.client.defaults.headers.common).toMatchObject({
'Accept-Language': 'es',
});
});

0 comments on commit 1150869

Please sign in to comment.