-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: sanketshevkar <[email protected]>
- Loading branch information
1 parent
462236d
commit 2d06623
Showing
1 changed file
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,10 @@ const ParserUtil = require('./parserutility'); | |
const ModelManager = require('../../lib/modelmanager'); | ||
const Util = require('../composer/composermodelutility'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const sinon = require('sinon'); | ||
const ModelFile = require('../../lib/introspect/modelfile'); | ||
const expect = require('chai').expect; | ||
|
||
|
||
|
@@ -787,3 +789,40 @@ describe('MapDeclaration', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('MapDeclration - Test for declarations using Import Aliasing', () => { | ||
|
||
let modelManager; | ||
let resolvedModelManager; | ||
|
||
beforeEach(() => { | ||
modelManager = new ModelManager({ strict: true, importAliasing: true, enableMapType: true}); | ||
|
||
const childModelCTO = fs.readFileSync(path.resolve(__dirname, '../data/aliasing/child.cto'), 'utf8'); | ||
const parentModelCTO = fs.readFileSync(path.resolve(__dirname, '../data/aliasing/parent.cto'), 'utf8'); | ||
|
||
modelManager.addCTOModel(childModelCTO, '[email protected]'); | ||
modelManager.addCTOModel(parentModelCTO, '[email protected]'); | ||
const resolvedMetamodelChild = modelManager.resolveMetaModel(modelManager.getAst().models[0]); | ||
const resolvedMetamodelParent = modelManager.resolveMetaModel(modelManager.getAst().models[1]); | ||
resolvedModelManager = new ModelManager({ strict: true, importAliasing: true, enableMapType: true}); | ||
const resolvedModelFileChild = new ModelFile(resolvedModelManager, resolvedMetamodelChild, '[email protected]'); | ||
const resolvedModelFileParent = new ModelFile(resolvedModelManager, resolvedMetamodelParent, '[email protected]'); | ||
resolvedModelManager.addModelFiles([resolvedModelFileChild, resolvedModelFileParent], ['[email protected]', '[email protected]']); | ||
}); | ||
|
||
describe('#validate', () => { | ||
|
||
it('should be able get validate a map key which is an imported scalar type which is aliased', () => { | ||
const mapDeclaration = resolvedModelManager.getType('[email protected]'); | ||
const key = mapDeclaration.getKey(); | ||
expect(key.validate.bind(key)).to.not.throw(); | ||
}); | ||
|
||
it('should be able get validate a map value which is an imported type which is aliased', () => { | ||
const mapDeclaration = resolvedModelManager.getType('[email protected]'); | ||
const value = mapDeclaration.getValue(); | ||
expect(value.validate.bind(value)).to.not.throw(); | ||
}); | ||
}); | ||
}); |