diff --git a/test/AUtilsTests.ts b/test/AUtilsTests.ts index 49cc1316..99a5eb94 100644 --- a/test/AUtilsTests.ts +++ b/test/AUtilsTests.ts @@ -1,37 +1,35 @@ -"use strict"; - -var utils = require("../lib/AUtils"); -var os = require("../lib/osTools"); -var assert = require("assert"); -var expect = require("chai").expect; +import assert from "assert"; +import {expect} from "chai"; +import {assertFileExists, fixFilePathSlashes, searchForExecutable, stringifyKeysInOrder} from "../lib/AUtils"; +import {platform} from "../lib/osTools"; describe("AUtils", function () { // only run these tests on Windows - if (os.platform.isWindows) { + if (platform.isWindows) { describe("searchForExecutable", function () { if (!process.env.APPVEYOR) { describe("when using windows where.exe to find programs", function () { it("ipconfig should be found once", function () { - var file = utils.searchForExecutable("ipconfig"); + const file = searchForExecutable("ipconfig"); - utils.assertFileExists(file); + assertFileExists(file); }); it("notepad is found multiple times and we should just use the first one", function () { - var file = utils.searchForExecutable("ipconfig"); + const file = searchForExecutable("ipconfig"); - utils.assertFileExists(file); + assertFileExists(file); }); }); describe("When looking for a program in program files", function () { it("should find iexplorer", function () { - var file = utils.searchForExecutable( + const file = searchForExecutable( "Internet Explorer", "iexplore", ); - utils.assertFileExists(file); + assertFileExists(file); }); }); } @@ -40,9 +38,9 @@ describe("AUtils", function () { describe("find linux executable", function () { describe("when using linux 'which' to find programs", function () { it("ifconfig should be found once", function () { - var file = utils.searchForExecutable("ifconfig"); + const file = searchForExecutable("ifconfig"); - utils.assertFileExists(file); + assertFileExists(file); }); }); }); @@ -50,17 +48,17 @@ describe("AUtils", function () { describe("fixFilePathSlashes", function () { it("should replace back slashes with forward slashes", function () { - var before = "C:\\Windows\\System32\\ipconfig.exe"; - var expected = "C:/Windows/System32/ipconfig.exe"; + const before = "C:\\Windows\\System32\\ipconfig.exe"; + const expected = "C:/Windows/System32/ipconfig.exe"; - var fixed = utils.fixFilePathSlashes(before); + const fixed = fixFilePathSlashes(before); assert.strictEqual(fixed, expected); }); }); describe("stringifyKeysInOrder", function () { - var expected = `{ + const expected = `{ "a": 1, "aSub": { "a": 1, @@ -84,7 +82,7 @@ describe("AUtils", function () { ] }`; it("should return proper string with keys in order", function () { - var result = utils.stringifyKeysInOrder({ + const result = stringifyKeysInOrder({ a: 1, aSub: { a: 1, @@ -108,7 +106,7 @@ describe("AUtils", function () { }); it("should return proper string with keys in order", function () { - var result = utils.stringifyKeysInOrder({ + const result = stringifyKeysInOrder({ b: 2, arr: [1, 2], aSub: { diff --git a/test/approvalsTests.test.ts b/test/approvalsTests.test.ts new file mode 100644 index 00000000..6061dc80 --- /dev/null +++ b/test/approvalsTests.test.ts @@ -0,0 +1,101 @@ +import fs from "fs"; +import path from "path"; +import {scrubbers, verify, verifyAsJSON, verifyAsJSONAndScrub} from "../lib/Approvals"; + +const approvalOverrides = { + EOL: "\r\n", + normalizeLineEndingsTo: "\n", + appendEOL: false, +}; + +describe("approvals", function () { + describe("verify", function () { + it("can verify some manual text", function () { + const testName = "manualVerification"; + const dataToVerify = "some stuff here"; + verify(__dirname, testName, dataToVerify, approvalOverrides); + }); + + it("should verify an image", function () { + // copy of the Approvals logo but base64 encoded + const logoBase46 = + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABICAYAAABLJIP0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOnAAADpwBB5RT3QAAAAd0SU1FB9oFDwUeFsmsQqoAAA8/SURBVHja7dx7dBRVngfw7739qOpOd+dFQicxvBEBQWFwRTCPzoOEkIg4Q84gHkdnHF1m3Jnjzuxxxj1nN2dn15lxnXVmEGdHBVEMsCCghEd45Ak+EBBERV4aIJAgkoSk8+hX3d/+kVTokK7uDuSBaJ1TJ6cq6ep7P/37/ereqq4A3y3fLX1Z2FA3oKl42khO4ldg+D4DthDY85GLD5/8VsM0r5o+jnGlgoBb/HeDU07koiP7vpUwGijq0gKinMiHjnzwrYIJgXJD4PDBfkNn6aLJ3JZQHQIFAGxgbEfL6mn33PQR4yxdNBnMUA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In3lwWWLLzQemx9hGn4wOjL2pZSpP2vqr/YP6BNuj6/bO4LDXQ3CyGAo6tTiXJMTF51tIeqO+KpDZx51uuhRFxHpPR5MaGior0lMTGzvz7YP6GM5Lxfee1ZASlWEOBMKhYiQGBmBOIspWDEGEYYbPW0Pdc19fJLEPutvlAGHUXF8MKYoRKeDoahros2COIsp6MQToLkD3e5Bee76tUVptW0dlKoQ1QRDUeGSIi2Is5i1Z8yKsummgAGAtT/OqXW3K6lCUE0wFBUuMdKCeKs50G3aU+0m08abBgYAin+ad87tolQCfRkMRYXrhSPoFAk46oqeaB/otg7J/3ZY+HpJkplYNUBjQtcd4HxTC+ovO0+RgOPUc784NxhtHLL/BrLwbyVJkkTVnGFMMBQCgRPONXY4U0qfevT0YLWPDxXM+iUF591uV6oi1LTSRtFznjmYKEMaMeryw+XvJHIhqjnDWC2UNx5/4MRgt4sPNczan8yva3W5UkF05CqUs0OFckNEjN/9bsOfyz/80emLjXnJ0bZ3742Kf2XmzPEt+G7pxHG73VOIKGKo2/L/F13OuWHkDdYAAAAASUVORK5CYII="; + + // copied how to save a base64 image to disk by using + // http://stackoverflow.com/questions/6926016/nodejs-saving-a-base64-encoded-image-to-disk + const base64Data = logoBase46.replace(/^data:image\/png;base64,/, ""); + const imgBuffer = Buffer.from(base64Data, "base64"); + + verify(__dirname, "basic-image-test-png", imgBuffer); + }); + + it("should verify an image 2", function () { + const testImage = path.join(__dirname, "basic-image-test-png.approved.png"); + const imgBuffer = fs.readFileSync(testImage); + + verify(__dirname, "basic-image-test-png", imgBuffer); + }); + }); + + describe("verifyAsJSON", function () { + it("can verify some json object", function () { + const testName = "manualVerificationAsJSON"; + const dataToVerify = { + x: "some stuff here", + y: 123, + }; + verifyAsJSON( + __dirname, + testName, + dataToVerify, + approvalOverrides, + ); + }); + + it("can be run with same JSON but keys ordered differently", function () { + const testName = "manualVerificationAsJSON-Ordered"; + const dataToVerify = { + x: "some stuff here", + y: 123, + }; + verifyAsJSON( + __dirname, + testName, + dataToVerify, + approvalOverrides, + ); + + const dataToVerify2 = { + y: 123, + x: "some stuff here", + }; + verifyAsJSON( + __dirname, + testName, + dataToVerify2, + approvalOverrides, + ); + }); + }); + + describe("verifyAsJSONAndScrub", function () { + it("can verify and scrub some json object", function () { + const testName = "manualverifyAsJSONAndScrub"; + const dataToVerify = { + x: "some stuff here", + y: 123, + sampleGuid: "3dda561f-903d-4a89-8c96-99ca6272e53d", + sampleGuid2: "11111111-1111-1111-1111-111111111111", + sampleGuidRepeated: "3dda561f-903d-4a89-8c96-99ca6272e53d", + }; + + verifyAsJSONAndScrub( + __dirname, + testName, + dataToVerify, + scrubbers.guidScrubber, + approvalOverrides, + ); + }); + }); +}); diff --git a/test/approvalsTestsReportedIssuesTests.ts b/test/approvalsTestsReportedIssuesTests.ts index 46c85d14..d8a1ff40 100644 --- a/test/approvalsTestsReportedIssuesTests.ts +++ b/test/approvalsTestsReportedIssuesTests.ts @@ -1,5 +1,5 @@ -var approvals = require("../lib/Approvals"); -var expect = require("chai").expect; +import {verify} from "../lib/Approvals"; +import {expect} from "chai"; describe("When issues are reported on github", () => { it("Issue #86: Issues with Buffer Compare Loop", () => { @@ -22,13 +22,13 @@ describe("When issues are reported on github", () => { var testName = "manualVerification"; var dataToVerify = "some stuff here"; - approvals.verify(__dirname, testName, dataToVerify, approvalOverrides); + verify(__dirname, testName, dataToVerify, approvalOverrides); approvalOverrides.forceApproveAll = false; dataToVerify = "some stuff here - also"; expect(() => { - approvals.verify(__dirname, testName, dataToVerify, approvalOverrides); + verify(__dirname, testName, dataToVerify, approvalOverrides); }).throws(Error); }); }); diff --git a/test/commandLineTests.ts b/test/commandLineTests.ts index afe19cf5..ab7b1c9e 100644 --- a/test/commandLineTests.ts +++ b/test/commandLineTests.ts @@ -1,12 +1,9 @@ -"use strict"; - -/// -var shelljs = require("shelljs"); -var path = require("path"); +import shelljs from "shelljs"; +import path from "path"; describe("Command Line", function () { it("Should run approvals CLI with basic text input", function (done) { - var cliTestCommand = + const cliTestCommand = 'echo "Hello\nWorld" | ' + path.join("./", "bin", "index.js") + " --reporter gitdiff --errorOnStaleApprovedFiles=false --outdir ./test commandlineTest"; diff --git a/test/configTests.ts b/test/configTests.ts index 7bbe5715..96c086a0 100644 --- a/test/configTests.ts +++ b/test/configTests.ts @@ -1,17 +1,16 @@ -import chai from "chai"; +import {expect} from "chai"; import sinon from "sinon"; import fs from "fs"; import _ from "lodash"; -import * as cfg from "../lib/config"; +import {defaultConfig, getConfig, getHomeApprovalConfig, reset} from "../lib/config"; -var expect = chai.expect; describe("config.js - ", function () { - var fsExistsSyncStub; - var fsReadFileSyncStub; + let fsExistsSyncStub; + let fsReadFileSyncStub; beforeEach(function () { fsExistsSyncStub = null; - cfg.reset(); + reset(); }); afterEach(function () { @@ -32,20 +31,20 @@ describe("config.js - ", function () { }); it("should not find config in user home directory", function () { - var configFile = cfg.getHomeApprovalConfig(); + const configFile = getHomeApprovalConfig(); expect(configFile).to.not.exist; }); it("should load default config", function () { - cfg.reset(); - var configFile = cfg.getConfig(); - expect(configFile).to.deep.equal(cfg.defaultConfig); + reset(); + const configFile = getConfig(); + expect(configFile).to.deep.equal(defaultConfig); }); }); describe("when a config file exists in a user's home directory", function () { - var configToLoad; + let configToLoad; beforeEach(function () { configToLoad = {}; @@ -56,7 +55,7 @@ describe("config.js - ", function () { fsReadFileSyncStub = sinon .stub(fs, "readFileSync") .callsFake(function () { - var data = + const data = typeof configToLoad === "string" ? configToLoad : JSON.stringify(configToLoad, null, " "); @@ -65,7 +64,7 @@ describe("config.js - ", function () { }); it("should find config in user home directory", function () { - var configFile = cfg.getHomeApprovalConfig(); + const configFile = getHomeApprovalConfig(); expect(configFile).to.exist; }); @@ -75,7 +74,7 @@ describe("config.js - ", function () { reporters: ["gitdiff"], }; - var configFile = cfg.getHomeApprovalConfig(); + const configFile = getHomeApprovalConfig(); expect(configFile?.reporters).to.deep.equal(["gitdiff"]); }); @@ -91,9 +90,9 @@ describe("config.js - ", function () { configToLoad = { myConfig: true, }; - var expectedConfig = _.defaults(configToLoad, cfg.defaultConfig); - cfg.reset(); - var configFile = cfg.getConfig(); + const expectedConfig = _.defaults(configToLoad, defaultConfig); + reset(); + const configFile = getConfig(); expect(configFile).to.deep.equal(expectedConfig); }); }); diff --git a/test/namerTests.ts b/test/namerTests.ts index 79823eef..8dab9999 100644 --- a/test/namerTests.ts +++ b/test/namerTests.ts @@ -1,15 +1,13 @@ -"use strict"; - -var assert = require("assert"); -var path = require("path"); -var Namer = require("../lib/Namer").Namer; +import assert from "assert"; +import path from "path"; +import {Namer} from "../lib/Namer"; describe("Namer", function () { describe("getReceivedFile & approvedFile", function () { it("should format a path that has no trailing separator", function () { - var pathWithoutTrailingSlash = "C:\\temp"; - var fileName = "foo.js"; - var namer = new Namer(pathWithoutTrailingSlash, fileName); + const pathWithoutTrailingSlash = "C:\\temp"; + const fileName = "foo.js"; + const namer = new Namer(pathWithoutTrailingSlash, fileName); assert.strictEqual( namer.getReceivedFile("txt"), @@ -23,9 +21,9 @@ describe("Namer", function () { }); it("should clean up not normalized input", function () { - var pathWithoutTrailingSlash = "C:\\temp" + path.sep; - var fileName = "foo.js."; - var namer = new Namer(pathWithoutTrailingSlash, fileName); + const pathWithoutTrailingSlash = "C:\\temp" + path.sep; + const fileName = "foo.js."; + const namer = new Namer(pathWithoutTrailingSlash, fileName); assert.strictEqual( namer.getReceivedFile(".txt"), diff --git a/test/readmeTests.ts b/test/readmeTests.ts index eb78cdd4..87aef600 100644 --- a/test/readmeTests.ts +++ b/test/readmeTests.ts @@ -1,26 +1,25 @@ -var path = require("path"); -var fs = require("fs"); - -var StringWriter = require("../lib/StringWriter").StringWriter; -var approvals = require("../lib/Approvals"); -var jsdoc2md = require("jsdoc-to-markdown"); +import path from "path"; +import fs from "fs"; +import {StringWriter} from "../lib/StringWriter"; +import jsdoc2md from "jsdoc-to-markdown"; +import {getConfig, verifyWithControl} from "../lib/Approvals"; describe("Readme", function () { it("Should not allow the readme docs to get out of sync", function () { - var currentReadme = fs + const currentReadme = fs .readFileSync(path.join(__dirname, "../", "readme.md")) .toString(); - var cliDocsRaw = fs + let cliDocsRaw = fs .readFileSync(path.join(__dirname, "../bin", "help.md")) .toString(); cliDocsRaw = cliDocsRaw.replace(/ /g, " ").replace(/\*\*/g, ""); - var approvalsSource = fs + const approvalsSource = fs .readFileSync(path.join(__dirname, "../lib", "Approvals.js")) .toString(); - var jsdocsOutput = jsdoc2md.renderSync({ + let jsdocsOutput = jsdoc2md.renderSync({ source: approvalsSource, "no-cache": true, }); @@ -31,13 +30,13 @@ describe("Readme", function () { }) .join("\n"); - var newDocs = ""; + let newDocs = ""; newDocs += "\n"; newDocs += "\n"; newDocs += "\n\n" + jsdocsOutput; newDocs += "\n\n"; - var cliDocs = ""; + let cliDocs = ""; cliDocs += "\n"; cliDocs += "\n"; cliDocs += "\n```"; @@ -45,7 +44,7 @@ describe("Readme", function () { cliDocs += "\n```"; cliDocs += "\n\n"; - var reporterList = ""; + let reporterList = ""; reporterList += "\n"; reporterList += "\n"; @@ -64,7 +63,7 @@ describe("Readme", function () { reporterList += "\n```"; reporterList += "\n"; - var resultingReadme = currentReadme + const resultingReadme = currentReadme .replace(/[\s\S]*/gm, newDocs) .replace(/[\s\S]*/gm, cliDocs) .replace( @@ -72,16 +71,16 @@ describe("Readme", function () { reporterList, ); - var config = approvals.getConfig(); + const config = getConfig(); config.EOL = "\n"; config.normalizeLineEndingsTo = "\n"; console.log(config); - var writer = new StringWriter( + const writer = new StringWriter( config, resultingReadme.replace(/(?:\r\n|\r|\n)/g, "\n"), ); - var namer = { + const namer = { getReceivedFile: function () { return path.join(__dirname, "..", "readme.received.md"); }, @@ -90,6 +89,6 @@ describe("Readme", function () { }, }; - approvals.verifyWithControl(namer, writer, null, config); + verifyWithControl(namer, writer, null, config); }); });