Add tests to `home-logo` component
This commit is contained in:
parent
9c61f45bf9
commit
a9daa33953
|
@ -1,7 +1,7 @@
|
|||
<a href="{{unbound linkUrl}}" data-auto-route="true">
|
||||
{{#if showSmallLogo}}
|
||||
{{#if smallLogoUrl}}
|
||||
<img class="logo-small" src="{{unbound smallLogoUrl}}" width="33" height="33">
|
||||
<img class="logo-small" src="{{unbound smallLogoUrl}}" width="33" height="33" alt="{{unbound title}}">
|
||||
{{else}}
|
||||
<i class="fa fa-home"></i>
|
||||
{{/if}}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
import componentTest from 'helpers/component-test';
|
||||
|
||||
moduleForComponent('home-logo', {integration: true});
|
||||
|
||||
const bigLogo = '/images/d-logo-sketch.png?test';
|
||||
const smallLogo = '/images/d-logo-sketch-small.png?test';
|
||||
const mobileLogo = '/images/d-logo-sketch.png?mobile';
|
||||
const title = "Cool Forum";
|
||||
|
||||
componentTest('basics', {
|
||||
template: '{{home-logo minimized=minimized}}',
|
||||
setup() {
|
||||
this.siteSettings.logo_url = bigLogo;
|
||||
this.siteSettings.logo_small_url= smallLogo;
|
||||
this.siteSettings.title = title;
|
||||
this.set('minimized', false);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$('a[data-auto-route]').length === 1);
|
||||
|
||||
assert.ok(this.$('img#site-logo.logo-big').length === 1);
|
||||
assert.equal(this.$('#site-logo').attr('src'), bigLogo);
|
||||
assert.equal(this.$('#site-logo').attr('alt'), title);
|
||||
|
||||
this.set('minimized', true);
|
||||
andThen(() => {
|
||||
assert.ok(this.$('img.logo-small').length === 1);
|
||||
assert.equal(this.$('img.logo-small').attr('src'), smallLogo);
|
||||
assert.equal(this.$('img.logo-small').attr('alt'), title);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
componentTest('no logo', {
|
||||
template: '{{home-logo minimized=minimized}}',
|
||||
setup() {
|
||||
this.siteSettings.logo_url = '';
|
||||
this.siteSettings.logo_small_url = '';
|
||||
this.siteSettings.title = title;
|
||||
this.set('minimized', false);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$('a[data-auto-route]').length === 1);
|
||||
|
||||
assert.ok(this.$('h2#site-text-logo.text-logo').length === 1);
|
||||
assert.equal(this.$('#site-text-logo').text(), title);
|
||||
|
||||
this.set('minimized', true);
|
||||
andThen(() => {
|
||||
assert.ok(this.$('i.fa-home').length === 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
componentTest('mobile logo', {
|
||||
template: "{{home-logo minimized=minimized}}",
|
||||
setup() {
|
||||
this.siteSettings.mobile_logo_url = mobileLogo;
|
||||
this.siteSettings.logo_small_url= smallLogo;
|
||||
this.set('minimized', true);
|
||||
this.site.mobileView = true;
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$('img#site-logo.logo-big').length === 1);
|
||||
assert.equal(this.$('#site-logo').attr('src'), mobileLogo);
|
||||
|
||||
this.set('minimized', true);
|
||||
andThen(() => {
|
||||
assert.equal(this.$('#site-logo').attr('src'), mobileLogo);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
componentTest('mobile without logo', {
|
||||
template: "{{home-logo minimized=minimized}}",
|
||||
setup() {
|
||||
this.set('minimized', true);
|
||||
this.siteSettings.logo_url = bigLogo;
|
||||
this.site.mobileView = true;
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
assert.ok(this.$('img#site-logo.logo-big').length === 1);
|
||||
assert.equal(this.$('#site-logo').attr('src'), bigLogo);
|
||||
}
|
||||
});
|
||||
|
||||
componentTest("changing url", {
|
||||
template: '{{home-logo targetUrl="https://www.discourse.org"}}',
|
||||
test(assert) {
|
||||
assert.equal(this.$('a').attr('href'), 'https://www.discourse.org');
|
||||
}
|
||||
});
|
|
@ -7,10 +7,12 @@ export default function(name, opts) {
|
|||
|
||||
test(name, function(assert) {
|
||||
const appEvents = AppEvents.create();
|
||||
this.site = Discourse.Site.current();
|
||||
|
||||
this.container.register('site-settings:main', Discourse.SiteSettings, { instantiate: false });
|
||||
this.container.register('app-events:main', appEvents, { instantiate: false });
|
||||
this.container.register('capabilities:main', Ember.Object);
|
||||
this.container.register('site:main', Discourse.Site.current(), { instantiate: false });
|
||||
this.container.register('site:main', this.site, { instantiate: false });
|
||||
this.container.injection('component', 'siteSettings', 'site-settings:main');
|
||||
this.container.injection('component', 'appEvents', 'app-events:main');
|
||||
this.container.injection('component', 'capabilities', 'capabilities:main');
|
||||
|
|
Loading…
Reference in New Issue