2016-10-18 01:54:49 +01:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import { render } from 'enzyme';
|
2017-07-11 00:00:14 +01:00
|
|
|
import { fromJS } from 'immutable';
|
2017-06-01 16:27:15 +01:00
|
|
|
import React from 'react';
|
|
|
|
import DisplayName from '../../../app/javascript/mastodon/components/display_name';
|
2016-10-18 01:54:49 +01:00
|
|
|
|
|
|
|
describe('<DisplayName />', () => {
|
2016-10-20 16:34:44 +01:00
|
|
|
it('renders display name + account name', () => {
|
2017-07-11 00:00:14 +01:00
|
|
|
const account = fromJS({
|
2016-10-20 16:34:44 +01:00
|
|
|
username: 'bar',
|
|
|
|
acct: 'bar@baz',
|
2017-06-01 16:27:15 +01:00
|
|
|
display_name: 'Foo',
|
2016-10-20 16:34:44 +01:00
|
|
|
});
|
|
|
|
const wrapper = render(<DisplayName account={account} />);
|
|
|
|
expect(wrapper).to.have.text('Foo @bar@baz');
|
2016-10-18 01:54:49 +01:00
|
|
|
});
|
|
|
|
|
2016-10-20 16:34:44 +01:00
|
|
|
it('renders the username + account name if display name is empty', () => {
|
2017-07-11 00:00:14 +01:00
|
|
|
const account = fromJS({
|
2016-10-20 16:34:44 +01:00
|
|
|
username: 'bar',
|
|
|
|
acct: 'bar@baz',
|
2017-06-01 16:27:15 +01:00
|
|
|
display_name: '',
|
2016-10-20 16:34:44 +01:00
|
|
|
});
|
|
|
|
const wrapper = render(<DisplayName account={account} />);
|
|
|
|
expect(wrapper).to.have.text('bar @bar@baz');
|
2016-10-18 01:54:49 +01:00
|
|
|
});
|
|
|
|
});
|