huridocs/uwazi

View on GitHub
app/react/Markdown/CustomHooks/utils/specs/parsingUtils.spec.js

Summary

Maintainability
A
0 mins
Test Coverage
import utils from '../parsingUtils';

describe('Custom Hooks Parsing utils', () => {
  describe('findBucketsByCountry', () => {
    let set;

    beforeEach(() => {
      set = {
        aggregations: {
          all: {
            country1: {
              buckets: [{ key: 'keyA' }, { key: 'keyB' }],
            },
            country2: {
              buckets: [{ key: 'keyB' }, { key: 'keyC' }],
            },
          },
        },
      };
    });

    it('should find buckets that match country key', () => {
      expect(utils.findBucketsByCountry(set, 'country2', 'keyC')).toBe(
        set.aggregations.all.country2.buckets[1]
      );
      expect(utils.findBucketsByCountry(set, 'country1', 'keyA')).toBe(
        set.aggregations.all.country1.buckets[0]
      );
    });
  });
});