var getDocFromAliasFactory = require('../../services/getDocFromAlias');
var aliasMapFactory = require('../../../base/services/aliasMap');
var mockLogFactory = require('dgeni/lib/mocks/log');
var getDocFromAlias, aliasMap, mockLog;

describe("getDocFromAlias", function() {
  beforeEach(function() {
    aliasMap = aliasMapFactory();
    mockLog = mockLogFactory();
    getDocFromAlias = getDocFromAliasFactory(aliasMap, mockLog);
  });

  it("should return an array of docs that match the alias", function() {
    var doc1 = { aliases: ['a','b','c'] };
    var doc2 = { aliases: ['a','b'] };
    var doc3 = { aliases: ['a'] };
    aliasMap.addDoc(doc1);
    aliasMap.addDoc(doc2);
    aliasMap.addDoc(doc3);

    expect(getDocFromAlias('a')).toEqual([doc1, doc2, doc3]);
    expect(getDocFromAlias('b')).toEqual([doc1, doc2]);
    expect(getDocFromAlias('c')).toEqual([doc1]);
  });

  it("should return docs that match the alias and originating doc's area", function() {
    var doc1 = { aliases: ['a'], area: 'api'};
    var doc2 = { aliases: ['a'], area: 'api'};
    var doc3 = { aliases: ['a'], area: 'other'};
    aliasMap.addDoc(doc1);
    aliasMap.addDoc(doc2);
    aliasMap.addDoc(doc3);

    expect(getDocFromAlias('a', {area: 'api'})).toEqual([doc1, doc2]);
  });

  it("should return docs that match the alias and originating doc's area and module", function() {
    var doc1 = { aliases: ['a'], area: 'api', module: 'ng'};
    var doc2 = { aliases: ['a'], area: 'api', module: 'ngMock'};
    var doc3 = { aliases: ['a'], area: 'other', module: 'ng'};
    aliasMap.addDoc(doc1);
    aliasMap.addDoc(doc2);
    aliasMap.addDoc(doc3);

    expect(getDocFromAlias('a', {area: 'api', module:'ng'})).toEqual([doc1]);
  });
});
@@ -1,160 +1,81 @@
 var 
-getDocFromAliasFactory = require('../../services/getDocFromAlias');%0Avar aliasMapFactory = require('../../../base/services/aliasMap');%0Avar mockLogFactory
+mockPackage = require('dgeni-packages/ngdoc/spec/mockPackage');%0Avar Dgeni
  = r
@@ -91,26 +91,13 @@
 geni
-/lib/mocks/log
 ');%0A
+%0A
 var 
@@ -121,25 +121,16 @@
 aliasMap
-, mockLog
 ;%0A%0Adescr
@@ -199,67 +199,132 @@
     
-aliasMap = aliasMapFactory();%0A    mockLog = mockLogFactory(
+var dgeni = new Dgeni(%5BmockPackage()%5D);%0A    var injector = dgeni.configureInjector();%0A    aliasMap = injector.get('aliasMap'
 );%0A 
@@ -344,16 +344,30 @@
 Alias = 
+injector.get('
 getDocFr
@@ -377,33 +377,9 @@
 lias
-Factory(aliasMap, mockLog
+'
 );%0A 

test with mockPackage