Skip to content

Commit 622e56c

Browse files
committed
chore(tests): fixes OS-based difference in git log output
Windows git and *nix git output of the log command treats empty lines differently. Windows trims the spaces while *nix leaves them intact. This means that when comparing output in a test, we need to take into account whether the output of the os when determining if the test failed or not.
1 parent 30c7b55 commit 622e56c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/tests/commit.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {expect} from 'chai';
2-
import path from 'path';
32
import fs from 'fs';
3+
import os from 'os';
4+
import path from 'path';
45
import _ from 'lodash';
56

67
import inquirer from 'inquirer';
@@ -79,13 +80,24 @@ describe('commit', function() {
7980

8081
// SETUP
8182

82-
let dummyCommitMessage = `sip sip sippin on jnkjnkjn
83-
some sizzurp`;
83+
// Don't trim or delete the spacing in this commit message!
8484

85-
dummyCommitMessage = `sip sip sippin on jnkjnkjn
85+
// Git on *nix retains spaces on lines with only spaces
86+
// The blank line of this block should have 4 spaces.
87+
let nixCommitMessage =
88+
`sip sip sippin on jnkjnkjn
8689
8790
some sizzurp`;
8891

92+
// Git on win32 removes spaces from lines with only spaces
93+
// The blank line of this block should have no spaces
94+
let windowsCommitMessage =
95+
`sip sip sippin on jnkjnkjn
96+
97+
some sizzurp`;
98+
99+
let dummyCommitMessage = (os.platform == 'win32') ? windowsCommitMessage : nixCommitMessage;
100+
89101
// Describe a repo and some files to add and commit
90102
let repoConfig = {
91103
path: config.paths.endUserRepo,

0 commit comments

Comments
 (0)