2015-10-26 14:48:38 +03:00
|
|
|
/* jshint expr:true */
|
|
|
|
/* global md5 */
|
|
|
|
import { expect } from 'chai';
|
|
|
|
import {
|
|
|
|
describeComponent,
|
|
|
|
it
|
|
|
|
} from 'ember-mocha';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import Ember from 'ember';
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {run} = Ember;
|
|
|
|
|
|
|
|
let pathsStub = Ember.Service.extend({
|
|
|
|
url: {
|
|
|
|
api() {
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
asset(src) {
|
|
|
|
return src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2015-10-26 14:48:38 +03:00
|
|
|
|
|
|
|
describeComponent(
|
|
|
|
'gh-profile-image',
|
|
|
|
'Integration: Component: gh-profile-image',
|
|
|
|
{
|
|
|
|
integration: true
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.register('service:ghost-paths', pathsStub);
|
|
|
|
this.inject.service('ghost-paths', {as: 'ghost-paths'});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders', function () {
|
|
|
|
this.set('email', '');
|
|
|
|
|
|
|
|
this.render(hbs`
|
|
|
|
{{gh-profile-image email=email}}
|
|
|
|
`);
|
|
|
|
|
|
|
|
expect(this.$()).to.have.length(1);
|
|
|
|
});
|
|
|
|
|
2015-12-21 14:08:49 +03:00
|
|
|
it('renders and tears down ok with fileStorage:false', function () {
|
|
|
|
this.set('fileStorage', false);
|
|
|
|
|
|
|
|
this.render(hbs`
|
|
|
|
{{gh-profile-image fileStorage=fileStorage}}
|
|
|
|
`);
|
|
|
|
|
|
|
|
expect(this.$()).to.have.length(1);
|
|
|
|
expect(this.$('input')).to.have.length(0);
|
|
|
|
}),
|
|
|
|
|
2015-10-26 14:48:38 +03:00
|
|
|
it('immediately renders the gravatar if valid email supplied', function () {
|
2015-10-28 14:36:45 +03:00
|
|
|
let email = 'test@example.com';
|
2016-03-25 07:03:45 +03:00
|
|
|
let expectedUrl = `//www.gravatar.com/avatar/${md5(email)}?s=100&d=404`;
|
2015-10-26 14:48:38 +03:00
|
|
|
|
|
|
|
this.set('email', email);
|
|
|
|
|
|
|
|
this.render(hbs`
|
|
|
|
{{gh-profile-image email=email size=100 debounce=300}}
|
|
|
|
`);
|
|
|
|
|
|
|
|
expect(this.$('.gravatar-img').attr('style'), 'gravatar image style')
|
|
|
|
.to.equal(`background-image: url(${expectedUrl})`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|