-
Notifications
You must be signed in to change notification settings - Fork 7
Check field associated entity and add missing fields #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d00a470
afb50db
7dba111
2ffa992
28945df
beaef54
d6013f3
95770bc
244ce10
9592885
cf267a3
a25f9a1
1335880
dc47a25
ac43bf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,134 @@ | ||
| import { MetaService } from '../src'; | ||
|
|
||
| describe('MetaService', () => { | ||
| describe('function: hasMemory', () => { | ||
| it('should be defined', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| const actual = meta.hasMemory; | ||
| expect(actual).toBeDefined(); | ||
| }); | ||
| it('should return false when memory is undefined', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = undefined; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is null', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = null; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is false', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = false; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is not an Object', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = []; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is an empty Object', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = {}; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return true when memory is a non-empty Object', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = { test: 'test' }; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(true); | ||
| }); | ||
| describe('function: hasMemory', () => { | ||
| it('should be defined', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| const actual = meta.hasMemory; | ||
| expect(actual).toBeDefined(); | ||
| }); | ||
| it('should return false when memory is undefined', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = undefined; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is null', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = null; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is false', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = false; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is not an Object', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = []; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return false when memory is an empty Object', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = {}; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(false); | ||
| }); | ||
| it('should return true when memory is a non-empty Object', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| meta.memory = {test: 'test'}; | ||
| const actual = meta.hasMemory(); | ||
| expect(actual).toEqual(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('function: getSubFields', () => { | ||
| it('should be defined', () => { | ||
| const meta: MetaService = new MetaService('EarnCodeGroup'); | ||
| const actual = meta.getSubFields; | ||
| expect(actual).toBeDefined(); | ||
| }); | ||
| it('should return array of fields case 1', () => { | ||
| const meta: MetaService = new MetaService('EarnCodeGroup'); | ||
| const field = 'jobOrders(id,title,status)'; | ||
| const res = meta.getSubFields(field); | ||
| expect(res[0]).toBe('id'); | ||
| expect(res[1]).toBe('title'); | ||
| expect(res[2]).toBe('status'); | ||
| }); | ||
| it('should return array of fields case 1', () => { | ||
| const meta: MetaService = new MetaService('EarnCodeGroup'); | ||
| const field = 'jobOrders(id,title,status)'; | ||
| const res = meta.getSubFields(field); | ||
| expect(res[0]).toBe('id'); | ||
| expect(res[1]).toBe('title'); | ||
| expect(res[2]).toBe('status'); | ||
| }); | ||
| it('should return array of fields case 2', () => { | ||
| const meta: MetaService = new MetaService('EarnCodeGroup'); | ||
| const field = 'jobOrders[3](id,title,status)'; | ||
| const res = meta.getSubFields(field); | ||
| expect(res[0]).toBe('id'); | ||
| expect(res[1]).toBe('title'); | ||
| expect(res[2]).toBe('status'); | ||
| }); | ||
| it('should return array of fields case 3', () => { | ||
charlesabarnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const meta: MetaService = new MetaService('EarnCodeGroup'); | ||
| const field = 'jobOrders{status=\'closed\'}(id,title,status)'; | ||
| const res = meta.getSubFields(field); | ||
| expect(res[0]).toBe('id'); | ||
| expect(res[1]).toBe('title'); | ||
| expect(res[2]).toBe('status'); | ||
| }); | ||
| it('should return array of fields case 4', () => { | ||
| const meta: MetaService = new MetaService('EarnCodeGroup'); | ||
| const field = 'jobOrders(id, title, status)'; | ||
| const res = meta.getSubFields(field); | ||
| expect(res[0]).toBe('id'); | ||
| expect(res[1]).toBe('title'); | ||
| expect(res[2]).toBe('status'); | ||
| }); | ||
| it('should return array of fields case 5', () => { | ||
| const meta: MetaService = new MetaService('EarnCodeGroup'); | ||
| const fields = 'businessSectors[3](name,id){name=\'Insurance\'},category'; | ||
| const res = meta.getSubFields(fields); | ||
| expect(res[0]).toBe('name'); | ||
| expect(res[1]).toBe('id'); | ||
| }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think you are missing a test that get the fields inside a nested field
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We made a change to this, to only target 'INLINE_EMBEDDED' entities. The only entity that is configured that way it defaultEanCode, and the other earn code entities. The fields for these, do not ever have double nested fields, so the current logic should be able to handle that. |
||
| }); | ||
|
|
||
| describe('function: _clean', () => { | ||
| it('should be defined', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| const actual = meta._clean; | ||
| expect(actual).toBeDefined(); | ||
| }); | ||
| it('should return a field name case 1', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| const field = 'name'; | ||
| const res = meta._clean(field); | ||
| expect(res).toBe('name'); | ||
| }); | ||
| it('should return a field name case 2', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| const field = 'jobOrder(id,title)'; | ||
| const res = meta._clean(field); | ||
| expect(res).toBe('jobOrder'); | ||
| }); | ||
| it('should return a field name case 3', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| const field = 'jobOrder[3](id,title)'; | ||
| const res = meta._clean(field); | ||
| expect(res).toBe('jobOrder'); | ||
| }); | ||
| it('should return a field name case 4', () => { | ||
| const meta: MetaService = new MetaService('Candidate'); | ||
| const field = 'jobOrder.title'; | ||
| const res = meta._clean(field); | ||
| expect(res).toBe('jobOrder'); | ||
| }); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something i might have missed earlier is that we are pushing
cleanedthat seems wrong because all the default fields would have to be included, Maybe that is true for INLINE_EMBEDDED.was think something more like