Improve sprite icon spec

This commit is contained in:
Clement Ho 2017-10-17 16:19:40 +00:00 committed by Phil Hughes
parent 89f5ede2a3
commit 22a120a24d
1 changed files with 18 additions and 10 deletions

View File

@ -467,19 +467,27 @@ describe('common_utils', () => {
commonUtils.ajaxPost(requestURL, data);
expect(ajaxSpy.calls.allArgs()[0][0].type).toEqual('POST');
});
});
describe('gl.utils.spriteIcon', () => {
beforeEach(() => {
window.gon.sprite_icons = 'icons.svg';
});
describe('spriteIcon', () => {
let beforeGon;
it('should return the svg for a linked icon', () => {
expect(gl.utils.spriteIcon('test')).toEqual('<svg ><use xlink:href="icons.svg#test" /></svg>');
});
beforeEach(() => {
window.gon = window.gon || {};
beforeGon = Object.assign({}, window.gon);
window.gon.sprite_icons = 'icons.svg';
});
it('should set svg className when passed', () => {
expect(gl.utils.spriteIcon('test', 'fa fa-test')).toEqual('<svg class="fa fa-test"><use xlink:href="icons.svg#test" /></svg>');
});
afterEach(() => {
window.gon = beforeGon;
});
it('should return the svg for a linked icon', () => {
expect(commonUtils.spriteIcon('test')).toEqual('<svg ><use xlink:href="icons.svg#test" /></svg>');
});
it('should set svg className when passed', () => {
expect(commonUtils.spriteIcon('test', 'fa fa-test')).toEqual('<svg class="fa fa-test"><use xlink:href="icons.svg#test" /></svg>');
});
});
});