Skip to content

Commit

Permalink
fix(lib/test.coffee,test/unit/test-test.coffee): Remove unused banUnk…
Browse files Browse the repository at this point in the history
…nown property

Removed banUnknown property from tv4 exported module.

Fixes: #237
  • Loading branch information
plroebuck committed Apr 4, 2018
1 parent 4546e64 commit 9e37eb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 6 additions & 3 deletions lib/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class TestFactory
files = glob.sync schemaLocation
console.log '\tJSON ref schemas: ' + files.join(', ')

tv4.banUnknown = true

for file in files
tv4.addSchema(JSON.parse(fs.readFileSync(file, 'utf8')))

Expand Down Expand Up @@ -120,7 +118,12 @@ class Test
"""

json = validateJson()
result = tv4.validateResult json, schema

# Validate object against JSON schema
checkRecursive = false
banUnknown = false
result = tv4.validateResult json, schema, checkRecursive, banUnknown

assert.lengthOf result.missing, 0, """
Missing/unresolved JSON schema $refs (#{result.missing?.join(', ')}) in schema:
#{JSON.stringify(schema, null, 4)}
Expand Down
4 changes: 0 additions & 4 deletions test/unit/test-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ describe 'Test', () ->
)

tv4Stub = {}
tv4Stub.banUnknown = false
tv4Stub.addSchema = sinon.spy()

TestTestFactory = proxyquire '../../lib/test', {
Expand All @@ -203,23 +202,20 @@ describe 'Test', () ->
new TestTestFactory('')
assert.isFalse globStub.sync.called
assert.isFalse fsStub.readFileSync.called
assert.isFalse tv4Stub.banUnknown
assert.isFalse tv4Stub.addSchema.called

it 'test TestFactory with name 1', () ->
new TestTestFactory('thisisaword')
assert.isTrue globStub.sync.calledWith 'thisisaword'
assert.isTrue fsStub.readFileSync.calledOnce
assert.isTrue fsStub.readFileSync.calledWith 'thisisaword', 'utf8'
assert.isTrue tv4Stub.banUnknown
assert.isTrue tv4Stub.addSchema.calledWith(JSON.parse('{ "text": "example" }'))

it 'test TestFactory with name 2', () ->
new TestTestFactory('thisIsAnotherWord')
assert.isTrue globStub.sync.calledWith 'thisIsAnotherWord'
assert.isTrue fsStub.readFileSync.calledTwice
assert.isTrue fsStub.readFileSync.calledWith 'thisIsAnotherWord', 'utf8'
assert.isTrue tv4Stub.banUnknown
assert.isTrue tv4Stub.addSchema.calledWith(JSON.parse('{ "text": "example" }'))


Expand Down

0 comments on commit 9e37eb8

Please sign in to comment.