message: Moves around to make more managable
diff: @@ -5,6 +5,17 @@ import { validTestCertPath } from '../test-helpers';
  const accountingBaseUrl = 'https://api.xero.com/api.xro/2.0/';
  const aGuid = 'dcb417fc-0c23-4ba3-bc7f-fbc718e7e663';
  +interface IEndPoingDetails {
  + endpoint: string;
  + action: string;
  + expectedPath: string;
  + args?: any;
  +}
  +
  +interface IFixture {
  + [key: string]: IEndPoingDetails[];
  +}
  +
  describe('Endpoint: ', () => {
  const inMemoryOAuthLib = new InMemoryOAuthLib();
  @@ -18,18 +29,34 @@ describe('Endpoint: ', () => {
  // TODO: figure out contactgroups.contacts
  // TODO: Double check when an endpoint and take an ID and add a line for it
  - [{ endpoint: 'invoices', action: 'get', expectedPath: 'invoices' },
  - { endpoint: 'invoices', action: 'create', expectedPath: 'invoices?summarizeErrors=false' },
  + const verbMap: { [key: string]: string } = {
  + create: 'put',
  + delete: 'delete',
  + update: 'post',
  + get: 'get'
  + };
  +
  + const fixtures: IFixture = {
  + invoices: [
  + { endpoint: 'invoices', action: 'get', expectedPath: 'invoices' },
  + { endpoint: 'invoices', action: 'create', expectedPath: 'invoices?summarizeErrors=false' }
  + ],
  + contactgroups: [
  { endpoint: 'contactgroups', action: 'get', expectedPath: 'contactgroups' },
  { endpoint: 'contactgroups', action: 'create', expectedPath: 'contactgroups?summarizeErrors=false' },
  { endpoint: 'contactgroups', action: 'update', expectedPath: `contactgroups/${aGuid}?summarizeErrors=false`, args: { ContactGroupID: aGuid } },
  + ],
  + currencies: [
  { endpoint: 'currencies', action: 'get', expectedPath: `currencies` },
  { endpoint: 'currencies', action: 'create', expectedPath: `currencies` },
  - ].map((fixture) => {
  + ]
  + };
  - let result: any;
  + Object.keys(fixtures).map((endpoint: string) => {
  + (fixtures[endpoint] as any).map((fixture: IEndPoingDetails) => {
  describe(`${fixture.endpoint} & ${fixture.action} calls`, () => {
  + let result: any;
  const mockedResponse = JSON.stringify({ a: 'response' });
  @@ -46,13 +73,6 @@ describe('Endpoint: ', () => {
  inMemoryOAuthLib.lastCalledThisURL(accountingBaseUrl + fixture.expectedPath);
  });
  - const verbMap: { [key: string]: string } = {
  - create: 'put',
  - delete: 'delete',
  - update: 'post',
  - get: 'get'
  - };
  -
  it(`calls the ${verbMap[fixture.action]} verb`, () => {
  inMemoryOAuthLib.lastCalledThisVerb(verbMap[fixture.action]);
  });
  @@ -66,4 +86,6 @@ describe('Endpoint: ', () => {
  });
  });
  });
  +
  + });
  });
  