| 
									
										
										
										
											2017-05-26 16:37:31 -04:00
										 |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | const assert = require('assert'); | 
					
						
							|  |  |  | const path = require('path'); | 
					
						
							| 
									
										
										
										
											2017-05-26 16:37:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:06:15 -07:00
										 |  |  | const db = require('./mocks/databasemock'); | 
					
						
							|  |  |  | const image = require('../src/image'); | 
					
						
							|  |  |  | const file = require('../src/file'); | 
					
						
							| 
									
										
										
										
											2017-05-26 16:37:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | describe('image', () => { | 
					
						
							|  |  |  | 	it('should normalise image', (done) => { | 
					
						
							|  |  |  | 		image.normalise(path.join(__dirname, 'files/normalise.jpg'), '.jpg', (err) => { | 
					
						
							| 
									
										
										
										
											2017-05-26 16:37:31 -04:00
										 |  |  | 			assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			file.exists(path.join(__dirname, 'files/normalise.jpg.png'), (err, exists) => { | 
					
						
							| 
									
										
										
										
											2017-05-26 16:37:31 -04:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert(exists); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-05-28 17:21:44 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 	it('should resize an image', (done) => { | 
					
						
							| 
									
										
										
										
											2017-05-28 17:21:44 -04:00
										 |  |  | 		image.resizeImage({ | 
					
						
							|  |  |  | 			path: path.join(__dirname, 'files/normalise.jpg'), | 
					
						
							|  |  |  | 			target: path.join(__dirname, 'files/normalise-resized.jpg'), | 
					
						
							|  |  |  | 			width: 50, | 
					
						
							|  |  |  | 			height: 40, | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 		}, (err) => { | 
					
						
							| 
									
										
										
										
											2017-05-28 17:21:44 -04:00
										 |  |  | 			assert.ifError(err); | 
					
						
							| 
									
										
										
										
											2021-02-04 00:01:39 -07:00
										 |  |  | 			image.size(path.join(__dirname, 'files/normalise-resized.jpg'), (err, bitmap) => { | 
					
						
							| 
									
										
										
										
											2017-05-28 17:21:44 -04:00
										 |  |  | 				assert.ifError(err); | 
					
						
							|  |  |  | 				assert.equal(bitmap.width, 50); | 
					
						
							|  |  |  | 				assert.equal(bitmap.height, 40); | 
					
						
							|  |  |  | 				done(); | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-05-26 16:37:31 -04:00
										 |  |  | }); |