/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 Mickael Jeanroy
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

describe('GridComparator', function() {

  var grid;

  beforeEach(function() {
    var columns = [
      { id: 'id', sortable: false },
      { id: 'firstName' },
      { id: 'lastName' }
    ];

    var data = [
      { id: 1, firstName: 'foo1', lastName: 'bar1' },
      { id: 2, firstName: 'foo2', lastName: 'bar2' },
      { id: 3, firstName: 'foo2', lastName: 'bar3' }
    ];

    grid = new Grid({
      data: data,
      columns: columns,
      key: function(o) {
        return o.id;
      }
    });
  });

  it('should create basic comparator', function() {
    var column = grid.$columns[1];

    var c1 = new BasicComparator();
    c1.id = 'foo';

    var c2 = new BasicComparator();
    c2.id = 'bar';

    var c3 = new BasicComparator();
    c3.id = 'foo';

    expect(c1.predicate()).toBe('foo');
    expect(c2.predicate()).toBe('bar');
    expect(c3.predicate()).toBe('foo');

    expect(c1.equals(c2)).toBeFalse();
    expect(c1.equals(c3)).toBeTrue();
  });

  it('should throw error in compare function', function() {
    var c1 = new BasicComparator();
    c1.id = 'foo';

    var compare = function() {
      var o1 = {};
      var o2 = {};
      return c1.compare(o1, o2);
    };

    expect(compare).toThrow('Function compare must be implemented');
  });
});

@@ -1174,27 +1174,22 @@
 r', 
-function()
+() =%3E
  %7B%0A%0A  
-var
+let
  gri
@@ -1205,36 +1205,33 @@
 oreEach(
-function()
+() =%3E
  %7B%0A    
-var
+const
  columns
@@ -1336,19 +1336,21 @@
 %5D;%0A%0A    
-var
+const
  data = 
@@ -1599,50 +1599,17 @@
 ey: 
-function(o) %7B%0A        return o.id;%0A      %7D
+o =%3E o.id
 %0A   
@@ -1659,36 +1659,33 @@
 rator', 
-function()
+() =%3E
  %7B%0A    
-var
+const
  column 
@@ -1705,27 +1705,29 @@
 ns%5B1%5D;%0A%0A    
-var
+const
  c1 = new Ba
@@ -1767,19 +1767,21 @@
 ';%0A%0A    
-var
+const
  c2 = ne
@@ -1825,19 +1825,21 @@
 ';%0A%0A    
-var
+const
  c3 = ne
@@ -2135,28 +2135,25 @@
 n', 
-function()
+() =%3E
  %7B%0A    
-var
+const
  c1 
@@ -2201,19 +2201,21 @@
 ';%0A%0A    
-var
+const
  compare
@@ -2221,18 +2221,13 @@
 e = 
-function()
+() =%3E
  %7B%0A 
@@ -2231,19 +2231,21 @@
 %7B%0A      
-var
+const
  o1 = %7B%7D
@@ -2256,11 +2256,13 @@
     
-var
+const
  o2 

migrate basic-comparator-spec to es6