Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('works with max', () => {
var attribute = AttributeInfo.fromJS({
"name": "price",
"type": "NUMBER",
"unsplitable": true,
"makerAction": {
"action": "max",
"expression": {
"name": "price",
"op": "ref"
}
}
});
var measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
expect(measures).to.deep.equal([
{
"name": "price",
it("works with sum", () => {
const attribute = AttributeInfo.fromJS({
name: "price",
type: "NUMBER",
unsplitable: true,
maker: {
action: "sum",
expression: {
name: "price",
op: "ref"
}
}
});
const measures = Measure.measuresFromAttributeInfo(attribute).map((m => m.toJS()));
expect(measures).to.deep.equal([
{
name: "price",
title: "Price",
public deduceAttributes(): Attributes {
const { dimensions, measures, timeAttribute, attributeOverrides } = this;
let attributes: Attributes = [];
if (timeAttribute) {
attributes.push(AttributeInfo.fromJS({ name: timeAttribute.name, type: "TIME" }));
}
dimensions.forEachDimension(dimension => {
const expression = dimension.expression;
if (expression.equals(timeAttribute)) return;
const references = expression.getFreeReferences();
for (let reference of references) {
if (NamedArray.findByName(attributes, reference)) continue;
attributes.push(AttributeInfo.fromJS({ name: reference, type: "STRING" }));
}
});
measures.forEachMeasure(measure => {
const references = Measure.getReferences(measure.expression);
for (let reference of references) {
if (NamedArray.findByName(attributes, reference)) continue;
measures.forEachMeasure(measure => {
const references = Measure.getReferences(measure.expression);
for (let reference of references) {
if (NamedArray.findByName(attributes, reference)) continue;
if (Measure.hasCountDistinctReferences(measure.expression)) continue;
if (Measure.hasQuantileReferences(measure.expression)) continue;
attributes.push(AttributeInfo.fromJS({ name: reference, type: "NUMBER" }));
}
});