Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Apr 7, 2015
1 parent f1687ac commit fb36ba3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ define(function (require) {

// Get all fields current in data set
var currentFields = _.chain($scope.data).map(function (d) {
return _.keys(d.$$_flattened);
return _.keys($scope.indexPattern.flattenHit(d));
}).flatten().unique().sort().value();

_.each($scope.fields, function (field) {
Expand Down
13 changes: 8 additions & 5 deletions test/unit/specs/apps/discover/directives/field_chooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,32 +118,35 @@ define(function (require) {
});

it('should not show the popular fields if there are not any', function (done) {

// Re-init
destroy();

_.each(indexPattern.fields, function (field) { field.count = 0;}); // Reset the popular fields
init($elem, {
columns: [],
toggle: sinon.spy(),
data: require('fixtures/hits'),
filter: sinon.spy(),
indexPattern: indexPattern.fields
indexPattern: indexPattern
});

var section = getSections($elem);
// Remove the popular fields

$scope.$digest();
expect(section.popular.hasClass('ng-hide')).to.be(true);
expect(section.popular.find('li:not(.sidebar-list-header)').length).to.be(0);
done();
});

it('should move the field into selected when setting field.display', function (done) {
it('should move the field into selected when it is added to the columns array', function (done) {
var section = getSections($elem);
indexPattern.fields.byName.bytes.display = true;
$scope.columns.push('bytes');
$scope.$digest();
expect(section.selected.text()).to.contain('bytes');
expect(section.popular.text()).to.not.contain('bytes');

indexPattern.fields.byName.ip.display = true;
$scope.columns.push('ip');
$scope.$digest();
expect(section.selected.text()).to.contain('ip\n');
expect(section.unpopular.text()).to.not.contain('ip\n');
Expand Down

0 comments on commit fb36ba3

Please sign in to comment.