| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /* eslint-disable
- no-return-assign,
- */
- // TODO: This file was created by bulk-decaffeinate.
- // Fix any style issues and re-enable lint.
- /*
- * decaffeinate suggestions:
- * DS102: Remove unnecessary code created because of implicit returns
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
- */
- import { expect } from 'chai'
- import displayNameForUser from '../../../../../frontend/js/ide/history/util/displayNameForUser'
- export default describe('displayNameForUser', function () {
- beforeEach(function () {
- return (window.user = { id: 42 })
- })
- it("should return 'Anonymous' with no user", function () {
- return expect(displayNameForUser(null)).to.equal('Anonymous')
- })
- it("should return 'you' when the user has the same id as the window", function () {
- return expect(
- displayNameForUser({
- id: window.user.id,
- email: 'james.allen@overleaf.com',
- first_name: 'James',
- last_name: 'Allen',
- })
- ).to.equal('you')
- })
- it('should return the first_name and last_name when present', function () {
- return expect(
- displayNameForUser({
- id: window.user.id + 1,
- email: 'james.allen@overleaf.com',
- first_name: 'James',
- last_name: 'Allen',
- })
- ).to.equal('James Allen')
- })
- it('should return only the firstAname if no last_name', function () {
- return expect(
- displayNameForUser({
- id: window.user.id + 1,
- email: 'james.allen@overleaf.com',
- first_name: 'James',
- last_name: '',
- })
- ).to.equal('James')
- })
- it('should return the email username if there are no names', function () {
- return expect(
- displayNameForUser({
- id: window.user.id + 1,
- email: 'james.allen@overleaf.com',
- first_name: '',
- last_name: '',
- })
- ).to.equal('james.allen')
- })
- it("should return the '?' if it has nothing", function () {
- return expect(
- displayNameForUser({
- id: window.user.id + 1,
- email: '',
- first_name: '',
- last_name: '',
- })
- ).to.equal('?')
- })
- })
|