All files / src/Fake FakeFields.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 2/2
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 293x 3x       5x   4x             3x       4x 3x   2x 2x 2x     2x    
import { Assert, IIndexFieldValue } from "coveo-search-ui";
export function createFakeFieldValue(
  field: string,
  numberOfResults: number
): IIndexFieldValue {
  Assert.isNonEmptyString(field);
 
  return {
    value: field,
    lookupValue: field,
    numberOfResults: numberOfResults
  };
}
 
export function createFakeFieldValues(
  field: string,
  count: number
): IIndexFieldValue[] {
  Assert.isNonEmptyString(field);
  Assert.isLargerOrEqualsThan(0, count);
 
  const fieldValues: IIndexFieldValue[] = [];
  for (var i = 0; i < count; ++i) {
    fieldValues.push(createFakeFieldValue(field + i.toString(), i + 1));
  }
 
  return fieldValues;
}