|
| 1 | +import { SimpleGit } from '../../typings'; |
| 2 | +import { assertExecutedCommands, closeWithSuccess, newSimpleGit } from './__fixtures__'; |
| 3 | +import { pathspec } from '../../src/lib/args/pathspec'; |
| 4 | + |
| 5 | +describe('suffixPathsPlugin', function () { |
| 6 | + let git: SimpleGit; |
| 7 | + |
| 8 | + beforeEach(() => (git = newSimpleGit())); |
| 9 | + |
| 10 | + it('moves pathspec to end', async () => { |
| 11 | + git.raw(['a', pathspec('b'), 'c']); |
| 12 | + await closeWithSuccess(); |
| 13 | + |
| 14 | + assertExecutedCommands('a', 'c', '--', 'b'); |
| 15 | + }); |
| 16 | + |
| 17 | + it('moves multiple pathspecs to end', async () => { |
| 18 | + git.raw(['a', pathspec('b'), 'c', pathspec('d'), 'e']); |
| 19 | + await closeWithSuccess(); |
| 20 | + |
| 21 | + assertExecutedCommands('a', 'c', 'e', '--', 'b', 'd'); |
| 22 | + }); |
| 23 | + |
| 24 | + it('ignores processing after a pathspec split', async () => { |
| 25 | + git.raw('a', pathspec('b'), '--', 'c', pathspec('d'), 'e'); |
| 26 | + await closeWithSuccess(); |
| 27 | + |
| 28 | + assertExecutedCommands('a', '--', 'b', 'c', 'd', 'e'); |
| 29 | + }); |
| 30 | + |
| 31 | + it('flattens pathspecs after an explicit splitter', async () => { |
| 32 | + git.raw('a', '--', 'b', pathspec('c', 'd'), 'e'); |
| 33 | + await closeWithSuccess(); |
| 34 | + |
| 35 | + assertExecutedCommands('a', '--', 'b', 'c', 'd', 'e'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('accepts multiple paths in one pathspec argument', async () => { |
| 39 | + git.raw('a', pathspec('b', 'c'), 'd'); |
| 40 | + await closeWithSuccess(); |
| 41 | + |
| 42 | + assertExecutedCommands('a', 'd', '--', 'b', 'c'); |
| 43 | + }); |
| 44 | + |
| 45 | + it('accepted as value of an option', async () => { |
| 46 | + git.pull({ |
| 47 | + foo: null, |
| 48 | + blah1: pathspec('a', 'b'), |
| 49 | + blah2: pathspec('c', 'd'), |
| 50 | + bar: null, |
| 51 | + }); |
| 52 | + |
| 53 | + await closeWithSuccess(); |
| 54 | + assertExecutedCommands('pull', 'foo', 'bar', '--', 'a', 'b', 'c', 'd'); |
| 55 | + }); |
| 56 | +}); |
0 commit comments