From 1096f80bd9934848cbd0d9d5b74466a9ce525aa0 Mon Sep 17 00:00:00 2001 From: Ognjen Jevremovic Date: Fri, 26 Mar 2021 08:54:37 +0100 Subject: [PATCH] test(tests/staging.js): preserve the functionality of the --all flag Extend upon the existing staging unit tests. Assert that the files are added to staging area when running commitizen commit command with -a (--all) flag, prior to spawning the prompt. "re #785" --- test/tests/staging.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/tests/staging.js b/test/tests/staging.js index 02e8c4fd..2ff77256 100644 --- a/test/tests/staging.js +++ b/test/tests/staging.js @@ -78,6 +78,43 @@ describe('staging', function () { }); }); + it('should determine if --all flag adds files to staging area', function (done) { + + this.timeout(config.maxTimeout); // this could take a while + + // SETUP + + // Describe a repo and some files to add and commit + let repoConfig = { + path: config.paths.endUserRepo, + files: { + dummyfile: { + contents: `duck-duck-gray-duck`, + filename: `mydummiestfile.txt`, + }, + gitignore: { + contents: `node_modules/`, + filename: `.gitignore` + } + } + }; + + gitInit(repoConfig.path); + + staging.isClean(repoConfig.path, function (stagingIsCleanError, stagingIsClean) { + expect(stagingIsCleanError).to.be.null; + expect(stagingIsClean).to.be.true; + + writeFilesToPath(repoConfig.files, repoConfig.path); + + staging.isClean(repoConfig.path, function (afterWriteStagingIsCleanError, afterWriteStagingIsClean) { + expect(afterWriteStagingIsCleanError).to.be.null; + expect(afterWriteStagingIsClean).to.be.true; + + done(); + }); + }, true); + }); }); afterEach(function () {