Merge pull request #29 from Microsoft/dev

merge dev to master
This commit is contained in:
Noa 2016-12-12 06:18:15 -08:00 коммит произвёл GitHub
Родитель 82b1441755 76e5181919
Коммит adf1966d34
3 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "powerbi-models",
"version": "0.10.1",
"version": "0.10.2",
"description": "Contains JavaScript & TypeScript object models for Microsoft Power BI JavaScript SDK. For each model there is a TypeScript interface, a json schema definitions, and a validation function to ensure and object is valid.",
"main": "dist/models.js",
"typings": "dist/models.d.ts",

Просмотреть файл

@ -147,7 +147,7 @@ export interface IBasicFilter extends IFilter {
values: (string | number | boolean)[];
}
export type BasicFilterOperators = "In" | "NotIn";
export type BasicFilterOperators = "In" | "NotIn" | "All";
export type AdvancedFilterLogicalOperators = "And" | "Or";
export type AdvancedFilterConditionOperators = "None" | "LessThan" | "LessThanOrEqual" | "GreaterThan" | "GreaterThanOrEqual" | "Contains" | "DoesNotContain" | "StartsWith" | "DoesNotStartWith" | "Is" | "IsNot" | "IsBlank" | "IsNotBlank";
@ -232,8 +232,8 @@ export class BasicFilter extends Filter {
this.operator = operator;
this.schemaUrl = BasicFilter.schemaUrl;
if (values.length === 0) {
throw new Error(`values must be a non-empty array. You passed: ${values}`);
if (values.length === 0 && operator !== "All") {
throw new Error(`values must be a non-empty array unless your operator is "All". You passed: ${values}`);
}
/**

Просмотреть файл

@ -362,6 +362,27 @@ describe('Unit | Models', function () {
false
]
};
// Act
const filter = new models.BasicFilter(
expectedFilter.target,
expectedFilter.operator,
expectedFilter.values);
// Assert
expect(models.validateFilter(filter.toJSON())).toBeUndefined();
});
it("should return undefined if object is valid basic filter schema with operator All", function () {
// Arrange
const expectedFilter: models.IBasicFilter = {
$schema: "http://powerbi.com/product/schema#advanced",
target: {
table: "a",
column: "b"
},
operator: <any>"All",
values: []
};
// Act
const filter = new models.BasicFilter(