Remove tests for texture-preview module
This commit is contained in:
parent
d54709c23d
commit
0373c0ada6
|
|
@ -147,135 +147,6 @@ describe('tests for "polyfill" module', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tests for "texture-preview" module', () => {
|
|
||||||
const TexturePreview = require('../common/texture-preview');
|
|
||||||
|
|
||||||
it('change 2d preview', () => {
|
|
||||||
const url = jest.fn(path => path);
|
|
||||||
window.url = url;
|
|
||||||
|
|
||||||
document.body.innerHTML = `
|
|
||||||
<a><img id="steve" /></a>
|
|
||||||
<div></div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
const instance = new TexturePreview('steve', 5, 'default');
|
|
||||||
instance.change2dPreview();
|
|
||||||
expect($('img').attr('src')).toBe('preview/200/5.png');
|
|
||||||
expect($('a').attr('href')).toBe('skinlib/show/5');
|
|
||||||
expect($('div').css('display')).toBe('none');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('change 3d preview', async () => {
|
|
||||||
const url = jest.fn(path => path);
|
|
||||||
const fetch = jest.fn()
|
|
||||||
.mockReturnValueOnce(Promise.resolve({ hash: '1' }))
|
|
||||||
.mockReturnValueOnce(Promise.resolve({ hash: '2' }))
|
|
||||||
.mockReturnValueOnce(Promise.reject());
|
|
||||||
const showAjaxError = jest.fn();
|
|
||||||
const MSP = {
|
|
||||||
changeSkin: jest.fn(),
|
|
||||||
changeCape: jest.fn()
|
|
||||||
};
|
|
||||||
window.url = url;
|
|
||||||
window.fetch = fetch;
|
|
||||||
window.showAjaxError = showAjaxError;
|
|
||||||
window.MSP = MSP;
|
|
||||||
|
|
||||||
let instance = new TexturePreview('alex', 5, 'default');
|
|
||||||
instance.change3dPreview();
|
|
||||||
expect(fetch).not.toBeCalled();
|
|
||||||
|
|
||||||
instance = new TexturePreview('steve', 5, 'default');
|
|
||||||
await instance.change3dPreview();
|
|
||||||
expect(fetch).toBeCalledWith({
|
|
||||||
type: 'GET',
|
|
||||||
url: 'skinlib/info/5',
|
|
||||||
dataType: 'json'
|
|
||||||
});
|
|
||||||
expect(MSP.changeSkin).toBeCalledWith('textures/1');
|
|
||||||
|
|
||||||
instance = new TexturePreview('cape', 5, 'default');
|
|
||||||
await instance.change3dPreview();
|
|
||||||
expect(fetch).toBeCalledWith({
|
|
||||||
type: 'GET',
|
|
||||||
url: 'skinlib/info/5',
|
|
||||||
dataType: 'json'
|
|
||||||
});
|
|
||||||
expect(MSP.changeCape).toBeCalledWith('textures/2');
|
|
||||||
|
|
||||||
await instance.change3dPreview();
|
|
||||||
expect(showAjaxError).toBeCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('show not uploaded', () => {
|
|
||||||
const MSP = {
|
|
||||||
changeSkin: jest.fn(),
|
|
||||||
changeCape: jest.fn()
|
|
||||||
};
|
|
||||||
window.MSP = MSP;
|
|
||||||
document.body.innerHTML = `
|
|
||||||
<a><img id="steve" /></a>
|
|
||||||
<div></div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
let instance = new TexturePreview('steve', 5, 'default');
|
|
||||||
instance.showNotUploaded();
|
|
||||||
expect($('img').css('display')).toBe('none');
|
|
||||||
expect($('div').css('display')).not.toBe('none');
|
|
||||||
|
|
||||||
instance = new TexturePreview('cape', 7, 'cape');
|
|
||||||
instance.showNotUploaded();
|
|
||||||
expect(MSP.changeCape).toBeCalledWith('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('show 3d preview', () => {
|
|
||||||
document.body.innerHTML = `
|
|
||||||
<a id="preview-2d"></a>
|
|
||||||
<a class="operations" style="display: none"></a>
|
|
||||||
<a id="preview-switch"></a>
|
|
||||||
<div id="skinpreview"></div>
|
|
||||||
`;
|
|
||||||
const trans = jest.fn(key => key);
|
|
||||||
const MSP = {
|
|
||||||
changeSkin: jest.fn(),
|
|
||||||
changeCape: jest.fn(),
|
|
||||||
get3dSkinCanvas: jest.fn(() => '<canvas></canvas>')
|
|
||||||
};
|
|
||||||
window.trans = trans;
|
|
||||||
window.MSP = MSP;
|
|
||||||
|
|
||||||
TexturePreview.previewType = '3D';
|
|
||||||
TexturePreview.show3dPreview();
|
|
||||||
expect($('#preview-2d').css('display')).toBe('none');
|
|
||||||
expect($('.operations').css('display')).not.toBe('none');
|
|
||||||
expect($('#preview-switch').html()).toBe('user.switch2dPreview');
|
|
||||||
expect(MSP.get3dSkinCanvas).toBeCalledWith(0, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('show 2d preview', () => {
|
|
||||||
document.body.innerHTML = `
|
|
||||||
<div id="canvas3d"></div>
|
|
||||||
<a id="preview-2d" style="display: none"></a>
|
|
||||||
<a class="operations"></a>
|
|
||||||
<a id="preview-switch"></a>
|
|
||||||
`;
|
|
||||||
const trans = jest.fn(key => key);
|
|
||||||
const MSP = {
|
|
||||||
changeSkin: jest.fn(),
|
|
||||||
changeCape: jest.fn()
|
|
||||||
};
|
|
||||||
window.trans = trans;
|
|
||||||
window.MSP = MSP;
|
|
||||||
|
|
||||||
TexturePreview.show2dPreview();
|
|
||||||
expect(document.getElementById('canvas3d')).toBeNull();
|
|
||||||
expect($('#preview-2d').css('display')).not.toBe('none');
|
|
||||||
expect($('.operations').css('display')).toBe('none');
|
|
||||||
expect($('#preview-switch').html()).toBe('user.switch3dPreview');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('tests for "utils" module', () => {
|
describe('tests for "utils" module', () => {
|
||||||
const modulePath = '../common/utils';
|
const modulePath = '../common/utils';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
/* global skinview3d */
|
/* global skinview3d */
|
||||||
|
|
||||||
|
// TODO: Help wanted. This file needs to be tested.
|
||||||
|
|
||||||
$.msp = {};
|
$.msp = {};
|
||||||
$.msp.handles = {};
|
$.msp.handles = {};
|
||||||
$.msp.control = null;
|
$.msp.control = null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user