Skip to content

Commit

Permalink
Change setActivePage to setPage, and change setPage method to take pa…
Browse files Browse the repository at this point in the history
…geName instead of pageObject
  • Loading branch information
mattmazzola committed Jun 14, 2016
1 parent 0a5c66b commit 7ff0561
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
21 changes: 9 additions & 12 deletions e2e/protocol.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ describe('Protocol', function () {
// Arrange
const testData = {
page: {
name: "fakeName",
displayName: "fakeDisplayName"
name: "fakeName"
}
};

Expand All @@ -262,11 +261,11 @@ describe('Protocol', function () {
.catch(response => {
// Assert
expect(spyApp.validatePage).toHaveBeenCalledWith(testData.page);
expect(spyApp.setActivePage).not.toHaveBeenCalled();
expect(spyApp.setPage).not.toHaveBeenCalled();
expect(response.statusCode).toEqual(400);
// Cleanup
spyApp.validatePage.calls.reset();
spyApp.setActivePage.calls.reset();
spyApp.setPage.calls.reset();
done();
});
});
Expand All @@ -276,8 +275,7 @@ describe('Protocol', function () {
// Arrange
const testData = {
page: {
name: "fakeName",
displayName: "fakeDisplayName"
name: "fakeName"
}
};

Expand All @@ -290,11 +288,11 @@ describe('Protocol', function () {
.then(response => {
// Assert
expect(spyApp.validatePage).toHaveBeenCalledWith(testData.page);
expect(spyApp.setActivePage).toHaveBeenCalledWith(testData.page);
expect(spyApp.setPage).toHaveBeenCalledWith(testData.page);
expect(response.statusCode).toEqual(202);
// Cleanup
spyApp.validatePage.calls.reset();
spyApp.setActivePage.calls.reset();
spyApp.setPage.calls.reset();
done();
});
});
Expand All @@ -304,8 +302,7 @@ describe('Protocol', function () {
// Arrange
const testData = {
page: {
name: "fakeName",
displayName: "fakeDisplayName"
name: "fakeName"
},
expectedEvent: {
method: 'POST',
Expand All @@ -325,12 +322,12 @@ describe('Protocol', function () {
.then(response => {
// Assert
expect(spyApp.validatePage).toHaveBeenCalledWith(testData.page);
expect(spyApp.setActivePage).toHaveBeenCalledWith(testData.page);
expect(spyApp.setPage).toHaveBeenCalledWith(testData.page);
expect(response.statusCode).toEqual(202);
expect(spyHandler.handle).toHaveBeenCalledWith(jasmine.objectContaining(testData.expectedEvent));
// Cleanup
spyApp.validateLoad.calls.reset();
spyApp.setActivePage.calls.reset();
spyApp.setPage.calls.reset();
done();
});
});
Expand Down
6 changes: 3 additions & 3 deletions e2e/utility/mockApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface IApp {

// Pages
getPages(): Promise<IPage>;
setActivePage(page: IPage): Promise<void>;
setPage(pageName: string): Promise<void>;
togglePageNavigation(): Promise<void>;
validatePage(page: IPage): Promise<IValidationResponse>;
// Filters
Expand All @@ -66,7 +66,7 @@ export const mockAppSpyObj = {
validateSettings: jasmine.createSpy("validateSettings").and.returnValue(Promise.resolve(null)),
// Pages
getPages: jasmine.createSpy("getPages").and.returnValue(Promise.resolve(null)),
setActivePage: jasmine.createSpy("setActivePage").and.returnValue(Promise.resolve(null)),
setPage: jasmine.createSpy("setPage").and.returnValue(Promise.resolve(null)),
togglePageNavigation: jasmine.createSpy("togglePageNavigation").and.returnValue(Promise.resolve(null)),
validatePage: jasmine.createSpy("validatePage").and.returnValue(Promise.resolve(null)),
// Filters
Expand All @@ -87,7 +87,7 @@ export const mockAppSpyObj = {
mockAppSpyObj.updateSettings.calls.reset();
mockAppSpyObj.validateSettings.calls.reset();
mockAppSpyObj.getPages.calls.reset();
mockAppSpyObj.setActivePage.calls.reset();
mockAppSpyObj.setPage.calls.reset();
mockAppSpyObj.togglePageNavigation.calls.reset();
mockAppSpyObj.validatePage.calls.reset();
mockAppSpyObj.validateFilter.calls.reset();
Expand Down
2 changes: 1 addition & 1 deletion e2e/utility/mockReportEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function setup(iframeContentWindow: Window, parentWindow: Window, logMess
const page = req.body;
return app.validatePage(page)
.then(() => {
app.setActivePage(page)
app.setPage(page)
.then(page => {
const initiator = "sdk";
hpm.post('/report/events/pageChanged', {
Expand Down
7 changes: 6 additions & 1 deletion src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ export class Report extends Embed {
/**
* Set the active page
*/
setActivePage(page: IPage): Promise<void> {
setPage(pageName: string): Promise<void> {
const page: IPage = {
name: pageName,
displayName: null
};

return this.hpm.put<IError[]>('/report/pages/active', page)
.catch(response => {
throw response.body;
Expand Down

0 comments on commit 7ff0561

Please sign in to comment.