Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Caele committed Mar 28, 2023
1 parent 34adf13 commit 9453fbe
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions apis/nucleus/src/object/__tests__/populator.test.js
@@ -1,19 +1,29 @@
import * as hcHandlerModule from '../hc-handler';
import * as loHandlerModule from '../lo-handler';
import populate, { fieldType as ft } from '../populator';

describe('populator', () => {
let h;
let l;
let warn;
let handler;
let lohandler;

beforeEach(() => {
h = {
addMeasure: jest.fn(),
addDimension: jest.fn(),
};
l = {
addMeasure: jest.fn(),
addDimension: jest.fn(),
};
const fn = () => h;
const fnl = () => l;
handler = jest.fn().mockImplementation(fn);
lohandler = jest.fn().mockImplementation(fnl);
jest.spyOn(hcHandlerModule, 'default').mockImplementation(handler);
jest.spyOn(loHandlerModule, 'default').mockImplementation(lohandler);

global.__NEBULA_DEV__ = true; // eslint-disable-line no-underscore-dangle
warn = jest.fn();
Expand Down Expand Up @@ -91,6 +101,22 @@ describe('populator', () => {
expect(h.addMeasure).toHaveBeenCalledWith('=A');
});

test('should work for qListObjectDef', () => {
const target = {
propertyPath: '/qListObjectDef',
};
const sn = {
qae: {
data: {
targets: [target],
},
},
};
const resolved = { qDimensions: [] };
populate({ sn, properties: { a: { b: { c: resolved } } }, fields: ['A'] });
expect(l.addDimension).toHaveBeenCalledWith('A');
});

test("should identify field as measure when prefixed with '='", () => {
expect(ft('=a')).toBe('measure');
});
Expand Down

0 comments on commit 9453fbe

Please sign in to comment.