CB-12018 : updated tests to work with jasmine (promise matcher tests commented out for now)

This commit is contained in:
audreyso
2017-01-03 11:02:48 -08:00
parent c7ff24b983
commit 3fc4daa447
11 changed files with 119 additions and 86 deletions
+14 -14
View File
@@ -38,13 +38,13 @@ var copyNewFile = common.__get__('copyNewFile');
describe('common platform handler', function() {
describe('copyFile', function() {
it('should throw if source path not found', function(){
it('Test#001 : should throw if source path not found', function(){
shell.rm('-rf', src);
expect(function(){copyFile(test_dir, src, project_dir, dest);})
.toThrow(new Error('"' + src + '" not found!'));
});
it('should throw if src not in plugin directory', function(){
it('Test#002 : should throw if src not in plugin directory', function(){
shell.mkdir('-p', project_dir);
fs.writeFileSync(non_plugin_file, 'contents', 'utf-8');
var outside_file = '../non_plugin_file';
@@ -53,7 +53,7 @@ describe('common platform handler', function() {
shell.rm('-rf', test_dir);
});
it('should allow symlink src, if inside plugin', function(){
it('Test#003 : should allow symlink src, if inside plugin', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(java_file, 'contents', 'utf-8');
@@ -66,7 +66,7 @@ describe('common platform handler', function() {
shell.rm('-rf', project_dir);
});
it('should throw if symlink is linked to a file outside the plugin', function(){
it('Test#004 : should throw if symlink is linked to a file outside the plugin', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(non_plugin_file, 'contents', 'utf-8');
@@ -80,7 +80,7 @@ describe('common platform handler', function() {
shell.rm('-rf', project_dir);
});
it('should throw if dest is outside the project directory', function(){
it('Test#005 : should throw if dest is outside the project directory', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(java_file, 'contents', 'utf-8');
expect(function(){copyFile(test_dir, java_file, project_dir, non_plugin_file);}).
@@ -88,11 +88,11 @@ describe('common platform handler', function() {
shell.rm('-rf', project_dir);
});
it('should call mkdir -p on target path', function(){
it('Test#006 : should call mkdir -p on target path', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(java_file, 'contents', 'utf-8');
var s = spyOn(shell, 'mkdir').andCallThrough();
var s = spyOn(shell, 'mkdir').and.callThrough();
var resolvedDest = path.resolve(project_dir, dest);
copyFile(test_dir, java_file, project_dir, dest);
@@ -102,11 +102,11 @@ describe('common platform handler', function() {
shell.rm('-rf', project_dir);
});
it('should call cp source/dest paths', function(){
it('Test#007 : should call cp source/dest paths', function(){
shell.mkdir('-p', java_dir);
fs.writeFileSync(java_file, 'contents', 'utf-8');
var s = spyOn(shell, 'cp').andCallThrough();
var s = spyOn(shell, 'cp').and.callThrough();
var resolvedDest = path.resolve(project_dir, dest);
copyFile(test_dir, java_file, project_dir, dest);
@@ -119,7 +119,7 @@ describe('common platform handler', function() {
});
describe('copyNewFile', function () {
it('should throw if target path exists', function(){
it('Test#008 : should throw if target path exists', function(){
shell.mkdir('-p', dest);
expect(function(){copyNewFile(test_dir, src, project_dir, dest);}).
toThrow(new Error('"' + dest + '" already exists!'));
@@ -137,21 +137,21 @@ describe('common platform handler', function() {
shell.rm('-rf', java_dir);
});
it('should call fs.unlinkSync on the provided paths', function(){
var s = spyOn(fs, 'unlinkSync').andCallThrough();
it('Test#009 : should call fs.unlinkSync on the provided paths', function(){
var s = spyOn(fs, 'unlinkSync').and.callThrough();
deleteJava(project_dir, java_file);
expect(s).toHaveBeenCalled();
expect(s).toHaveBeenCalledWith(path.resolve(project_dir, java_file));
});
it('should delete empty directories after removing source code in a java src path hierarchy', function(){
it('Test#010 : should delete empty directories after removing source code in a java src path hierarchy', function(){
deleteJava(project_dir, java_file);
expect(fs.existsSync(java_file)).not.toBe(true);
expect(fs.existsSync(java_dir)).not.toBe(true);
expect(fs.existsSync(path.join(src,'one'))).not.toBe(true);
});
it('should never delete the top-level src directory, even if all plugins added were removed', function(){
it('Test#011 : should never delete the top-level src directory, even if all plugins added were removed', function(){
deleteJava(project_dir, java_file);
expect(fs.existsSync(src)).toBe(true);
});