-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor cleanup. Provide ability to override rules when calling apply.
- Loading branch information
Ross McDonald
committed
Sep 28, 2018
1 parent
08be1df
commit 18e2493
Showing
8 changed files
with
82 additions
and
173 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Spectral } from '@spectral/index'; | ||
import { IRuleConfig } from '@spectral/types'; | ||
|
||
const spec = require('./fixtures/todos.partial-deref.oas2.json'); | ||
|
||
describe('spectral', () => { | ||
test('load and run the default rule set', () => { | ||
const s = new Spectral(); | ||
const results = s.apply(spec, 'oas2'); | ||
expect(results.length).toBeGreaterThan(0); | ||
}); | ||
|
||
test.only('be able to toggle rules on apply', () => { | ||
const spec = { | ||
something: 'something-else', | ||
}; | ||
|
||
const initialConfig: IRuleConfig = { | ||
rules: { | ||
oas2: { | ||
'lint:test': { | ||
type: 'truthy', | ||
path: '$', | ||
enabled: false, | ||
description: 'this should return a result if enabled', | ||
truthy: 'something-not-present', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const overrideConfig: IRuleConfig = { | ||
rules: { | ||
oas2: { | ||
'lint:test': true, | ||
}, | ||
}, | ||
}; | ||
|
||
const s = new Spectral(initialConfig); | ||
// run once with no override config | ||
let results = s.apply(spec, 'oas2'); | ||
expect(results.length).toEqual(0); | ||
|
||
// run again with an override config | ||
results = s.apply(spec, 'oas2', overrideConfig); | ||
expect(results.length).toEqual(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters