-
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(core): pass client through to init schematic
Use the same client in the generator and schematic for test consistency
- Loading branch information
Ben Callaghan
committed
May 18, 2021
1 parent
96082a1
commit 5908947
Showing
3 changed files
with
21 additions
and
5 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,33 +1,49 @@ | ||
import { readJson, Tree } from '@nrwl/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet'; | ||
|
||
import { CONFIG_FILE_PATH, NxDotnetConfig } from '@nx-dotnet/utils'; | ||
|
||
import generator from './generator'; | ||
|
||
describe('init generator', () => { | ||
let appTree: Tree; | ||
let dotnetClient: DotNetClient; | ||
|
||
beforeEach(() => { | ||
appTree = createTreeWithEmptyWorkspace(); | ||
dotnetClient = new DotNetClient(mockDotnetFactory()); | ||
}); | ||
|
||
it('should create config', async () => { | ||
await generator(appTree); | ||
await generator(appTree, dotnetClient); | ||
const config = appTree.isFile(CONFIG_FILE_PATH); | ||
expect(config).toBeTruthy(); | ||
}); | ||
|
||
it('should update gitignore', async () => { | ||
appTree.write('.gitignore', ''); | ||
await generator(appTree); | ||
await generator(appTree, dotnetClient); | ||
const gitignoreValue = appTree.read('.gitignore')?.toString(); | ||
expect(gitignoreValue).toBeTruthy(); | ||
}); | ||
|
||
it('should put dependency array inside config', async () => { | ||
await generator(appTree); | ||
await generator(appTree, dotnetClient); | ||
const config: NxDotnetConfig = readJson(appTree, CONFIG_FILE_PATH); | ||
expect(config.nugetPackages).toBeDefined(); | ||
}); | ||
|
||
it('should create tool manifest', async () => { | ||
const spy = spyOn(dotnetClient, 'new'); | ||
await generator(appTree, dotnetClient); | ||
expect(spy).toHaveBeenCalledWith('tool-manifest'); | ||
}); | ||
|
||
it('should not create tool manifest if it exists', async () => { | ||
appTree.write('.config/dotnet-tools.json', ''); | ||
const spy = spyOn(dotnetClient, 'new'); | ||
await generator(appTree, dotnetClient); | ||
expect(spy).not.toHaveBeenCalled(); | ||
}); | ||
}); |
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
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