-
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.
- Loading branch information
1 parent
3be9e88
commit 1290cb2
Showing
2 changed files
with
65 additions
and
1 deletion.
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); | ||
}); | ||
}); | ||
}); |