-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reset defaults before tests #1212
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1345,25 +1345,36 @@ marked.setOptions = function(opt) { | |
return marked; | ||
}; | ||
|
||
marked.defaults = { | ||
baseUrl: null, | ||
breaks: false, | ||
gfm: true, | ||
headerIds: true, | ||
headerPrefix: '', | ||
highlight: null, | ||
langPrefix: 'lang-', | ||
mangle: true, | ||
pedantic: false, | ||
renderer: new Renderer(), | ||
sanitize: false, | ||
sanitizer: null, | ||
silent: false, | ||
smartLists: false, | ||
smartypants: false, | ||
tables: true, | ||
xhtml: false | ||
}; | ||
marked.getDefaults = function () { | ||
var defaults = { | ||
baseUrl: null, | ||
breaks: false, | ||
gfm: true, | ||
headerIds: true, | ||
headerPrefix: '', | ||
highlight: null, | ||
langPrefix: 'lang-', | ||
mangle: true, | ||
pedantic: false, | ||
renderer: new Renderer(), | ||
sanitize: false, | ||
sanitizer: null, | ||
silent: false, | ||
smartLists: false, | ||
smartypants: false, | ||
tables: true, | ||
xhtml: false | ||
}; | ||
|
||
var clone = {}; | ||
for (var opt in defaults) { | ||
clone[opt] = defaults[opt]; | ||
} | ||
|
||
return clone; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the clone still necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you are saying |
||
} | ||
|
||
marked.defaults = marked.getDefaults(); | ||
|
||
/** | ||
* Expose | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var marked = require('../../lib/marked.js'); | ||
|
||
beforeEach(function () { | ||
marked.setOptions(marked.getDefaults()); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to do this as part of the test itself instead of the lib? Believe @styfle mentioned something like that before. Thinking it would be better to have the test use a blank object over the singleton pattern that seems preferred by Node (understandably in many use cases).