-
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 #46 from ditrit/improvement/definition_models
Improvement/definition models
- Loading branch information
Showing
9 changed files
with
157 additions
and
48 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
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,40 @@ | ||
/** | ||
* Definition of the link between components. | ||
*/ | ||
class ComponentLinkDefinition { | ||
/** | ||
* Default constructor. | ||
* | ||
* @param {String} [props.sourceRef] - Reference of component can be the source in a link. | ||
* @param {String} [props.targetRef] - Reference of component can be the target of the link. | ||
* @param {String} [props.type] - Representation of the link. | ||
*/ | ||
constructor(props = { | ||
sourceRef: null, | ||
targetRef: null, | ||
type: null, | ||
}) { | ||
const { | ||
sourceRef, | ||
targetRef, | ||
type, | ||
} = props; | ||
/** | ||
* Reference of component can be the source in a link. | ||
* @type {String} | ||
*/ | ||
this.sourceRef = sourceRef || null; | ||
/** | ||
* Reference of component can be the target of the link. | ||
* @type {String} | ||
*/ | ||
this.targetRef = targetRef || null; | ||
/** | ||
* Representation of the link. | ||
* @type {String} | ||
*/ | ||
this.type = type || null; | ||
} | ||
} | ||
|
||
export default ComponentLinkDefinition; |
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
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,33 @@ | ||
import ComponentLinkDefinition from 'src/models/ComponentLinkDefinition'; | ||
|
||
describe('Test class: ComponentLinkDefinition', () => { | ||
describe('Test constructor', () => { | ||
it('Check variable instantiation', () => { | ||
const link = new ComponentLinkDefinition(); | ||
|
||
expect(link.sourceRef).toBeNull(); | ||
expect(link.targetRef).toBeNull(); | ||
expect(link.type).toBeNull(); | ||
}); | ||
|
||
it('Check passing undefined variables to constructor', () => { | ||
const link = new ComponentLinkDefinition({}); | ||
|
||
expect(link.sourceRef).toBeNull(); | ||
expect(link.targetRef).toBeNull(); | ||
expect(link.type).toBeNull(); | ||
}); | ||
|
||
it('Check passing variable to constructor', () => { | ||
const link = new ComponentLinkDefinition({ | ||
sourceRef: 'id1', | ||
targetRef: 'id2', | ||
type: 'type', | ||
}); | ||
|
||
expect(link.sourceRef).toEqual('id1'); | ||
expect(link.targetRef).toEqual('id2'); | ||
expect(link.type).toEqual('type'); | ||
}); | ||
}); | ||
}); |