Commit 5202c3f0 authored by Alexis Reigel's avatar Alexis Reigel Committed by Alexis Reigel

fix resetFavicon so that it actually resets

parent 67fe0a17
...@@ -393,8 +393,9 @@ export const setFavicon = (faviconPath) => { ...@@ -393,8 +393,9 @@ export const setFavicon = (faviconPath) => {
export const resetFavicon = () => { export const resetFavicon = () => {
const faviconEl = document.getElementById('favicon'); const faviconEl = document.getElementById('favicon');
const originalFavicon = faviconEl ? faviconEl.getAttribute('href') : null;
if (faviconEl) { if (faviconEl) {
const originalFavicon = faviconEl.getAttribute('data-default-href');
faviconEl.setAttribute('href', originalFavicon); faviconEl.setAttribute('href', originalFavicon);
} }
}; };
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
%title= page_title(site_name) %title= page_title(site_name)
%meta{ name: "description", content: page_description } %meta{ name: "description", content: page_description }
= favicon_link_tag favicon, id: 'favicon' = favicon_link_tag favicon, id: 'favicon', :'data-default-href': favicon
= stylesheet_link_tag "application", media: "all" = stylesheet_link_tag "application", media: "all"
= stylesheet_link_tag "print", media: "print" = stylesheet_link_tag "print", media: "print"
......
...@@ -395,6 +395,7 @@ describe('common_utils', () => { ...@@ -395,6 +395,7 @@ describe('common_utils', () => {
const favicon = document.createElement('link'); const favicon = document.createElement('link');
favicon.setAttribute('id', 'favicon'); favicon.setAttribute('id', 'favicon');
favicon.setAttribute('href', 'default/favicon'); favicon.setAttribute('href', 'default/favicon');
favicon.setAttribute('data-default-href', 'default/favicon');
document.body.appendChild(favicon); document.body.appendChild(favicon);
}); });
...@@ -413,7 +414,7 @@ describe('common_utils', () => { ...@@ -413,7 +414,7 @@ describe('common_utils', () => {
beforeEach(() => { beforeEach(() => {
const favicon = document.createElement('link'); const favicon = document.createElement('link');
favicon.setAttribute('id', 'favicon'); favicon.setAttribute('id', 'favicon');
favicon.setAttribute('href', 'default/favicon'); favicon.setAttribute('data-original-href', 'default/favicon');
document.body.appendChild(favicon); document.body.appendChild(favicon);
}); });
...@@ -421,7 +422,9 @@ describe('common_utils', () => { ...@@ -421,7 +422,9 @@ describe('common_utils', () => {
document.body.removeChild(document.getElementById('favicon')); document.body.removeChild(document.getElementById('favicon'));
}); });
it('should reset page favicon to tanuki', () => { it('should reset page favicon to the default icon', () => {
const favicon = document.getElementById('favicon');
favicon.setAttribute('href', 'new/favicon');
commonUtils.resetFavicon(); commonUtils.resetFavicon();
expect(document.getElementById('favicon').getAttribute('href')).toEqual('default/favicon'); expect(document.getElementById('favicon').getAttribute('href')).toEqual('default/favicon');
}); });
...@@ -434,6 +437,8 @@ describe('common_utils', () => { ...@@ -434,6 +437,8 @@ describe('common_utils', () => {
beforeEach(() => { beforeEach(() => {
const favicon = document.createElement('link'); const favicon = document.createElement('link');
favicon.setAttribute('id', 'favicon'); favicon.setAttribute('id', 'favicon');
favicon.setAttribute('href', 'null');
favicon.setAttribute('data-original-href', faviconDataUrl);
document.body.appendChild(favicon); document.body.appendChild(favicon);
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
}); });
...@@ -449,7 +454,7 @@ describe('common_utils', () => { ...@@ -449,7 +454,7 @@ describe('common_utils', () => {
commonUtils.setCiStatusFavicon(BUILD_URL) commonUtils.setCiStatusFavicon(BUILD_URL)
.then(() => { .then(() => {
const favicon = document.getElementById('favicon'); const favicon = document.getElementById('favicon');
expect(favicon.getAttribute('href')).toEqual('null'); expect(favicon.getAttribute('href')).toEqual(faviconDataUrl);
done(); done();
}) })
// Error is already caught in catch() block of setCiStatusFavicon, // Error is already caught in catch() block of setCiStatusFavicon,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment