From 5189dce8efacaa2de6507d6fc46c0f3c1c756a82 Mon Sep 17 00:00:00 2001 From: Rumiantsev Oleksii Date: Wed, 15 May 2019 17:17:37 +0300 Subject: [PATCH] Add tests for metaschema context support --- .../context/duplicate/context.context | 3 ++ .../fixtures/context/duplicate/custom.domains | 3 ++ .../context/duplicate/duplicateDomain.context | 3 ++ .../context/unresolved/context.context | 3 ++ test/ms.context.js | 32 +++++++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 test/fixtures/context/duplicate/context.context create mode 100644 test/fixtures/context/duplicate/custom.domains create mode 100644 test/fixtures/context/duplicate/duplicateDomain.context create mode 100644 test/fixtures/context/unresolved/context.context create mode 100644 test/ms.context.js 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', + }), + ]) + ); +});