Show options when a test fails when running specs

This commit is contained in:
Glavin Wiechert 2015-06-10 17:02:22 -03:00
parent 9afde9bfd1
commit 01d7f2f9bb
3 changed files with 25 additions and 3 deletions

View File

@ -18,7 +18,6 @@
indent_char: " " indent_char: " "
indent_size: 2 indent_size: 2
preserve_newlines: true preserve_newlines: true
# newline_between_rules: true
js: js:
indent_size: 2 indent_size: 2
indent_char: " " indent_char: " "

View File

@ -183,8 +183,15 @@ describe "BeautifyLanguages", ->
newStr=expectedContents newStr=expectedContents
oldHeader="beautified" oldHeader="beautified"
newHeader="expected" newHeader="expected"
diff = JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader) diff = JsDiff.createPatch(fileName, oldStr, \
expect(text).toEqual(expectedContents, "Beautifier output does not match expected output:\n"+diff) 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! # All done!
beautifyCompleted = true beautifyCompleted = true

View File

@ -289,6 +289,22 @@ module.exports = class Beautifiers extends EventEmitter
_.contains(beautifier.languages, language) _.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} = {}) -> beautify : (text, allOptions, grammar, filePath, {onSave} = {}) ->
return Promise.all(allOptions) return Promise.all(allOptions)