Show options when a test fails when running specs
This commit is contained in:
parent
9afde9bfd1
commit
01d7f2f9bb
|
@ -18,7 +18,6 @@
|
|||
indent_char: " "
|
||||
indent_size: 2
|
||||
preserve_newlines: true
|
||||
# newline_between_rules: true
|
||||
js:
|
||||
indent_size: 2
|
||||
indent_char: " "
|
||||
|
|
|
@ -183,8 +183,15 @@ describe "BeautifyLanguages", ->
|
|||
newStr=expectedContents
|
||||
oldHeader="beautified"
|
||||
newHeader="expected"
|
||||
diff = JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader)
|
||||
expect(text).toEqual(expectedContents, "Beautifier output does not match expected output:\n"+diff)
|
||||
diff = JsDiff.createPatch(fileName, oldStr, \
|
||||
newStr, oldHeader, newHeader)
|
||||
opts = beautifier.getOptions(allOptions, \
|
||||
grammarName, testFileName)
|
||||
expect(text).toEqual(expectedContents, \
|
||||
"Beautifier output does not match expected \
|
||||
output:\n#{diff}\n\n\
|
||||
With options:\n\
|
||||
#{JSON.stringify(opts, undefined, 4)}")
|
||||
# All done!
|
||||
beautifyCompleted = true
|
||||
|
||||
|
|
|
@ -289,6 +289,22 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
_.contains(beautifier.languages, language)
|
||||
)
|
||||
|
||||
getOptions : (allOptions, grammar, filePath) ->
|
||||
# Get language
|
||||
fileExtension = path.extname(filePath)
|
||||
# Remove prefix "." (period) in fileExtension
|
||||
fileExtension = fileExtension.substr(1)
|
||||
languages = @languages.getLanguages({grammar, extension: fileExtension})
|
||||
logger.verbose(languages, grammar, fileExtension)
|
||||
# Check if unsupported language
|
||||
if languages.length < 1
|
||||
return null
|
||||
else
|
||||
# TODO: select appropriate language
|
||||
language = languages[0]
|
||||
# Options for Language
|
||||
options = @getOptions([language.namespace]\
|
||||
.concat(language.fallback or []), allOptions) or {}
|
||||
|
||||
beautify : (text, allOptions, grammar, filePath, {onSave} = {}) ->
|
||||
return Promise.all(allOptions)
|
||||
|
|
Loading…
Reference in New Issue