Commit 4c66b9cb authored by Robert Knight's avatar Robert Knight

Improve a few test descriptions per PR feedback

parent 764b1acf
...@@ -138,24 +138,26 @@ describe('HypothesisApp', () => { ...@@ -138,24 +138,26 @@ describe('HypothesisApp', () => {
}); });
}); });
const getAuthState = wrapper => wrapper.find('TopBar').prop('auth'); describe('"status" field of "auth" prop passed to children', () => {
const getStatus = wrapper => wrapper.find('TopBar').prop('auth').status;
it('auth state is "unknown" if profile has not yet been fetched', () => { it('is "unknown" if profile has not yet been fetched', () => {
fakeStore.hasFetchedProfile.returns(false); fakeStore.hasFetchedProfile.returns(false);
const wrapper = createComponent(); const wrapper = createComponent();
assert.equal(getAuthState(wrapper).status, 'unknown'); assert.equal(getStatus(wrapper), 'unknown');
}); });
it('auth state is "logged-out" if userid is null', () => { it('is "logged-out" if userid is null', () => {
fakeStore.profile.returns({ userid: null }); fakeStore.profile.returns({ userid: null });
const wrapper = createComponent(); const wrapper = createComponent();
assert.equal(getAuthState(wrapper).status, 'logged-out'); assert.equal(getStatus(wrapper), 'logged-out');
}); });
it('auth state is "logged-in" if userid is non-null', () => { it('is "logged-in" if userid is non-null', () => {
fakeStore.profile.returns({ userid: 'acct:jimsmith@hypothes.is' }); fakeStore.profile.returns({ userid: 'acct:jimsmith@hypothes.is' });
const wrapper = createComponent(); const wrapper = createComponent();
assert.equal(getAuthState(wrapper).status, 'logged-in'); assert.equal(getStatus(wrapper), 'logged-in');
});
}); });
[ [
...@@ -192,10 +194,11 @@ describe('HypothesisApp', () => { ...@@ -192,10 +194,11 @@ describe('HypothesisApp', () => {
}, },
}, },
].forEach(({ profile, expectedAuth }) => { ].forEach(({ profile, expectedAuth }) => {
it('sets auth state depending on profile', () => { it('passes expected "auth" prop to children', () => {
fakeStore.profile.returns(profile); fakeStore.profile.returns(profile);
const wrapper = createComponent(); const wrapper = createComponent();
assert.deepEqual(getAuthState(wrapper), expectedAuth); const auth = wrapper.find('TopBar').prop('auth');
assert.deepEqual(auth, expectedAuth);
}); });
}); });
...@@ -277,7 +280,7 @@ describe('HypothesisApp', () => { ...@@ -277,7 +280,7 @@ describe('HypothesisApp', () => {
assert.called(fakeToastMessenger.error); assert.called(fakeToastMessenger.error);
}); });
it('sends LOGIN_REQUESTED if a third-party service is in use', async () => { it('sends LOGIN_REQUESTED event to host page if using a third-party service', async () => {
// If the client is using a third-party annotation service then clicking // If the client is using a third-party annotation service then clicking
// on a login button should send the LOGIN_REQUESTED event over the bridge // on a login button should send the LOGIN_REQUESTED event over the bridge
// (so that the partner site we're embedded in can do its own login // (so that the partner site we're embedded in can do its own login
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment