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) => {
export const resetFavicon = () => {
const faviconEl = document.getElementById('favicon');
const originalFavicon = faviconEl ? faviconEl.getAttribute('href') : null;
if (faviconEl) {
const originalFavicon = faviconEl.getAttribute('data-default-href');
faviconEl.setAttribute('href', originalFavicon);
}
};
......
......@@ -25,7 +25,7 @@
%title= page_title(site_name)
%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 "print", media: "print"
......
......@@ -395,6 +395,7 @@ describe('common_utils', () => {
const favicon = document.createElement('link');
favicon.setAttribute('id', 'favicon');
favicon.setAttribute('href', 'default/favicon');
favicon.setAttribute('data-default-href', 'default/favicon');
document.body.appendChild(favicon);
});
......@@ -413,7 +414,7 @@ describe('common_utils', () => {
beforeEach(() => {
const favicon = document.createElement('link');
favicon.setAttribute('id', 'favicon');
favicon.setAttribute('href', 'default/favicon');
favicon.setAttribute('data-original-href', 'default/favicon');
document.body.appendChild(favicon);
});
......@@ -421,7 +422,9 @@ describe('common_utils', () => {
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();
expect(document.getElementById('favicon').getAttribute('href')).toEqual('default/favicon');
});
......@@ -434,6 +437,8 @@ describe('common_utils', () => {
beforeEach(() => {
const favicon = document.createElement('link');
favicon.setAttribute('id', 'favicon');
favicon.setAttribute('href', 'null');
favicon.setAttribute('data-original-href', faviconDataUrl);
document.body.appendChild(favicon);
mock = new MockAdapter(axios);
});
......@@ -449,7 +454,7 @@ describe('common_utils', () => {
commonUtils.setCiStatusFavicon(BUILD_URL)
.then(() => {
const favicon = document.getElementById('favicon');
expect(favicon.getAttribute('href')).toEqual('null');
expect(favicon.getAttribute('href')).toEqual(faviconDataUrl);
done();
})
// 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