Created
July 3, 2019 19:37
-
-
Save crisperpo/2614e6bf70be5adedd9c67c11d4c0e69 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/qojapeg
This file contains hidden or 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
<script id="jsbin-javascript"> | |
describe('SSO UserVoice token', () => { | |
it('Gets token from endpoint and set up consent in local storage', done => { | |
const wrapper = shallow(<ConsentUserVoice />); | |
jest.spyOn(window.localStorage.__proto__, 'getItem'); | |
window.localStorage.__proto__.getItem = jest.fn(); | |
jest.spyOn(window.localStorage.__proto__, 'setItem'); | |
window.localStorage.__proto__.setItem = jest.fn(); | |
setTimeout(() => { | |
wrapper.update(); | |
expect(localStorage.setItem).toHaveBeenCalled(); | |
done(); | |
}); | |
}); | |
}); | |
// src/services/__mocks__/userVoiceSSOToken.js | |
const mockTokenData = { | |
user_voice_single_sign_on_token: { | |
value: | |
'eyJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDJmN2E2N2VhZDMyYzNhMTY0OTdkOGVjYTNlNzNmODQiLCJlbWFpbCI6InRlc3RpbmctbmVvQGJhYmJlbC5jb20iLCJkaXNwbGF5X25hbWUiOiJUZXN0aW5nIE5lbyIsImV4cGlyZXMiOjE1NjIxODU5NTh9.stFB_euobxPd1IE5lw4QYjdhJoHzdXTbXddCTqzvmQs' | |
} | |
}; | |
export default async () => { | |
return await new Promise(resolve => { | |
resolve(mockTokenData); | |
}); | |
}; | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">describe('SSO UserVoice token', () => { | |
it('Gets token from endpoint and set up consent in local storage', done => { | |
const wrapper = shallow(<ConsentUserVoice />); | |
jest.spyOn(window.localStorage.__proto__, 'getItem'); | |
window.localStorage.__proto__.getItem = jest.fn(); | |
jest.spyOn(window.localStorage.__proto__, 'setItem'); | |
window.localStorage.__proto__.setItem = jest.fn(); | |
setTimeout(() => { | |
wrapper.update(); | |
expect(localStorage.setItem).toHaveBeenCalled(); | |
done(); | |
}); | |
}); | |
}); | |
// src/services/__mocks__/userVoiceSSOToken.js | |
const mockTokenData = { | |
user_voice_single_sign_on_token: { | |
value: | |
'eyJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDJmN2E2N2VhZDMyYzNhMTY0OTdkOGVjYTNlNzNmODQiLCJlbWFpbCI6InRlc3RpbmctbmVvQGJhYmJlbC5jb20iLCJkaXNwbGF5X25hbWUiOiJUZXN0aW5nIE5lbyIsImV4cGlyZXMiOjE1NjIxODU5NTh9.stFB_euobxPd1IE5lw4QYjdhJoHzdXTbXddCTqzvmQs' | |
} | |
}; | |
export default async () => { | |
return await new Promise(resolve => { | |
resolve(mockTokenData); | |
}); | |
};</script> |
This file contains hidden or 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
describe('SSO UserVoice token', () => { | |
it('Gets token from endpoint and set up consent in local storage', done => { | |
const wrapper = shallow(<ConsentUserVoice />); | |
jest.spyOn(window.localStorage.__proto__, 'getItem'); | |
window.localStorage.__proto__.getItem = jest.fn(); | |
jest.spyOn(window.localStorage.__proto__, 'setItem'); | |
window.localStorage.__proto__.setItem = jest.fn(); | |
setTimeout(() => { | |
wrapper.update(); | |
expect(localStorage.setItem).toHaveBeenCalled(); | |
done(); | |
}); | |
}); | |
}); | |
// src/services/__mocks__/userVoiceSSOToken.js | |
const mockTokenData = { | |
user_voice_single_sign_on_token: { | |
value: | |
'eyJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDJmN2E2N2VhZDMyYzNhMTY0OTdkOGVjYTNlNzNmODQiLCJlbWFpbCI6InRlc3RpbmctbmVvQGJhYmJlbC5jb20iLCJkaXNwbGF5X25hbWUiOiJUZXN0aW5nIE5lbyIsImV4cGlyZXMiOjE1NjIxODU5NTh9.stFB_euobxPd1IE5lw4QYjdhJoHzdXTbXddCTqzvmQs' | |
} | |
}; | |
export default async () => { | |
return await new Promise(resolve => { | |
resolve(mockTokenData); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment