gitlab-org--gitlab-foss/spec/frontend/oauth_remember_me_spec.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

import $ from 'jquery';
2018-01-10 13:56:15 -05:00
import OAuthRememberMe from '~/pages/sessions/new/oauth_remember_me';
describe('OAuthRememberMe', () => {
const findFormAction = (selector) => {
return $(`#oauth-container .js-oauth-login${selector}`).parent('form').attr('action');
};
beforeEach(() => {
loadFixtures('static/oauth_remember_me.html');
new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents();
});
it('adds the "remember_me" query parameter to all OAuth login buttons', () => {
$('#oauth-container #remember_me').click();
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',
);
});
it('removes the "remember_me" query parameter from all OAuth login buttons', () => {
$('#oauth-container #remember_me').click();
$('#oauth-container #remember_me').click();
expect(findFormAction('.twitter')).toBe('http://example.com/');
expect(findFormAction('.github')).toBe('http://example.com/');
expect(findFormAction('.facebook')).toBe('http://example.com/?redirect_fragment=L1');
});
});