import assert from 'assert'; import { shallow } from 'enzyme'; import React from 'react'; import { FieldTitle } from './FieldTitle'; describe('FieldTitle', () => { const translateMock = dictionary => (term, options) => dictionary[term] || options._ || ''; it('should return empty span by default', () => assert.equal(shallow().html(), '')); it('should use the label when given', () => assert.equal( shallow().html(), 'foo' )); it('should the label as translate key when translation is available', () => assert.equal( shallow( ).html(), 'bar' )); it('should use the humanized source when given', () => { assert.equal( shallow( ).html(), 'Title' ); assert.equal( shallow( ).html(), 'Title with underscore' ); assert.equal( shallow( ).html(), 'Title with camel case' ); }); it('should use the source and resource as translate key when translation is available', () => assert.equal( shallow( ).html(), 'titre' )); it('should use label rather than source', () => assert.equal( shallow( ).html(), 'foo' )); it('should add a trailing asterisk if the field is required', () => assert.equal( shallow().html(), 'foo *' )); });