2018-10-20 15:00:01 +00:00
|
|
|
/* eslint-env jest */
|
2018-08-13 18:03:59 +00:00
|
|
|
import { Component } from 'react'
|
2018-10-01 22:55:31 +00:00
|
|
|
import { getDisplayName } from 'next-server/dist/lib/utils'
|
2018-08-13 18:03:59 +00:00
|
|
|
|
|
|
|
describe('getDisplayName', () => {
|
|
|
|
it('gets the proper display name of a component', () => {
|
|
|
|
class ComponentOne extends Component {
|
|
|
|
render () {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ComponentTwo extends Component {
|
|
|
|
static displayName = 'CustomDisplayName'
|
|
|
|
render () {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function FunctionalComponent () {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(getDisplayName(ComponentOne)).toBe('ComponentOne')
|
|
|
|
expect(getDisplayName(ComponentTwo)).toBe('CustomDisplayName')
|
|
|
|
expect(getDisplayName(FunctionalComponent)).toBe('FunctionalComponent')
|
|
|
|
expect(getDisplayName(() => null)).toBe('Unknown')
|
|
|
|
expect(getDisplayName('div')).toBe('div')
|
|
|
|
})
|
|
|
|
})
|