Skip to content

Commit

Permalink
Restoring part of validation-context tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yanickrochon committed Jun 21, 2017
1 parent 713024e commit d9553c7
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions test/validation-context.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ describe('Testing Validation Context', () => {
const assert = require('assert');

const validationContext = require('../src/validation-context');
const Schema = require('../src/schema');
const Model = require('../src/model');


it('should create new contexts', () => {
Expand All @@ -18,10 +16,6 @@ describe('Testing Validation Context', () => {
});




return;

it('should validate correct contexts', () => {
const context = validationContext();
const mockContext = { field() {}, parent() {} };
Expand Down Expand Up @@ -80,30 +74,12 @@ describe('Testing Validation Context', () => {
assert.strictEqual(context2.field('bar').exists, true, 'Failed to get field');
});

it('should get field from model', () => {
var data = {
foo: {
bar: new Model(new Schema({ buz: String }))
}
};
it('should get field value', () => {
const data = { foo: { bar: { buz: 'world' } } };
const context = validationContext(data);

data.foo.bar.set('buz', 'hello');

assert.strictEqual(context.field('foo.bar.buz').exists, true, 'Failed to get field');
assert.strictEqual(context.field('foo.bar.buz').value, 'hello', 'Failed to fetch field inside model');
assert.strictEqual(context.field('foo.bar.buz').value, 'world', 'Failed to get field value');
});

it('should get field from model', () => {
var data = {
foo: new Model(new Schema({ bar: Object }))
};
const context = validationContext(data);

data.foo.set('bar', { buz: 'world' });

assert.strictEqual(context.field('foo.bar.buz').exists, true, 'Failed to get field');
assert.strictEqual(context.field('foo.bar.buz').value, 'world', 'Failed to fetch field inside model');
});

});

0 comments on commit d9553c7

Please sign in to comment.