-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dotnet): update handling of extraParameters to be compatible with…
… spawn (#403)
- Loading branch information
1 parent
84bde4c
commit 65f0c48
Showing
3 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { DotNetClient } from './dotnet.client'; | ||
import { mockDotnetFactory } from './dotnet.factory'; | ||
import * as cp from 'child_process'; | ||
|
||
describe('dotnet client', () => { | ||
describe('publish', () => { | ||
describe('extra parameters', () => { | ||
const dotnetClient = new DotNetClient(mockDotnetFactory()); | ||
|
||
let spawnSyncSpy: jest.SpyInstance; | ||
|
||
beforeEach(() => { | ||
spawnSyncSpy = jest | ||
.spyOn(cp, 'spawnSync') | ||
.mockImplementation(jest.fn()); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it('should handle multiple parameters', () => { | ||
dotnetClient.publish( | ||
'my-project', | ||
undefined, | ||
undefined, | ||
'--flag --other-flag', | ||
); | ||
expect(spawnSyncSpy.mock.calls[0][1]).toContain('--flag'); | ||
expect(spawnSyncSpy.mock.calls[0][1]).toContain('--other-flag'); | ||
expect(spawnSyncSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should handle multiple parameters with quotations', () => { | ||
dotnetClient.publish( | ||
'my-project', | ||
undefined, | ||
undefined, | ||
`--flag \\p:"my project"`, | ||
); | ||
expect(spawnSyncSpy.mock.calls[0][1]).toContain('--flag'); | ||
expect(spawnSyncSpy.mock.calls[0][1]).toContain('\\p:"my project"'); | ||
expect(spawnSyncSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should handle several parameters', () => { | ||
dotnetClient.publish( | ||
'my-project', | ||
undefined, | ||
undefined, | ||
`--self-contained=false /p:CopyOutputSymbolsToPublishDirectory=false /p:Version=2022.03.25.1 /p:VersionAssembly=2022.03.25.1 /p:Name:"My Project"`, | ||
); | ||
expect(spawnSyncSpy.mock.calls[0][1]).toMatchInlineSnapshot(` | ||
Array [ | ||
"publish", | ||
"\\"my-project\\"", | ||
"--self-contained=false", | ||
"/p:CopyOutputSymbolsToPublishDirectory=false", | ||
"/p:Version=2022.03.25.1", | ||
"/p:VersionAssembly=2022.03.25.1", | ||
"/p:Name:\\"My Project\\"", | ||
] | ||
`); | ||
expect(spawnSyncSpy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters