-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in r2-2825-show-webpush-preferences-when-webpush-enabled (pull…
… request #6723) R2-2825 - Instance with push notifications turned off still shows user options for push notifications Approved-by: Joshua Toliver
- Loading branch information
Showing
5 changed files
with
107 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ import Account from "./container"; | |
describe("<Account />", () => { | ||
let component; | ||
|
||
const getVisibleFields = allFields => | ||
allFields.filter(field => Object.is(field.visible, null) || field.visible).map(field => field.toJS()); | ||
|
||
beforeEach(() => { | ||
const initialState = fromJS({ | ||
user: { | ||
|
@@ -45,4 +48,62 @@ describe("<Account />", () => { | |
it("renders ChangePassword component", () => { | ||
expect(component.find(ChangePassword)).to.have.length(1); | ||
}); | ||
|
||
describe("when WEBPUSH is enabled", () => { | ||
const state = fromJS({ | ||
user: { | ||
loading: false, | ||
errors: false, | ||
serverErrors: [], | ||
locale: "en", | ||
id: 1, | ||
full_name: "Test user", | ||
disabled: false, | ||
email: "[email protected]", | ||
time_zone: "UTC", | ||
user_name: "primero" | ||
}, | ||
application: { | ||
agencies: [{ id: 1, unique_id: "agency-unicef", name: "UNICEF" }], | ||
webpush: { | ||
enabled: true | ||
} | ||
} | ||
}); | ||
|
||
const { component: newComponent } = setupMountedComponent(Account, { mode: "'edit'" }, state, ["/account"]); | ||
|
||
it("renders 25 fields", () => { | ||
expect(getVisibleFields(newComponent.find("FormSection").props().formSection.fields)).to.have.lengthOf(25); | ||
}); | ||
}); | ||
|
||
describe("when WEBPUSH is disabled", () => { | ||
const state = fromJS({ | ||
user: { | ||
loading: false, | ||
errors: false, | ||
serverErrors: [], | ||
locale: "en", | ||
id: 1, | ||
full_name: "Test user", | ||
disabled: false, | ||
email: "[email protected]", | ||
time_zone: "UTC", | ||
user_name: "primero" | ||
}, | ||
application: { | ||
agencies: [{ id: 1, unique_id: "agency-unicef", name: "UNICEF" }], | ||
webpush: { | ||
enabled: false | ||
} | ||
} | ||
}); | ||
|
||
const { component: newComponent } = setupMountedComponent(Account, { mode: "'edit'" }, state, ["/account"]); | ||
|
||
it("renders 20 fields", () => { | ||
expect(getVisibleFields(newComponent.find("FormSection").props().formSection.fields)).to.have.lengthOf(20); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters