test: Add test to check unexpected plugin return values
This commit is contained in:
		
							parent
							
								
									02ddf34f21
								
							
						
					
					
						commit
						2491032a99
					
				| @ -3,6 +3,7 @@ import proxyquire from 'proxyquire'; | |||||||
| import {stub} from 'sinon'; | import {stub} from 'sinon'; | ||||||
| import tempy from 'tempy'; | import tempy from 'tempy'; | ||||||
| import SemanticReleaseError from '@semantic-release/error'; | import SemanticReleaseError from '@semantic-release/error'; | ||||||
|  | import DEFINITIONS from '../lib/plugins/definitions'; | ||||||
| import {gitHead as getGitHead} from '../lib/git'; | import {gitHead as getGitHead} from '../lib/git'; | ||||||
| import {gitRepo, gitCommits, gitTagVersion} from './helpers/git-utils'; | import {gitRepo, gitCommits, gitTagVersion} from './helpers/git-utils'; | ||||||
| 
 | 
 | ||||||
| @ -261,4 +262,30 @@ test.serial('Throw SemanticReleaseError if repositoryUrl is not set and canot be | |||||||
|   // Verify error code and type
 |   // Verify error code and type
 | ||||||
|   t.is(error.code, 'ENOREPOURL'); |   t.is(error.code, 'ENOREPOURL'); | ||||||
|   t.true(error instanceof SemanticReleaseError); |   t.true(error instanceof SemanticReleaseError); | ||||||
|  | 
 | ||||||
|  | test.serial('Throw an Error if returns an unexpected value', async t => { | ||||||
|  |   // Create a git repository, set the current working directory at the root of the repo
 | ||||||
|  |   await gitRepo(); | ||||||
|  |   // Add commits to the master branch
 | ||||||
|  |   await gitCommits(['First']); | ||||||
|  |   // Create the tag corresponding to version 1.0.0
 | ||||||
|  |   await gitTagVersion('v1.0.0'); | ||||||
|  |   // Add new commits to the master branch
 | ||||||
|  |   await gitCommits(['Second']); | ||||||
|  | 
 | ||||||
|  |   const verifyConditions = stub().resolves(); | ||||||
|  |   const getLastRelease = stub().resolves('string'); | ||||||
|  | 
 | ||||||
|  |   const options = { | ||||||
|  |     branch: 'master', | ||||||
|  |     repositoryUrl: 'git@hostname.com:owner/module.git', | ||||||
|  |     verifyConditions: [verifyConditions], | ||||||
|  |     getLastRelease, | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const error = await t.throws(t.context.semanticRelease(options), Error); | ||||||
|  | 
 | ||||||
|  |   // Verify error message
 | ||||||
|  |   t.regex(error.message, new RegExp(DEFINITIONS.getLastRelease.output.message)); | ||||||
|  |   t.regex(error.message, /Received: 'string'/); | ||||||
| }); | }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user