-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schematics): only begin converting to workspace once files have b…
…een checked
- Loading branch information
1 parent
3670fd4
commit e7fd6b1
Showing
2 changed files
with
69 additions
and
0 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
49 changes: 49 additions & 0 deletions
49
packages/schematics/src/collection/workspace/workspace.spec.ts
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,49 @@ | ||
import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; | ||
import * as path from 'path'; | ||
import { Tree, VirtualTree } from '@angular-devkit/schematics'; | ||
import { getFileContent } from '@schematics/angular/utility/test'; | ||
|
||
describe('workspace', () => { | ||
const schematicRunner = new SchematicTestRunner('@nrwl/schematics', path.join(__dirname, '../../collection.json')); | ||
|
||
let appTree: Tree; | ||
|
||
beforeEach(() => { | ||
appTree = new VirtualTree(); | ||
}); | ||
|
||
it('should error if no package.json is present', () => { | ||
expect(() => { | ||
const tree = schematicRunner.runSchematic('workspace', { name: 'myApp' }, appTree); | ||
}).toThrow('Cannot find package.json'); | ||
}); | ||
|
||
it('should error if no protractor.conf.js is present', () => { | ||
expect(() => { | ||
appTree.create('/package.json', JSON.stringify({})); | ||
const tree = schematicRunner.runSchematic('workspace', { name: 'myApp' }, appTree); | ||
}).toThrow('Cannot find protractor.conf.js'); | ||
}); | ||
|
||
it('should error if no .angular-cli.json is present', () => { | ||
expect(() => { | ||
appTree.create('/package.json', JSON.stringify({})); | ||
appTree.create('/protractor.conf.js', ''); | ||
const tree = schematicRunner.runSchematic('workspace', { name: 'myApp' }, appTree); | ||
}).toThrow('Cannot find .angular-cli.json'); | ||
}); | ||
|
||
it('should error if the .angular-cli.json specifies more than one app', () => { | ||
expect(() => { | ||
appTree.create('/package.json', JSON.stringify({})); | ||
appTree.create('/protractor.conf.js', ''); | ||
appTree.create( | ||
'/.angular-cli.json', | ||
JSON.stringify({ | ||
apps: [{}, {}] | ||
}) | ||
); | ||
const tree = schematicRunner.runSchematic('workspace', { name: 'myApp' }, appTree); | ||
}).toThrow('Can only convert projects with one app'); | ||
}); | ||
}); |