test(post): initial
This commit is contained in:
		
							parent
							
								
									431babb42e
								
							
						
					
					
						commit
						ed05101a61
					
				
							
								
								
									
										3
									
								
								test/mocks/git-head.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								test/mocks/git-head.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| module.exports = function (cb) { | ||||
|   cb(null, 'bar') | ||||
| } | ||||
							
								
								
									
										6
									
								
								test/mocks/github.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								test/mocks/github.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| module.exports = () => ({ | ||||
|   authenticate: () => true, | ||||
|   releases: { | ||||
|     createRelease: (release, cb) => cb(null) | ||||
|   } | ||||
| }) | ||||
							
								
								
									
										60
									
								
								test/specs/post.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								test/specs/post.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,60 @@ | ||||
| const { defaults } = require('lodash') | ||||
| const test = require('tap').test | ||||
| const proxyquire = require('proxyquire') | ||||
| 
 | ||||
| const post = proxyquire('../../dist/post', { | ||||
|   'git-head': require('../mocks/git-head'), | ||||
|   github: require('../mocks/github') | ||||
| }) | ||||
| 
 | ||||
| const pkg = { | ||||
|   version: '1.0.0', | ||||
|   repository: { | ||||
|     url: 'http://github.com/whats/up.git' | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const plugins = { | ||||
|   generateNotes: (pkg, cb) => cb(null, 'the log') | ||||
| } | ||||
| 
 | ||||
| const defaultRelease = { | ||||
|   owner: 'whats', | ||||
|   repo: 'up', | ||||
|   name: 'v1.0.0', | ||||
|   tag_name: 'v1.0.0', | ||||
|   target_commitish: 'bar', | ||||
|   body: 'the log' | ||||
| } | ||||
| 
 | ||||
| test('full post run', (t) => { | ||||
|   t.test('in debug mode w/o token', (tt) => { | ||||
|     post(pkg, {debug: true}, plugins, (err, published, release) => { | ||||
|       tt.error(err) | ||||
|       tt.is(published, false) | ||||
|       tt.match(release, defaults({draft: true}, defaultRelease)) | ||||
| 
 | ||||
|       tt.end() | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   t.test('in debug mode w token', (tt) => { | ||||
|     post(pkg, {debug: true, 'github-token': 'yo'}, plugins, (err, published, release) => { | ||||
|       tt.error(err) | ||||
|       tt.is(published, true) | ||||
|       tt.match(release, defaults({draft: true}, defaultRelease)) | ||||
| 
 | ||||
|       tt.end() | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   t.test('production', (tt) => { | ||||
|     post(pkg, {'github-token': 'yo'}, plugins, (err, published, release) => { | ||||
|       tt.error(err) | ||||
|       tt.is(published, true) | ||||
|       tt.match(release, defaultRelease) | ||||
| 
 | ||||
|       tt.end() | ||||
|     }) | ||||
|   }) | ||||
| }) | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user