Welcome to mirror list, hosted at ThFree Co, Russian Federation.

oauth_remember_me_spec.js « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 33295d46feae0b26242497905e573256f64b2eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import $ from 'jquery';
import htmlOauthRememberMe from 'test_fixtures_static/oauth_remember_me.html';
import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
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(() => {
    setHTMLFixture(htmlOauthRememberMe);

    new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents();
  });

  afterEach(() => {
    resetHTMLFixture();
  });

  it('adds and removes the "remember_me" query parameter from all OAuth login buttons', () => {
    $('#oauth-container #remember_me_omniauth').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(
      'http://example.com/?redirect_fragment=L1&remember_me=1',
    );

    $('#oauth-container #remember_me_omniauth').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');
  });
});