-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lysyi3m/feature/multi-relationships
Add support for multiple relationships extracting
- Loading branch information
Showing
3 changed files
with
122 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { getRelationshipData } from '../src' | ||
|
||
describe('getRelationshipData()', () => { | ||
test('return correct relationship data for provided relationship', () => { | ||
const relationship = { type: 'authors', id: '9' } | ||
|
||
const included = [ | ||
{ | ||
id: '9', | ||
type: 'authors', | ||
attributes: { | ||
name: 'Bob' | ||
} | ||
} | ||
] | ||
|
||
expect(getRelationshipData(relationship, included)).toMatchObject({ | ||
id: '9', | ||
name: 'Bob' | ||
}) | ||
}) | ||
|
||
test('return nothing if included resources are not provided', () => { | ||
const relationship = { type: 'authors', id: '9' } | ||
|
||
expect(getRelationshipData(relationship)).toBeUndefined() | ||
}) | ||
}) |