2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2018-01-10 13:56:15 -05:00
|
|
|
import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me';
|
2017-07-04 07:59:41 -04:00
|
|
|
|
|
|
|
describe('OAuthRememberMe', () => {
|
2020-12-23 19:10:25 -05:00
|
|
|
const findFormAction = (selector) => {
|
2021-10-08 17:09:48 -04:00
|
|
|
return $(`#oauth-container .js-oauth-login${selector}`).parent('form').attr('action');
|
2020-06-09 20:08:55 -04:00
|
|
|
};
|
|
|
|
|
2017-07-04 07:59:41 -04:00
|
|
|
beforeEach(() => {
|
2019-03-26 12:03:28 -04:00
|
|
|
loadFixtures('static/oauth_remember_me.html');
|
2017-07-04 07:59:41 -04:00
|
|
|
|
|
|
|
new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('adds the "remember_me" query parameter to all OAuth login buttons', () => {
|
|
|
|
$('#oauth-container #remember_me').click();
|
|
|
|
|
2020-06-09 20:08:55 -04:00
|
|
|
expect(findFormAction('.twitter')).toBe('http://example.com/?remember_me=1');
|
|
|
|
expect(findFormAction('.github')).toBe('http://example.com/?remember_me=1');
|
|
|
|
expect(findFormAction('.facebook')).toBe(
|
2018-11-27 08:16:24 -05:00
|
|
|
'http://example.com/?redirect_fragment=L1&remember_me=1',
|
2018-06-04 17:30:59 -04:00
|
|
|
);
|
2017-07-04 07:59:41 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('removes the "remember_me" query parameter from all OAuth login buttons', () => {
|
|
|
|
$('#oauth-container #remember_me').click();
|
|
|
|
$('#oauth-container #remember_me').click();
|
|
|
|
|
2020-06-09 20:08:55 -04:00
|
|
|
expect(findFormAction('.twitter')).toBe('http://example.com/');
|
|
|
|
expect(findFormAction('.github')).toBe('http://example.com/');
|
|
|
|
expect(findFormAction('.facebook')).toBe('http://example.com/?redirect_fragment=L1');
|
2017-07-04 07:59:41 -04:00
|
|
|
});
|
|
|
|
});
|