Skip to content
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

Support for custom file extensions #115

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ coverage/

# VS Code settings folder
.settings/

# IntelliJ
.idea/
3 changes: 1 addition & 2 deletions lib/Approvals.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ var verifyAndScrub = function (dirName, testName, data, scrubber, optionsOverrid
writer = new BinaryWriter(newOptions, data);
} else {
data = scrubber(data);

writer = new StringWriter(newOptions, data);
writer = new StringWriter(newOptions, data, newOptions.fileExtension);
}
verifyWithControl(namer, writer, null, newOptions);
};
Expand Down
7 changes: 7 additions & 0 deletions test/approvalsTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ describe('approvals', function () {

approvals.verify(__dirname, "basic-image-test-png", imgBuffer);
});

it("should use a overridden file name extension", function () {
var testName = "overridden file extension";
var dataToVerify = "<html><body>Hello, world!</body></html>"
let overrideWithFileExtension = Object.assign({ fileExtension: "html" }, approvalOverrides);
approvals.verify(__dirname, testName, dataToVerify, overrideWithFileExtension)
});
});

describe('verifyAsJSON', function () {
Expand Down
1 change: 1 addition & 0 deletions test/overridden file extension.approved.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><body>Hello, world!</body></html>