Update tests

This commit is contained in:
printempw 2017-08-01 14:39:44 +08:00
parent 3e798d9cc5
commit 5fd8ef62aa
2 changed files with 36 additions and 0 deletions

View File

@ -8,6 +8,7 @@ describe('tests for "customize" module', () => {
it('change skin preview after switching color', () => {
window.current_skin = 'skin-blue';
window.showAjaxError = jest.fn();
document.body.className = window.current_skin;
document.body.innerHTML = `
<div id="layout-skins-list">
@ -35,6 +36,7 @@ describe('tests for "customize" module', () => {
window.url = url;
window.toastr = toastr;
window.current_skin = '';
window.showAjaxError = jest.fn();
document.body.innerHTML = '<button id="color-submit">submit</button>';
const submitColor = require(modulePath);
@ -69,6 +71,7 @@ describe('tests for "players" module', () => {
window.fetch = fetch;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div id="1">
@ -111,6 +114,7 @@ describe('tests for "players" module', () => {
window.url = url;
window.toastr = toastr;
window.$.fn.modal = modal;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div class="modal" style="display: none" id="shouldBeRemoved"></div>
@ -157,6 +161,7 @@ describe('tests for "players" module', () => {
window.toastr = toastr;
window.trans = trans;
window.swal = swal;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -208,6 +213,7 @@ describe('tests for "players" module', () => {
window.trans = trans;
window.swal = swal;
window.debounce = debounce;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -263,6 +269,7 @@ describe('tests for "players" module', () => {
window.toastr = toastr;
window.trans = trans;
window.swal = swal;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -310,6 +317,7 @@ describe('tests for "plugins" module', () => {
window.fetch = fetch;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
$.pluginsTable = {
ajax: {
reload: reloadTable
@ -345,6 +353,7 @@ describe('tests for "plugins" module', () => {
window.fetch = fetch;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
$.pluginsTable = {
ajax: {
reload: reloadTable
@ -380,6 +389,7 @@ describe('tests for "plugins" module', () => {
window.fetch = fetch;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
$.pluginsTable = {
ajax: {
reload: reloadTable
@ -423,6 +433,7 @@ describe('tests for "update" module', () => {
window.fetch = fetch;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
$.fn.modal = modal;
document.body.innerHTML = `
@ -470,6 +481,7 @@ describe('tests for "users" module', () => {
window.toastr = toastr;
window.trans = trans;
window.swal = swal;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -519,6 +531,7 @@ describe('tests for "users" module', () => {
window.toastr = toastr;
window.trans = trans;
window.swal = swal;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -566,6 +579,7 @@ describe('tests for "users" module', () => {
window.toastr = toastr;
window.trans = trans;
window.swal = swal;
window.showAjaxError = jest.fn();
const changeUserPwd = require(modulePath).changeUserPwd;
@ -597,6 +611,7 @@ describe('tests for "users" module', () => {
window.fetch = fetch;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -648,6 +663,7 @@ describe('tests for "users" module', () => {
window.url = url;
window.toastr = toastr;
window.trans = trans;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -720,6 +736,7 @@ describe('tests for "users" module', () => {
window.url = url;
window.toastr = toastr;
window.trans = trans;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<table>
@ -784,6 +801,7 @@ describe('tests for "users" module', () => {
window.toastr = toastr;
window.trans = trans;
window.swal = swal;
window.showAjaxError = jest.fn();
document.body.innerHTML = '<tr id="user-1"></tr>';
const deleteUserAccount = require(modulePath).deleteUserAccount;

View File

@ -22,6 +22,7 @@ describe('tests for "closet" module', () => {
window.trans = trans;
window.url = url;
window.MSP = MSP;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div id="textures-indicator"></div>
@ -71,6 +72,7 @@ describe('tests for "closet" module', () => {
const url = jest.fn(path => path);
window.trans = trans;
window.url = url;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<input name="q" />
@ -126,6 +128,7 @@ describe('tests for "closet" module', () => {
window.url = url;
window.swal = swal;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div id="skin-category">
@ -174,6 +177,7 @@ describe('tests for "closet" module', () => {
window.url = url;
window.swal = swal;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div id="skin-category">
@ -226,6 +230,7 @@ describe('tests for "closet" module', () => {
window.url = url;
window.swal = swal;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div id="skin-category">
@ -275,6 +280,7 @@ describe('tests for "closet" module', () => {
window.url = url;
window.swal = swal;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<img alt="User Image" src="src" />
@ -316,6 +322,7 @@ describe('tests for "player" module', () => {
}));
window.url = url;
window.fetch = fetch;
window.showAjaxError = jest.fn();
window.TexturePreview = require('../common/texture-preview');
window.MSP = {
changeSkin: jest.fn(),
@ -353,6 +360,7 @@ describe('tests for "player" module', () => {
window.fetch = fetch;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<select id="preference" pid="1">
@ -399,6 +407,7 @@ describe('tests for "player" module', () => {
window.trans = trans;
window.toastr = toastr;
window.swal = swal;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<input id="player_name" placeholder="placeholder" />
@ -445,6 +454,7 @@ describe('tests for "player" module', () => {
window.url = url;
window.trans = trans;
window.toastr = toastr;
window.showAjaxError = jest.fn();
$.fn.modal = modal;
document.body.innerHTML = `
@ -489,6 +499,7 @@ describe('tests for "player" module', () => {
window.url = url;
window.toastr = toastr;
window.swal = swal;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<tr id="1"></tr>
@ -531,6 +542,7 @@ describe('tests for "player" module', () => {
window.url = url;
window.toastr = toastr;
window.swal = swal;
window.showAjaxError = jest.fn();
$.fn.modal = modal;
document.body.innerHTML = `
@ -570,6 +582,7 @@ describe('tests for "player" module', () => {
window.swal = swal;
$.fn.modal = modal;
window.selectedTextures = {};
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<input name="player" id="1" />
@ -614,6 +627,7 @@ describe('tests for "profile" module', () => {
window.trans = trans;
window.url = url;
window.debounce = jest.fn(fn => fn);
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div class="nickname"></div>
@ -661,6 +675,7 @@ describe('tests for "profile" module', () => {
window.trans = trans;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
window.logout = jest.fn().mockReturnValue(Promise.resolve({ errno: 0 }));
document.body.innerHTML = `
@ -722,6 +737,7 @@ describe('tests for "profile" module', () => {
window.trans = trans;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
window.logout = jest.fn().mockReturnValue(Promise.resolve({ errno: 0 }));
document.body.innerHTML = `
@ -769,6 +785,7 @@ describe('tests for "profile" module', () => {
window.trans = trans;
window.url = url;
window.toastr = toastr;
window.showAjaxError = jest.fn();
document.body.innerHTML = `
<div class="modal-body">
@ -810,6 +827,7 @@ describe('tests for "sign" module', () => {
window.toastr = toastr;
window.trans = trans;
window.swal = swal;
window.showAjaxError = jest.fn();
window.debounce = fn => fn;
const fetch = jest.fn()
.mockReturnValueOnce(Promise.resolve({