You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					39 lines
				
				1.3 KiB
			
		
		
			
		
	
	
					39 lines
				
				1.3 KiB
			| 
											3 years ago
										 | /* global describe, it */ | ||
|  | 
 | ||
|  | var assert = require('assert') | ||
|  | var isGenerator = require('./') | ||
|  | 
 | ||
|  | describe('is-generator', function () { | ||
|  |   describe('generators', function () { | ||
|  |     it('should return false with non-generators', function () { | ||
|  |       assert(!isGenerator(null)) | ||
|  |       assert(!isGenerator(25)) | ||
|  |       assert(!isGenerator('test')) | ||
|  |       assert(!isGenerator(/* istanbul ignore next */ function () {})) | ||
|  |       assert(!isGenerator(/* istanbul ignore next */ function * () {})) | ||
|  |     }) | ||
|  | 
 | ||
|  |     it('should return true with a generator', function () { | ||
|  |       assert(isGenerator((/* istanbul ignore next */ function * () {})())) | ||
|  |     }) | ||
|  |   }) | ||
|  | 
 | ||
|  |   describe('generator functions', function () { | ||
|  |     it('should return false with non-generator function', function () { | ||
|  |       assert(!isGenerator.fn(null)) | ||
|  |       assert(!isGenerator.fn(25)) | ||
|  |       assert(!isGenerator.fn('test')) | ||
|  |       assert(!isGenerator.fn(/* istanbul ignore next */ function () {})) | ||
|  | 
 | ||
|  |       var noConstructorFn = /* istanbul ignore next */ function () {} | ||
|  |       noConstructorFn.constructor = undefined | ||
|  | 
 | ||
|  |       assert(!isGenerator.fn(noConstructorFn)) | ||
|  |     }) | ||
|  | 
 | ||
|  |     it('should return true with a generator function', function () { | ||
|  |       assert(isGenerator.fn(/* istanbul ignore next */ function * () { yield 'something' })) | ||
|  |     }) | ||
|  |   }) | ||
|  | }) |