Skip to content

Commit

Permalink
snapshot: Revert transform function
Browse files Browse the repository at this point in the history
  • Loading branch information
lauriro committed Oct 5, 2024
1 parent 5b5ef43 commit 4c85b01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe.assert.cmdSnapshot = function(cmd, file, opts) {
}

describe.assert.matchSnapshot = function(file, actual, snapFile) {
if (typeof actual === "function") actual = actual(fs.readFileSync(path.resolve(file), "utf8"))
if (!actual) actual = fs.readFileSync(path.resolve(file), "utf8")
var expected
, enc = typeof actual === "string" ? "utf8" : null
Expand Down
10 changes: 10 additions & 0 deletions test/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ describe("snapshot.js", function() {
assert.cmdSnapshot(cmd, file, opts).end()
})

it("should test transformed snapshots", function(assert) {
assert.matchSnapshot(
"./test/spec/test-transform",
function(str) {
return str.replace(/\\/g, "/")
}
)
assert.end()
})

it("should test status code", [
["node -r ./test.js test/test-fail.js", 12],
["node -r ./test.js test/snapshot-fail.js", 3],
Expand Down
6 changes: 6 additions & 0 deletions test/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,11 @@ describe("tools", function() {
cli.rmrf(".github/.dot2")
assert.end()
})

it ("should deepAssign", function(assert) {
cli.deepAssign({}, JSON.parse('{"__proto__": {"devMode": true}}'))
assert.notOk({}.devMode)
assert.end()
})
})

0 comments on commit 4c85b01

Please sign in to comment.