2015-05-28 08:52:41 +03:00
|
|
|
/* jshint expr:true */
|
|
|
|
/* global md5 */
|
|
|
|
import { expect } from 'chai';
|
|
|
|
import {
|
|
|
|
describeComponent,
|
|
|
|
it
|
|
|
|
} from 'ember-mocha';
|
|
|
|
|
2015-10-06 19:31:03 +03:00
|
|
|
describeComponent(
|
|
|
|
'gh-profile-image',
|
|
|
|
'Unit: Component: gh-profile-image',
|
|
|
|
{
|
|
|
|
unit: true,
|
2015-05-28 08:52:41 +03:00
|
|
|
needs: ['service:ghost-paths']
|
2015-10-06 19:31:03 +03:00
|
|
|
},
|
|
|
|
function () {
|
2015-05-28 08:52:41 +03:00
|
|
|
it('renders', function () {
|
|
|
|
// creates the component instance
|
|
|
|
var component = this.subject();
|
|
|
|
expect(component._state).to.equal('preRender');
|
|
|
|
|
|
|
|
// renders the component on the page
|
|
|
|
this.render();
|
|
|
|
expect(component._state).to.equal('inDOM');
|
|
|
|
});
|
|
|
|
it('renders the gravatar image background if email is supplied', function () {
|
|
|
|
var component = this.subject(),
|
|
|
|
testEmail = 'test@example.com',
|
|
|
|
style, size;
|
|
|
|
|
|
|
|
component.set('email', testEmail);
|
|
|
|
this.render();
|
|
|
|
|
|
|
|
size = component.get('size');
|
|
|
|
|
|
|
|
style = 'url(http://www.gravatar.com/avatar/' + md5(testEmail) + '?s=' + size + '&d=blank)';
|
|
|
|
|
|
|
|
expect(component.$('#account-image').css('background-image')).to.equal(style);
|
|
|
|
});
|
|
|
|
it('doesn\'t render the gravatar image background if email isn\'t supplied', function () {
|
|
|
|
var component = this.subject();
|
|
|
|
|
|
|
|
this.render();
|
|
|
|
|
|
|
|
expect(component.$('#account-image').length).to.equal(0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|