'use strict';

describe('filterWatcherProvider', function() {

  //Provider
  function setPrefix(name) {
    return function(filterWatcherProvider) {
      filterWatcherProvider.setPrefix(name);
    }
  }

  beforeEach(module('a8m.filter-watcher', function ($provide) {
    //mock setTimeout
    $provide.value('$window', {
      setTimeout: function(fn, mill) {
        fn.apply(null, [].slice.call(arguments, 2));
        return +new Date();
      }
    });
  }));

  it('should register watcher and return new object', inject(function(filterWatcher) {
    var watched = {},
      flag = filterWatcher.$watch('foo', watched);

    expect(flag).toEqual({});
    expect(watched).toEqual( {_$$foo: {} } );
  }));

  it('should return the same watcher instance if already exist', inject(function(filterWatcher) {
    var watched = { _$$bar: [ 1, 2, 3] },
      flag = filterWatcher.$watch('bar', watched);

    expect(flag).toEqual([ 1, 2, 3]);
  }));

  it('should be able to remove specific watcher instance', inject(function(filterWatcher) {
    var watched = { _$$bar: [ 1, 2, 3] };
    filterWatcher.$destroy('bar', watched);

    expect(watched).toEqual({});
  }));

  it('should be able to change the watcherPrefix', function() {
    module(setPrefix('a8m_'));
    inject(function(filterWatcher) {
      var watched = {},
        flag = filterWatcher.$watch('foo', watched);

      expect(flag).toEqual({});
      expect(watched).toEqual({ a8m_foo : {} });
    });
  });

});
@@ -936,32 +936,34 @@
 2, 3%5D);%0A  %7D));%0A%0A
+//
   it('should be 
@@ -1030,32 +1030,34 @@
 ilterWatcher) %7B%0A
+//
     var watched 
@@ -1082,16 +1082,18 @@
 , 3%5D %7D;%0A
+//
     filt
@@ -1120,33 +1120,37 @@
 bar', watched);%0A
-%0A
+//%0A//
     expect(watch
@@ -1162,32 +1162,38 @@
 oEqual(%7B%7D);%0A
+//
   %7D));%0A
-%0A
+//%0A//
   it('should
@@ -1240,24 +1240,26 @@
 unction() %7B%0A
+//
     module(s
@@ -1273,24 +1273,26 @@
 x('a8m_'));%0A
+//
     inject(f
@@ -1312,24 +1312,26 @@
 rWatcher) %7B%0A
+//
       var wa
@@ -1338,24 +1338,26 @@
 tched = %7B%7D,%0A
+//
         flag
@@ -1393,25 +1393,29 @@
 , watched);%0A
-%0A
+//%0A//
       expect
@@ -1430,24 +1430,26 @@
 oEqual(%7B%7D);%0A
+//
       expect
@@ -1485,24 +1485,26 @@
  %7B%7D %7D);%0A
+//
     %7D);%0A
   %7D);%0A%0A%7D
@@ -1491,22 +1491,24 @@
 ;%0A//    %7D);%0A
+//
   %7D);%0A%0A%7D);

fix broken build