'use strict';

var Ajv = require(typeof window == 'object' ? 'ajv' : '../lib/ajv')
  , should = require('chai').should()
  , stableStringify = require('json-stable-stringify');

describe('Ajv Options', function () {

  describe('removeAdditional', function() {
    it('should remove properties that would error when `additionalProperties = false`', function() {
      var ajv = Ajv({ removeAdditional: true });

      ajv.compile({
        id: '//test/fooBar',
        properties: { foo: { type: 'string' }, bar: { type: 'string' } },
        additionalProperties: false
      });

      var object = {
        foo: 'foo', bar: 'bar', baz: 'baz-to-be-removed'
      };

      ajv.validate('//test/fooBar', object) .should.equal(true);
      object.should.have.all.keys(['foo', 'bar']);
      object.should.not.have.property('baz');

    });

  });

});

@@ -250,24 +250,25 @@
 unction() %7B%0A
+%0A
     it('shou
@@ -707,17 +707,16 @@
  object)
- 
 .should.
@@ -757,75 +757,790 @@
 ave.
-all.keys(%5B'foo', 'bar'%5D);%0A      object.should.not.have.property('ba
+property('foo');%0A      object.should.have.property('bar');%0A      object.should.not.have.property('baz');%0A%0A    %7D);%0A%0A    it('should remove properties that would error when %60additionalProperties%60 is a schema', function() %7B%0A      var ajv = Ajv(%7B removeAdditional: true %7D);%0A%0A      ajv.compile(%7B%0A        id: '//test/fooBar',%0A        properties: %7B foo: %7B type: 'string' %7D, bar: %7B type: 'string' %7D %7D,%0A        additionalProperties: %7B type: 'string' %7D%0A      %7D);%0A%0A      var object = %7B%0A        foo: 'foo', bar: 'bar', baz: 'baz-to-be-kept', fizz: 1000%0A      %7D;%0A%0A      ajv.validate('//test/fooBar', object).should.equal(true);%0A      object.should.have.property('foo');%0A      object.should.have.property('bar');%0A      object.should.have.property('baz');%0A      object.should.not.have.property('fiz
 z');

Add test for `removeAdditional` when using a schema to validate additional properties.