Major improvement to tests: display diff of original vs expected
This commit is contained in:
parent
9d6dc8d04f
commit
5797b4bb00
|
@ -54,6 +54,7 @@
|
||||||
"atom-space-pen-views": "^2.0.3",
|
"atom-space-pen-views": "^2.0.3",
|
||||||
"bluebird": "^2.9.25",
|
"bluebird": "^2.9.25",
|
||||||
"coffee-formatter": "^0.1.1",
|
"coffee-formatter": "^0.1.1",
|
||||||
|
"diff": "^1.3.2",
|
||||||
"editorconfig": "^0.11.4",
|
"editorconfig": "^0.11.4",
|
||||||
"emissary": "^1.0.0",
|
"emissary": "^1.0.0",
|
||||||
"expand-home-dir": "0.0.2",
|
"expand-home-dir": "0.0.2",
|
||||||
|
|
|
@ -3,6 +3,7 @@ Beautifiers = require "../src/beautifiers"
|
||||||
beautifier = new Beautifiers()
|
beautifier = new Beautifiers()
|
||||||
fs = require "fs"
|
fs = require "fs"
|
||||||
path = require "path"
|
path = require "path"
|
||||||
|
JsDiff = require('diff')
|
||||||
|
|
||||||
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
|
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
|
||||||
#
|
#
|
||||||
|
@ -135,9 +136,18 @@ describe "BeautifyLanguages", ->
|
||||||
if text instanceof Error
|
if text instanceof Error
|
||||||
return beautifyCompleted = text # text == Error
|
return beautifyCompleted = text # text == Error
|
||||||
expect(typeof text).toEqual "string"
|
expect(typeof text).toEqual "string"
|
||||||
|
# Check for beautification errors
|
||||||
if text isnt expectedContents
|
if text isnt expectedContents
|
||||||
console.warn(allOptions, text, expectedContents)
|
# console.warn(allOptions, text, expectedContents)
|
||||||
expect(text).toEqual expectedContents
|
fileName = originalTestPath
|
||||||
|
oldStr=text
|
||||||
|
newStr=expectedContents
|
||||||
|
oldHeader="original"
|
||||||
|
newHeader="expected"
|
||||||
|
diff = JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader)
|
||||||
|
throw new Error("Beautifier output does not match expected output:\n"+diff)
|
||||||
|
#expect(text).toEqual expectedContents
|
||||||
|
# All done!
|
||||||
beautifyCompleted = true
|
beautifyCompleted = true
|
||||||
|
|
||||||
runs ->
|
runs ->
|
||||||
|
|
Loading…
Reference in New Issue