Merge pull request #23 from Microsoft/add_viewtype_to_dashboard_embed_configuration

add pageView to dashboard configuration
This commit is contained in:
Noa 2016-11-12 23:22:54 -08:00 коммит произвёл GitHub
Родитель 245a1757a8 f9e0eb3388
Коммит 82b1441755
4 изменённых файлов: 45 добавлений и 1 удалений

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

@ -1,6 +1,6 @@
{
"name": "powerbi-models",
"version": "0.10.0",
"version": "0.10.1",
"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",

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

@ -80,9 +80,12 @@ export const validateReportLoad = validate(loadSchema, {
}
});
export type PageView = "fitToWidth" | "oneColumn" | "actualSize";
export interface IDashboardLoadConfiguration {
accessToken: string;
id: string;
pageView?: PageView;
}
export const validateDashboardLoad = validate(dashboardLoadSchema);

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

@ -15,6 +15,12 @@
"type": "id must be a string",
"required": "id is required"
}
},
"pageView": {
"type": "string",
"messages": {
"type": "pageView must be a string with one of the following values: \"actualSize\", \"fitToWidth\", \"oneColumn\""
}
}
},
"required": [

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

@ -194,6 +194,7 @@ describe('Unit | Models', function () {
const accessTokenInvalidTypeMessage = models.dashboardLoadSchema.properties.accessToken.messages.type;
const idRequiredMessage = models.dashboardLoadSchema.properties.id.messages.required;
const idInvalidTypeMessage = models.dashboardLoadSchema.properties.id.messages.type;
const pageViewInvalidTypeMessage = models.dashboardLoadSchema.properties.pageView.messages.type;
it(`should return errors with one containing message '${accessTokenRequiredMessage}' if accessToken is not defined`, function () {
// Arrange
@ -270,6 +271,40 @@ describe('Unit | Models', function () {
// Assert
expect(errors).toBeUndefined();
});
it(`should return undefined if id and accessToken and pageView are provided`, function () {
// Arrange
const testData = {
load: {
id: 'fakeId',
accessToken: 'fakeAccessToken',
pageView: 'pageView',
}
};
// Act
const errors = models.validateDashboardLoad(testData.load);
// Assert
expect(errors).toBeUndefined();
});
it(`should return errors with one containing message '${pageViewInvalidTypeMessage}' if pageView is not a string`, function () {
// Arrange
const testData = {
load: {
accessToken: 'fakeAccessToken',
id: 'id',
pageView: 2,
}
};
// Act
const errors = models.validateDashboardLoad(testData.load);
// Assert
testForExpectedMessage(errors, pageViewInvalidTypeMessage);
});
});
describe('validateFilter', function () {