Skip to content

Commit

Permalink
ngx-jsonapi and parent-resource-service tests fixed (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxi7587 authored and pablorsk committed Jul 20, 2018
1 parent 4ac7e22 commit 0b29fd3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ngx-jsonapi.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonapiCore, NgxJsonapiModule } from '.';

import { JsonapiConfig } from './jsonapi-config';
/*
This file is to import the main module. By importing it into this
spec file, all the attached components get traversed and recognized
Expand All @@ -13,7 +13,7 @@ describe('ngx-jsonapi Module', () => {

it('should throw error when imported more than once', () => {
expect(
(): NgxJsonapiModule => new NgxJsonapiModule(NgxJsonapiModule, new JsonapiCore(undefined, undefined, undefined))
(): NgxJsonapiModule => new NgxJsonapiModule(NgxJsonapiModule, new JsonapiCore(new JsonapiConfig(), undefined, undefined))
).toThrow(new Error('NgxJsonapiModule is already loaded. Import it in the AppModule only'));
});
});
25 changes: 23 additions & 2 deletions src/parent-resource-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,32 @@ describe('parent-resource-service test', () => {
.toEqual({ ...{}, ...Base.Params, ...exec_params_with_object.params });
});
it('proccess_exec_params() should fail if provided with a non IExecParams object', () => {
// TODO: cahnge test or fix method to return false or an error in such case
let exec_params = {
id: 'test_exec_params',
params: 'test_exec_params'
};
expect(parentResourceServiceTest.testProccessExecParams(exec_params)).toBeFalsy();
// expect error, typescript won't allow this
expect(parentResourceServiceTest.testProccessExecParams(exec_params).params).toEqual(
{
0: 't',
1: 'e',
2: 's',
3: 't',
4: '_',
5: 'e',
6: 'x',
7: 'e',
8: 'c',
9: '_',
10: 'p',
11: 'a',
12: 'r',
13: 'a',
14: 'm',
15: 's',
id: '',
include: [ ]
}
);
});
});

0 comments on commit 0b29fd3

Please sign in to comment.