Skip to content

Commit

Permalink
Add tests for metaschema context support
Browse files Browse the repository at this point in the history
  • Loading branch information
o-rumiantsev committed Jun 2, 2019
1 parent 9e61d11 commit 5189dce
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/fixtures/context/duplicate/context.context
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
({
Nomen: { domain: 'Nomen' },
});
3 changes: 3 additions & 0 deletions test/fixtures/context/duplicate/custom.domains
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
({
Nomen: { type: 'string' },
});
3 changes: 3 additions & 0 deletions test/fixtures/context/duplicate/duplicateDomain.context
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
({
Nomen: { domain: 'Nomen' },
});
3 changes: 3 additions & 0 deletions test/fixtures/context/unresolved/context.context
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
({
Nomen: { domain: 'Nomen' },
});
32 changes: 32 additions & 0 deletions test/ms.context.js
Original file line number Diff line number Diff line change
@@ -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',
}),
])
);
});

0 comments on commit 5189dce

Please sign in to comment.