describe('list-table directive', () => {
  var $compile;
  var $rootScope;

  beforeEach(angular.mock.module('Xivo'));
  beforeEach(angular.mock.module('html-templates'));
  beforeEach(angular.mock.module('karma-backend'));

  beforeEach(angular.mock.inject(function(_$compile_, _$rootScope_) {
    $compile = _$compile_;
    $rootScope = _$rootScope_;
  }));

  it('Generate html for defined actions', () => {

    $rootScope.headers = ['id', 'name', 'voip_ip'];
    $rootScope.actions = ['edit', 'delete'];
    $rootScope.path = '/test/path/';
    $rootScope.list = [
      {
        "id": 1,
        "name": "mds1",
        "voip_ip": "10.52.0.10",
        "read_only": false
      },
      {
        "id": 2,
        "name": "mds2",
        "voip_ip": "10.52.0.20",
        "read_only": false
      }
    ];

    var element = $compile('<list-table headers="headers" list="list" actions="actions" path="path"></list-table>')($rootScope);
    $rootScope.$digest();
    expect(element.html()).toContain('ng-href="/test/path/?act=edit&amp;id=2"');
    expect(element.html()).toContain('ng-click="delete({id: elem.id})"');
  });
});
