|
|
|
@ -85,17 +85,17 @@ describe('DataSource', () => { |
|
|
|
|
|
|
|
describe('Relations', () => { |
|
|
|
const categoryRecords = [ |
|
|
|
{ id: 'cat1', name: 'Category 1' }, |
|
|
|
{ id: 'cat2', name: 'Category 2' }, |
|
|
|
{ id: 'cat1', uid: 'cat1-uid', name: 'Category 1' }, |
|
|
|
{ id: 'cat2', uid: 'cat2-uid', name: 'Category 2' }, |
|
|
|
]; |
|
|
|
const userRecords = [ |
|
|
|
{ id: 'user1', username: 'user_one' }, |
|
|
|
{ id: 'user2', username: 'user_two' }, |
|
|
|
]; |
|
|
|
const blogRecords = [ |
|
|
|
{ id: 'blog1', title: 'First Blog', author: 'user1', categories: ['cat1'] }, |
|
|
|
{ id: 'blog1', title: 'First Blog', author: 'user1', categories: ['cat1-uid'] }, |
|
|
|
{ id: 'blog2', title: 'Second Blog', author: 'user2' }, |
|
|
|
{ id: 'blog3', title: 'Third Blog', categories: ['cat1', 'cat2'] }, |
|
|
|
{ id: 'blog3', title: 'Third Blog', categories: ['cat1-uid', 'cat2-uid'] }, |
|
|
|
]; |
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
@ -128,9 +128,9 @@ describe('DataSource', () => { |
|
|
|
expect(serializeRecords(blogsDS.getRecords())).toEqual(blogRecords); |
|
|
|
}); |
|
|
|
|
|
|
|
test('return resolved values', () => { |
|
|
|
test('return 1:1 resolved values', () => { |
|
|
|
const blogsDS = dsm.get('blogs'); |
|
|
|
const records = blogsDS.getRecords({ resolveRelations: true }); |
|
|
|
const records = blogsDS.getResolvedRecords(); |
|
|
|
expect(records).toEqual([ |
|
|
|
{ ...blogRecords[0], author: userRecords[0] }, |
|
|
|
{ ...blogRecords[1], author: userRecords[1] }, |
|
|
|
|