Skip to content

Commit

Permalink
Cleans up code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Nov 15, 2018
1 parent 3e0c42f commit 72f0af8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/__mocks__/axios.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
get: jest.fn(() => Promise.resolve({ data: {} }))
}
get: jest.fn(() => Promise.resolve({ data: {} })),
};
4 changes: 2 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import axios, { AxiosInstance } from 'axios';

const Client = (domain: string) => {
const Client = (domain: string): AxiosInstance => {
return axios.create({
baseURL: `https://${domain}.coconutcalendar.com/api/v2/open`,
headers: {
Expand Down
57 changes: 25 additions & 32 deletions src/resources/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,74 @@ import User from './user';
it('will set assigned filter', async () => {
const resource = new User(mockAxios);

expect(resource.assigned())
.toHaveProperty('filters', {
assigned: true,
});
expect(resource.assigned()).toHaveProperty('filters', {
assigned: true,
});
});

it('will set location filter using a number', async () => {
const resource = new User(mockAxios);

expect(resource.at(1))
.toHaveProperty('filters', {
location: 1,
});
expect(resource.at(1)).toHaveProperty('filters', {
location: 1,
});
});

it('will set location filter using a string', async () => {
const resource = new User(mockAxios);

expect(resource.at('identifier'))
.toHaveProperty('filters', {
location: 'identifier',
});
expect(resource.at('identifier')).toHaveProperty('filters', {
location: 'identifier',
});
});

it('will set service filter using a number', async () => {
const resource = new User(mockAxios);

expect(resource.performing(1))
.toHaveProperty('filters', {
services: 1,
});
expect(resource.performing(1)).toHaveProperty('filters', {
services: 1,
});
});

it('will set service filter using an array of numbers', async () => {
const resource = new User(mockAxios);

expect(resource.performing([1, 2]))
.toHaveProperty('filters', {
services: [1, 2],
});
expect(resource.performing([1, 2])).toHaveProperty('filters', {
services: [1, 2],
});
});

it('will set service filter using a string', async () => {
const resource = new User(mockAxios);

expect(resource.performing('identifier'))
.toHaveProperty('filters', {
services: 'identifier',
});
expect(resource.performing('identifier')).toHaveProperty('filters', {
services: 'identifier',
});
});

it('will set service filter using an array of strings', async () => {
const resource = new User(mockAxios);

expect(resource.performing(['identifier', 'other']))
.toHaveProperty('filters', {
services: ['identifier', 'other'],
});
expect(resource.performing(['identifier', 'other'])).toHaveProperty('filters', {
services: ['identifier', 'other'],
});
});

it('will set the sortable filter', async () => {
const resource = new User(mockAxios);

expect(resource.sortBy('first_name,-created'))
.toHaveProperty('sortable', 'first_name,-created');
expect(resource.sortBy('first_name,-created')).toHaveProperty('sortable', 'first_name,-created');
});

it('can string all filterable options together', async () => {
const resource = new User(mockAxios);

const expected = expect(
resource.assigned()
resource
.assigned()
.at(1)
.performing([1, 2])
.sortBy('created')
.sortBy('created'),
);

expected.toHaveProperty('filters', {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "es5",
"module": "es6",
"moduleResolution": "node",
"esModuleInterop": true,
"declaration": true,
"lib": ["dom", "es2015.promise", "es5", "scripthost"],
"outDir": "./dist",
Expand Down

0 comments on commit 72f0af8

Please sign in to comment.