diff --git a/test/fixtures/context/duplicate/context.context b/test/fixtures/context/duplicate/context.context new file mode 100644 index 00000000..02e94e61 --- /dev/null +++ b/test/fixtures/context/duplicate/context.context @@ -0,0 +1,3 @@ +({ + Nomen: { domain: 'Nomen' }, +}); diff --git a/test/fixtures/context/duplicate/custom.domains b/test/fixtures/context/duplicate/custom.domains new file mode 100644 index 00000000..a16a5cf8 --- /dev/null +++ b/test/fixtures/context/duplicate/custom.domains @@ -0,0 +1,3 @@ +({ + Nomen: { type: 'string' }, +}); diff --git a/test/fixtures/context/duplicate/duplicateDomain.context b/test/fixtures/context/duplicate/duplicateDomain.context new file mode 100644 index 00000000..02e94e61 --- /dev/null +++ b/test/fixtures/context/duplicate/duplicateDomain.context @@ -0,0 +1,3 @@ +({ + Nomen: { domain: 'Nomen' }, +}); diff --git a/test/fixtures/context/unresolved/context.context b/test/fixtures/context/unresolved/context.context new file mode 100644 index 00000000..02e94e61 --- /dev/null +++ b/test/fixtures/context/unresolved/context.context @@ -0,0 +1,3 @@ +({ + Nomen: { domain: 'Nomen' }, +}); diff --git a/test/ms.context.js b/test/ms.context.js new file mode 100644 index 00000000..7405a439 --- /dev/null +++ b/test/ms.context.js @@ -0,0 +1,32 @@ +'use strict'; + +const metaschema = require('metaschema'); +const metatests = require('metatests'); + +const { options, config } = require('../lib/metaschema-config/config'); + +const { MetaschemaError, SchemaValidationError } = metaschema.errors; + +metatests.test('metaschema context error on duplicated domains', async test => { + await test.rejects( + metaschema.fs.load('test/fixtures/context/duplicate', options, config), + new MetaschemaError([ + new SchemaValidationError('duplicate', 'duplicateDomain', { + type: 'context', + value: 'Nomen', + }), + ]) + ); +}); + +metatests.test('metaschema context error on unresolved domain', async test => { + await test.rejects( + metaschema.fs.load('test/fixtures/context/unresolved', options, config), + new MetaschemaError([ + new SchemaValidationError('unresolved', 'context.Nomen', { + type: 'domain', + value: 'Nomen', + }), + ]) + ); +});