summaryrefslogtreecommitdiff
path: root/web-ui/test/unit/login/app.spec.js
blob: 2036dfd70926867145d8b7433ea0ad2a0c32cee4 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { shallow } from 'enzyme';
import expect from 'expect';
import React from 'react';
import { App } from 'src/login/app';
import AuthError from 'src/login/error/auth_error';
import GenericError from 'src/login/error/generic_error';
import PixelatedWelcome from 'src/login/about/pixelated_welcome';

describe('App', () => {
  let app;
  const mockTranslations = key => key;

  it('renders login form', () => {
    app = shallow(<App t={mockTranslations} />);
    expect(app.find('form').props().action).toEqual('/login');
  });

  it('renders welcome message when no error', () => {
    app = shallow(<App t={mockTranslations} />);
    expect(app.find(PixelatedWelcome).length).toEqual(1);
  });

  it('renders auth error message', () => {
    app = shallow(<App t={mockTranslations} authError />);
    expect(app.find(AuthError).length).toEqual(1);
  });

  it('renders generic error message when error', () => {
    app = shallow(<App t={mockTranslations} error />);
    expect(app.find(GenericError).length).toEqual(1);
  });

  it('does not render welcome message when error', () => {
    app = shallow(<App t={mockTranslations} error />);
    expect(app.find(PixelatedWelcome).length).toEqual(0);
  });

  it('does not render error message', () => {
    app = shallow(<App t={mockTranslations} />);
    expect(app.find(AuthError).length).toEqual(0);
    expect(app.find(GenericError).length).toEqual(0);
  });

  it('adds small logo class when error', () => {
    app = shallow(<App t={mockTranslations} error />);
    expect(app.find('.logo').props().className).toEqual('logo small-logo');
  });

  it('does not add small logo class when no error', () => {
    app = shallow(<App t={mockTranslations} />);
    expect(app.find('.logo').props().className).toEqual('logo');
  });

});