| 
									
										
										
										
											2015-11-05 12:32:45 +00:00
										 |  |  | var mockPackage = require('../mocks/mockPackage'); | 
					
						
							|  |  |  | var Dgeni = require('dgeni'); | 
					
						
							| 
									
										
										
										
											2015-09-15 23:21:55 -07:00
										 |  |  | var path = require('canonical-path'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 12:32:45 +00:00
										 |  |  | describe('contentFileReader', function() { | 
					
						
							|  |  |  |   var dgeni, injector, fileReader; | 
					
						
							| 
									
										
										
										
											2015-09-15 23:21:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-05 12:32:45 +00:00
										 |  |  |   beforeEach(function() { | 
					
						
							|  |  |  |     dgeni = new Dgeni([mockPackage()]); | 
					
						
							|  |  |  |     injector = dgeni.configureInjector(); | 
					
						
							|  |  |  |     fileReader = injector.get('contentFileReader'); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-09-15 23:21:55 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   var createFileInfo = function(file, content, basePath) { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       fileReader: fileReader.name, | 
					
						
							|  |  |  |       filePath: file, | 
					
						
							|  |  |  |       baseName: path.basename(file, path.extname(file)), | 
					
						
							|  |  |  |       extension: path.extname(file).replace(/^\./, ''), | 
					
						
							|  |  |  |       basePath: basePath, | 
					
						
							|  |  |  |       relativePath: path.relative(basePath, file), | 
					
						
							|  |  |  |       content: content | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('defaultPattern', function() { | 
					
						
							|  |  |  |     it('should match .md files', function() { | 
					
						
							|  |  |  |       expect(fileReader.defaultPattern.test('abc.md')).toBeTruthy(); | 
					
						
							|  |  |  |       expect(fileReader.defaultPattern.test('abc.js')).toBeFalsy(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe('getDocs', function() { | 
					
						
							|  |  |  |     it('should return an object containing info about the file and its contents', function() { | 
					
						
							|  |  |  |       var fileInfo = createFileInfo('project/path/modules/someModule/foo/docs/subfolder/bar.ngdoc', 'A load of content', 'project/path'); | 
					
						
							|  |  |  |       expect(fileReader.getDocs(fileInfo)).toEqual([{ | 
					
						
							|  |  |  |         docType: 'guide', | 
					
						
							|  |  |  |         content: 'A load of content', | 
					
						
							|  |  |  |         startingLine: 1 | 
					
						
							|  |  |  |       }]); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 |