How to use mergeDefaults method in Cypress

Best JavaScript code snippet using cypress

fim-api.ts.js

Source:fim-api.ts.js Github

copy

Full Screen

...109 return;110};111fimApi.prototype.login = function (params, requestSettings) {112 var _this = this;113 params = this.mergeDefaults(params, {114 'grant_type': 'password',115 'username': null,116 'password': null,117 'access_token': null,118 'refresh_token': null,119 'client_id': ''120 });121 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);122 return $.ajax({123 url: this.directory + 'validate.php',124 type: 'POST',125 data: params,126 timeout: requestSettings.timeout,127 cache: requestSettings.cache128 }).done(function (json) {129 if (json.login.access_token) {130 _this.lastSessionHash = json.login.access_token;131 }132 requestSettings.end(json.login);133 }).fail(this.fail(requestSettings));134};135/**136 * Obtains one or more users.137 */138fimApi.prototype.getUsers = function (params, requestSettings) {139 var _this = this;140 params = this.mergeDefaults(params, {141 'info': ['self', 'groups', 'profile'],142 'access_token': this.lastSessionHash,143 'id': null,144 'userIds': null,145 'userNames': null,146 'userNameSearch': null147 });148 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);149 $.ajax({150 type: 'get',151 url: this.directory + 'api/user.php',152 data: params,153 timeout: requestSettings.timeout,154 cache: requestSettings.cache155 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {156 _this.getUsers(params, requestSettings);157 })));158};159fimApi.prototype.createUser = function (params, requestSettings) {160 var _this = this;161 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);162 return $.ajax({163 type: 'post',164 url: this.directory + 'api/user.php',165 data: this.mergeDefaults(params, {166 'name': null,167 'password': null,168 'birthDate': null,169 'email': null170 }),171 timeout: requestSettings.timeout,172 cache: requestSettings.cache173 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {174 _this.getUsers(params, requestSettings);175 })));176};177fimApi.prototype.getRooms = function (params, requestSettings) {178 var _this = this;179 params = this.mergeDefaults(params, {180 'access_token': this.lastSessionHash,181 'id': null,182 'roomIds': null,183 'roomNames': null,184 'roomNameSearch': null,185 'permFilter': null,186 'page': null187 });188 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);189 $.ajax({190 type: 'get',191 url: this.directory + 'api/room.php',192 data: params,193 timeout: requestSettings.timeout,194 cache: requestSettings.cache195 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {196 _this.getRooms(params, requestSettings);197 })));198};199fimApi.prototype.getEventsFallback = function (params, requestSettings) {200 var _this = this;201 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);202 this.timer(requestSettings, "getEventsFallback", (function (requestSettings) {203 $.ajax({204 type: 'get',205 url: _this.directory + 'stream.php',206 data: _this.mergeDefaults(params, {207 'fallback': true,208 'access_token': _this.lastSessionHash,209 'streamType': null,210 'queryId': null,211 'lastEvent': null,212 'lastMessage': null213 }),214 timeout: requestSettings.timeout,215 cache: requestSettings.cache216 }).done(function (response) {217 _this.done(requestSettings)(response);218 }).fail((function (response) {219 if (requestSettings.refresh) {220 _this.getEventsFallback(null, { close: true });221 }222 _this.fail(requestSettings, (function () {223 _this.getEventsFallback(params, requestSettings);224 }))(response);225 }));226 }));227};228/* Messages */229fimApi.prototype.getMessages = function (params, requestSettings) {230 var _this = this;231 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);232 var getMessages_query = function (requestSettings) {233 $.ajax({234 type: 'get',235 url: _this.directory + 'api/message.php',236 data: _this.mergeDefaults(params, {237 'access_token': _this.lastSessionHash,238 'roomId': null,239 'id': null,240 'userIds': null,241 'messageIdEnd': null,242 'messageIdStart': null,243 'page': null,244 'messageTextSearch': null245 }),246 timeout: requestSettings.timeout,247 cache: requestSettings.cache248 }).done(_this.done(requestSettings)).fail(_this.fail(requestSettings, (function () {249 _this.getMessages(params, requestSettings);250 })));251 };252 this.timer(requestSettings, "getMessages", getMessages_query);253};254fimApi.prototype.sendMessage = function (roomId, params, requestSettings) {255 var _this = this;256 params = this.mergeDefaults(params, {257 'access_token': this.lastSessionHash,258 'ignoreBlock': false,259 'message': null,260 'flag': null261 });262 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);263 $.ajax({264 url: this.directory + 'api/message.php?' + $.param({265 'roomId': roomId266 }),267 type: 'POST',268 data: params,269 timeout: requestSettings.timeout,270 cache: requestSettings.cache271 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {272 _this.sendMessage(roomId, params, requestSettings);273 })));274};275fimApi.prototype.editMessage = function (roomId, messageId, params, requestSettings) {276 var _this = this;277 params = this.mergeDefaults(params, {278 'ignoreBlock': false,279 'message': null,280 'flag': null281 });282 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);283 $.ajax({284 url: this.directory + 'api/message.php?' + $.param({285 '_action': 'edit',286 'access_token': this.lastSessionHash,287 'id': messageId,288 'roomId': roomId289 }),290 type: 'POST',291 data: params,292 timeout: requestSettings.timeout,293 cache: requestSettings.cache294 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {295 _this.editMessage(roomId, messageId, params, requestSettings);296 })));297};298fimApi.prototype.deleteMessage = function (roomId, messageId, requestSettings) {299 var _this = this;300 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);301 $.ajax({302 url: this.directory + 'api/message.php?' + $.param({303 '_action': 'delete',304 'access_token': this.lastSessionHash,305 'id': messageId,306 'roomId': roomId307 }),308 type: 'POST',309 timeout: requestSettings.timeout,310 cache: requestSettings.cache311 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {312 _this.deleteMessage(roomId, messageId, requestSettings);313 })));314};315/* Unread Messages */316fimApi.prototype.getUnreadMessages = function (params, requestSettings) {317 var _this = this;318 requestSettings = this.mergeDefaults(requestSettings, this.mergeDefaults({319 'timeout': 30000,320 'refresh': 30000321 }, this.requestDefaults));322 var getUnreadMessages_query = function (requestSettings) {323 $.ajax({324 type: 'get',325 url: _this.directory + 'api/unreadMessages.php',326 data: _this.mergeDefaults(params, {327 'access_token': _this.lastSessionHash328 }),329 timeout: requestSettings.timeout,330 cache: requestSettings.cache331 }).done(_this.done(requestSettings)).fail((function (response) {332 if (requestSettings.refresh) {333 _this.getUnreadMessages(null, { close: true });334 }335 _this.fail(requestSettings, (function () {336 _this.getUnreadMessages(params, requestSettings);337 }))(response);338 }));339 };340 fimApi.timer(requestSettings, "getUnreadMessages", getUnreadMessages_query);341};342fimApi.prototype.getFiles = function (params, requestSettings) {343 var _this = this;344 params = this.mergeDefaults(params, {345 access_token: this.lastSessionHash,346 userIds: [],347 fileIds: [],348 page: 0349 });350 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);351 $.ajax({352 type: 'get',353 url: this.directory + 'api/file.php',354 data: params,355 timeout: requestSettings.timeout,356 cache: requestSettings.cache357 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {358 _this.getFiles(params.requestSettings);359 })));360};361fimApi.prototype.deleteFile = function (fileId, requestSettings) {362 var _this = this;363 var requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);364 $.ajax({365 type: 'post',366 url: this.directory + 'api/file.php?' + $.param({367 'access_token': this.lastSessionHash,368 '_action': 'delete',369 'id': fileId370 }),371 timeout: requestSettings.timeout372 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {373 _this.deleteFile(fileId, requestSettings);374 })));375};376fimApi.prototype.getStats = function (params, requestSettings) {377 var _this = this;378 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);379 $.ajax({380 type: 'get',381 url: this.directory + 'api/stats.php',382 data: this.mergeDefaults(params, {383 'access_token': this.lastSessionHash,384 'roomId': null,385 'number': 10386 }),387 timeout: requestSettings.timeout,388 cache: requestSettings.cache389 }).done(this.done(requestSettings, 'roomStats')).fail(this.fail(requestSettings, (function () {390 _this.getStats(params, requestSettings);391 })));392};393fimApi.prototype.getKicks = function (params, requestSettings) {394 var _this = this;395 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);396 $.ajax({397 type: 'get',398 url: this.directory + 'api/kick.php',399 data: this.mergeDefaults(params, {400 'access_token': this.lastSessionHash,401 'roomId': null,402 'userId': null403 }),404 timeout: requestSettings.timeout,405 cache: requestSettings.cache406 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {407 _this.getKicks(params, requestSettings);408 })));409};410fimApi.prototype.getCensorLists = function (params, requestSettings) {411 var _this = this;412 params = this.mergeDefaults(params, {413 'access_token': this.lastSessionHash,414 'roomId': null,415 'listIds': null,416 'includeWords': 1 // true417 });418 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);419 $.ajax({420 type: 'get',421 url: this.directory + 'api/getCensorLists.php',422 data: params,423 timeout: requestSettings.timeout,424 cache: requestSettings.cache425 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {426 _this.getCensorLists(params, requestSettings);427 })));428};429fimApi.prototype.getActiveUsers = function (params, requestSettings) {430 var _this = this;431 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);432 var getActiveUsers_query = function (requestSettings) {433 $.ajax({434 type: 'get',435 url: _this.directory + 'api/userStatus.php',436 data: _this.mergeDefaults(params, {437 'access_token': _this.lastSessionHash,438 'roomIds': null,439 'userIds': null,440 'onlineThreshold': null441 }),442 timeout: requestSettings.timeout,443 cache: requestSettings.cache444 }).done(_this.done(requestSettings, 'users')).fail((function (response) {445 if (requestSettings.refresh) {446 _this.getActiveUsers(null, { close: true });447 }448 _this.fail(requestSettings, (function () {449 _this.getActiveUsers(params, requestSettings);450 }))(response);451 }));452 };453 fimApi.timer(requestSettings, "getActiveUsers", getActiveUsers_query);454};455fimApi.prototype.getGroups = function (params, requestSettings) {456 var _this = this;457 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);458 $.ajax({459 type: 'get',460 url: this.directory + 'api/group.php',461 data: this.mergeDefaults(params, {462 'access_token': this.lastSessionHash,463 'groupIds': null,464 'groupNames': null,465 'groupNameSearch': null466 }),467 timeout: requestSettings.timeout,468 cache: requestSettings.cache469 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {470 _this.getGroups(params, requestSettings);471 })));472};473fimApi.prototype.acHelper = function (list) {474 var _this = this;475 return function (search, callback) {476 $.ajax({477 type: 'get',478 url: _this.directory + 'api/acHelper.php',479 data: {480 'access_token': _this.lastSessionHash,481 'list': list,482 'search': search.term483 },484 success: function (json) {485 callback($.map(json.entries, function (value, key) {486 return {487 label: value,488 value: key489 };490 }));491 }492 });493 };494};495fimApi.prototype.kickUser = function (userId, roomId, length, requestSettings) {496 var _this = this;497 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);498 $.ajax({499 url: this.directory + 'api/kick.php?' + $.param({500 'access_token': this.lastSessionHash,501 'roomId': roomId,502 'userId': userId503 }),504 type: 'POST',505 data: {506 'length': length507 },508 timeout: requestSettings.timeout,509 cache: requestSettings.cache510 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {511 _this.kickUser(userId, roomId, length, requestSettings);512 })));513};514fimApi.prototype.unkickUser = function (userId, roomId, requestSettings) {515 var _this = this;516 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);517 $.ajax({518 url: this.directory + 'api/kick.php?' + $.param({519 'access_token': this.lastSessionHash,520 '_action': 'delete',521 'roomId': roomId,522 'userId': userId523 }),524 type: 'POST',525 timeout: requestSettings.timeout,526 cache: requestSettings.cache527 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {528 _this.unkickUser(userId, roomId, requestSettings);529 })));530};531fimApi.prototype.markMessageRead = function (roomId, requestSettings) {532 var _this = this;533 var params = {534 'access_token': this.lastSessionHash,535 '_action': 'delete',536 'roomId': roomId537 };538 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);539 $.ajax({540 url: this.directory + 'api/unreadMessages.php',541 data: params,542 timeout: requestSettings.timeout,543 cache: requestSettings.cache544 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {545 _this.markMessageRead(roomId, requestSettings);546 })));547};548fimApi.prototype.editUserOptions = function (action, params, requestSettings) {549 var _this = this;550 params = this.mergeDefaults(params, {551 'defaultFormatting': null,552 'defaultColor': null,553 'defaultHighlight': null,554 'defaultRoomId': null,555 'favRooms': null,556 'ignoreList': null,557 'friendsList': null,558 'profile': null,559 'defaultFontface': null,560 'parentalAge': null,561 'parentalFlags': null,562 'avatar': null,563 'privacyLevel': null564 });565 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);566 $.ajax({567 url: this.directory + 'api/userOptions.php?' + $.param({568 'access_token': this.lastSessionHash,569 '_action': (action ? action : "edit")570 }),571 type: 'POST',572 data: params,573 timeout: requestSettings.timeout,574 cache: requestSettings.cache575 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {576 _this.editUserOptions(action, params, requestSettings);577 })));578};579fimApi.prototype.favRoom = function (roomId) {580 this.editUserOptions('create', {581 'favRooms': [roomId]582 });583};584fimApi.prototype.unfavRoom = function (roomId) {585 this.editUserOptions('delete', {586 'favRooms': [roomId]587 });588};589fimApi.prototype.editRoom = function (id, action, params, requestSettings) {590 var _this = this;591 params = this.mergeDefaults(params, {592 'access_token': this.lastSessionHash,593 'name': null,594 'defaultPermissions': null,595 'userPermissions': null,596 'groupPermissions': null,597 'censorLists': null,598 'parentalAge': null,599 'parentalFlags': null,600 'hidden': null,601 'official': null602 });603 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);604 $.ajax({605 url: this.directory + 'api/room.php?' + $.param(this.mergeDefaults({}, {606 'id': id,607 '_action': action608 })),609 method: 'POST',610 data: params,611 timeout: requestSettings.timeout,612 cache: requestSettings.cache613 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {614 _this.editRoom(id, params, requestSettings);615 })));616};617fimApi.prototype.createRoom = function (params, requestSettings) {618 this.editRoom(null, 'create', params, requestSettings);619};620fimApi.prototype.deleteRoom = function (id, requestSettings) {621 this.editRoom(id, 'delete', {}, requestSettings);622};623fimApi.prototype.undeleteRoom = function (id, requestSettings) {624 this.editRoom(id, 'undelete', {}, requestSettings);625};626fimApi.prototype.editRoomPermission = function (action, param, roomId, paramId, permissionsArray, requestSettings) {627 var _this = this;628 var requestHead = {629 '_action': action,630 'access_token': this.lastSessionHash,631 'roomId': roomId632 };633 requestHead[param + 'Id'] = paramId;634 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);635 $.ajax({636 url: this.directory + 'api/roomPermission.php?' + $.param(requestHead),637 method: 'POST',638 data: {639 'permissions': permissionsArray640 },641 timeout: requestSettings.timeout,642 cache: requestSettings.cache643 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, (function () {644 _this.editRoomPermission(action, param, roomId, paramId, permissionsArray, requestSettings);645 })));646};647fimApi.prototype.editRoomPermissionUser = function (roomId, userId, permissionsArray, requestSettings) {648 this.editRoomPermission('edit', 'user', roomId, userId, permissionsArray, requestSettings);649};650fimApi.prototype.editRoomPermissionGroup = function (roomId, groupId, permissionsArray, requestSettings) {651 this.editRoomPermission('edit', 'group', roomId, groupId, permissionsArray, requestSettings);652};653fimApi.prototype.deleteRoomPermissionUser = function (roomId, userId, permissionsArray, requestSettings) {654 this.editRoomPermission('delete', 'user', roomId, userId, permissionsArray, requestSettings);655};656fimApi.prototype.deleteRoomPermissionGroup = function (roomId, groupId, permissionsArray, requestSettings) {657 this.editRoomPermission('delete', 'group', roomId, groupId, permissionsArray, requestSettings);658};659fimApi.prototype.createRoomPermissionUser = function (roomId, userId, permissionsArray, requestSettings) {660 this.editRoomPermission('create', 'user', roomId, userId, permissionsArray, requestSettings);661};662fimApi.prototype.createRoomPermissionGroup = function (roomId, groupId, permissionsArray, requestSettings) {663 this.editRoomPermission('create', 'group', roomId, groupId, permissionsArray, requestSettings);664};665fimApi.prototype.editUserStatus = function (roomIds, params, requestSettings) {666 var _this = this;667 params = this.mergeDefaults(params, {668 'status': null,669 'typing': null670 });671 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);672 $.ajax({673 url: this.directory + 'api/userStatus.php?' + $.param({674 '_action': 'edit',675 'access_token': this.lastSessionHash,676 'roomIds': roomIds677 }),678 type: 'POST',679 data: params,680 timeout: requestSettings.timeout,681 cache: requestSettings.cache682 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, function () {683 _this.editUserStatus(roomIds, params, requestSettings);684 }));685};686fimApi.prototype.ping = function (roomId, requestSettings) {687 this.editUserStatus([roomId], { "status": "" }, requestSettings);688};689fimApi.prototype.exitRoom = function (roomId, requestSettings) {690 this.editUserStatus([roomId], { "status": "offline" }, requestSettings);691};692fimApi.prototype.startedTyping = function (roomId, requestSettings) {693 if (this.serverSettings.rooms.typingStatus)694 this.editUserStatus([roomId], { "typing": true }, requestSettings);695};696fimApi.prototype.stoppedTyping = function (roomId, requestSettings) {697 if (this.serverSettings.rooms.typingStatus)698 this.editUserStatus([roomId], { "typing": false }, requestSettings);699};700fimApi.prototype.changeAvatar = function (avatarHash, requestSettings) {701 this.editUserOptions({702 'avatarHash': avatarHash703 }, requestSettings);704};705fimApi.prototype.pushSub = function (endpoint, p256dh, auth, requestSettings) {706 var _this = this;707 requestSettings = this.mergeDefaults(requestSettings, this.requestDefaults);708 $.ajax({709 url: this.directory + 'api/webpushSubscribe.php',710 type: 'POST',711 data: {712 'access_token': this.lastSessionHash,713 'endpoint': endpoint,714 'p256dh': p256dh,715 'auth': auth716 },717 timeout: requestSettings.timeout,718 cache: requestSettings.cache719 }).done(this.done(requestSettings)).fail(this.fail(requestSettings, function () {720 _this.pushSub(endpoint, requestSettings);721 }));...

Full Screen

Full Screen

fim-api.js

Source:fim-api.js Github

copy

Full Screen

...18192021 login : function(params, requestSettings) {22 var params = fimApi.mergeDefaults(params, {23 'fim3_format' : 'json',24 'userId' : 0,25 'userName' : '',26 'password' : '',27 'passwordEncrypt' : 'plaintext',28 'apiVersions' : '[10000]',29 'clientCode' : ''30 });3132 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);3334 function login_query() {35 $.ajax({36 url: directory + 'validate.php',37 type: 'POST',38 data: params,39 timeout: requestSettings.timeout,40 cache: requestSettings.cache41 }).done(function(json) {42 requestSettings.callback(json.login);43 }).fail(function(response) {44 requestSettings.error(response.responseJSON.exception);45 });46 }4748 login_query();49 },50515253 /**54 * Obtains one or more users.55 * This function is async.56 *57 * @param object userId - The ID of the user to obtain info of.58 *59 * @author Jospeph T. Parsons <josephtparsons@gmail.com>60 * @copyright Joseph T. Parsons 201461 *62 */63 getUsers : function(params, requestSettings, async) {64 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['userIds']), {65 'fim3_sessionHash' : window.sessionHash,66 'fim3_userId' : window.userId,67 'fim3_format' : 'json',68 'userIds' : '',69 'userNames' : '',70 'userNameSearch' : ''71 });7273 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);7475 function getUsers_query() {76 $.ajax({77 type: 'get',78 url: directory + 'api/getUsers.php',79 data: params,80 timeout: requestSettings.timeout,81 cache: requestSettings.cache82 }).done(function(json) {83 /*$.each(json.getUsers.users, function(index, value) { console.log(value);84 if (!(value.userId in window.userData)) window.userData[value.userId] = value;85 else {86 for (var prop in value) window.userData[value.userId][prop] = value[prop];87 }8889 callback(value);90 });*/9192 requestSettings.begin(json);93 $.each(json.getRooms.rooms, function(index, value) { requestSettings.each(value); });94 requestSettings.end(json);95 });96 }97 },9899100 getRooms : function(params, requestSettings) {101 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['roomIds']), {102 'fim3_sessionHash' : window.sessionHash,103 'fim3_userId' : window.userId,104 'fim3_format' : 'json',105 'roomIds' : '',106 'roomNames' : '',107 'roomNameSearch' : '',108 'permLevel' : ''109 });110111 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);112113114 function getRooms_query() {115 $.ajax({116 type: 'get',117 url: directory + 'api/getRooms.php',118 data: params,119 timeout: requestSettings.timeout,120 cache: requestSettings.cache121 }).done(function(json) {122 requestSettings.begin(json);123 $.each(json.getRooms.rooms, function(index, value) { requestSettings.each(value); });124 requestSettings.end(json);125 });126 }127128129 if (requestSettings.close) clearInterval(fimApi.timers['getRooms_' + requestSettings.timerId]);130131 getRooms_query();132 if (requestSettings.refresh > -1) fimApi.timers['getRooms_' + requestSettings.timerId] = setInterval(getRooms_query, requestSettings.refresh);133 },134135136 /* var errStr = json.getMessages.errStr,137 errDesc = json.getMessages.errDesc,138 sentUserId = 0,139 messageCount = 0;140141 if (errStr) {142 sentUserId = json.getMessages.activeUser.userId;143144 if (errStr === 'noperm') {145 roomId = false; // Clear the internal roomId.146147 if (sentUserId) { popup.selectRoom(); dia.error('You have been restricted access from this room. Please select a new room.'); } // You are still login, but permission has been denied for whatever reason.148 else { popup.login(); dia.error('You are no longer logged in. Please log-in.'); } // If the API no longer recognises the login, prompt a relogin.149 }150 else {151 roomId = false;152 dia.error(errDesc);153 }154 }155 else {156 */157 getMessages : function(params, requestSettings) {158 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['userIds', 'messageIds']), {159 'fim3_sessionHash' : window.sessionHash,160 'fim3_userId' : window.userId,161 'fim3_format' : 'json',162 'roomId' : '',163 'userIds' : '',164 'messageIds' : '',165 'messageIdEnd' : 0,166 'messageIdStart' : 0,167 'search' : 0,168 'archive' : 0,169 'sortOrder' : 'asc'170 });171172 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);173174175 function getMessages_query() {176 $.ajax({177 type: 'get',178 url: directory + 'api/getMessages.php',179 data: params,180 timeout: requestSettings.timeout,181 cache: requestSettings.cache182 }).done(function(json) {183 requestSettings.begin(json);184 $.each(json.getMessages.messages, function(index, value) { requestSettings.each(value); });185 requestSettings.end(json);186 });187 }188189190 if (requestSettings.close) clearInterval(fimApi.timers['getMessages_' + requestSettings.timerId]);191 else {192 getMessages_query();193 if (requestSettings.refresh > -1) fimApi.timers['getMessages_' + requestSettings.timerId] = setInterval(getMessages_query, requestSettings.refresh);194 }195 },196197198199 getFiles : function(params, requestSettings) {200 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['userIds', 'fileIds']), {201 'fim3_sessionHash' : window.sessionHash,202 'fim3_userId' : window.userId,203 'fim3_format' : 'json',204 'userIds' : '',205 'fileIds' : ''206 });207208 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);209210211 function getFiles_query() {212 $.ajax({213 type: 'get',214 url: directory + 'api/getFiles.php',215 data: params,216 timeout: requestSettings.timeout,217 cache: requestSettings.cache218 }).done(function(json) {219 requestSettings.begin(json);220 $.each(json.getFiles.files, function(index, value) { requestSettings.each(value); });221 requestSettings.end(json);222 });223 }224225226 if (requestSettings.close) clearInterval(fimApi.timers['getFiles_' + requestSettings.timerId]);227228 getFiles_query();229 if (requestSettings.refresh > -1) fimApi.timers['getFiles_' + requestSettings.timerId] = setInterval(getFiles_query, requestSettings.refresh);230 },231232233234 getStats : function(params, requestSettings) {235 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['roomIds']), {236 'fim3_sessionHash' : window.sessionHash,237 'fim3_userId' : window.userId,238 'fim3_format' : 'json',239 'roomIds' : '',240 'number' : 10241 });242243 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);244245246 function getStats_query() {247 $.ajax({248 type: 'get',249 url: directory + 'api/getStats.php',250 data: params,251 timeout: requestSettings.timeout,252 cache: requestSettings.cache253 }).done(function(json) {254 requestSettings.begin(json);255 $.each(json.getStats.roomStats, function(index, value) { requestSettings.each(value); });256 requestSettings.end(json);257 });258 }259260261 if (requestSettings.close) clearInterval(fimApi.timers['getStats_' + requestSettings.timerId]);262263 getStats_query();264 if (requestSettings.refresh > -1) fimApi.timers['getStats_' + requestSettings.timerId] = setInterval(getStats_query, requestSettings.refresh);265 },266267268269 getKicks : function(params, requestSettings) {270 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['roomIds', 'userIds']), {271 'fim3_sessionHash' : window.sessionHash,272 'fim3_userId' : window.userId,273 'fim3_format' : 'json',274 'roomIds' : '',275 'userIds' : ''276 });277278 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);279280281 function getKicks_query() {282 $.ajax({283 type: 'get',284 url: directory + 'api/getKicks.php',285 data: params,286 timeout: requestSettings.timeout,287 cache: requestSettings.cache288 }).done(function(json) {289 requestSettings.begin(json);290 $.each(json.getKicks.kicks, function(index, value) { requestSettings.each(value); });291 requestSettings.end(json);292 });293 }294295296 if (requestSettings.close) clearInterval(fimApi.timers['getKicks_' + requestSettings.timerId]);297298 getKicks_query();299 if (requestSettings.refresh > -1) fimApi.timers['getKicks_' + requestSettings.timerId] = setInterval(getKicks_query, requestSettings.refresh);300 },301302303304 getCensorLists : function(params, requestSettings) {305 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['roomIds', 'listIds']), {306 'fim3_sessionHash' : window.sessionHash,307 'fim3_userId' : window.userId,308 'fim3_format' : 'json',309 'roomIds' : '',310 'listIds' : '',311 'includeWords' : 1 // true312 });313314 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);315316317 function getCensorLists_query() {318 $.ajax({319 type: 'get',320 url: directory + 'api/getCensorLists.php',321 data: params,322 timeout: requestSettings.timeout,323 cache: requestSettings.cache324 }).done(function(json) {325 requestSettings.begin(json);326 $.each(json.getCensorLists.lists, function(index, value) { requestSettings.each(value); });327 requestSettings.end(json);328 });329 }330331332 if (requestSettings.close) clearInterval(fimApi.timers['getCensorLists_' + requestSettings.timerId]);333334 getCensorLists_query();335 if (requestSettings.refresh > -1) fimApi.timers['getCensorLists_' + requestSettings.timerId] = setInterval(getCensorLists_query, requestSettings.refresh);336 },337338339340 getActiveUsers : function(params, requestSettings) {341 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['roomIds', 'userIds']), {342 'fim3_sessionHash' : window.sessionHash,343 'fim3_userId' : window.userId,344 'fim3_format' : 'json',345 'roomIds' : '',346 'userIds' : '',347 'onlineThreshold' : null348 });349350 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);351352 function getActiveUsers_query() {353 $.ajax({354 type: 'get',355 url: directory + 'api/getActiveUsers.php',356 data: params,357 timeout: requestSettings.timeout,358 cache: requestSettings.cache359 }).done(function(json) {360 requestSettings.begin(json);361 $.each(json.getActiveUsers.users, function(index, value) { requestSettings.each(value); });362 requestSettings.end(json);363 });364 }365366367 if (requestSettings.close) clearInterval(fimApi.timers['getActiveUsers_' + requestSettings.timerId]);368 else {369 getActiveUsers_query();370 if (requestSettings.refresh > -1) fimApi.timers['getActiveUsers_' + requestSettings.timerId] = setInterval(getActiveUsers_query, requestSettings.refresh);371 }372 },373374375 acHelper : function(list) {376 return function acHelper_query(search, callback) {377 $.ajax({378 type: 'get',379 url: directory + 'api/acHelper.php',380 data: {381 'fim3_sessionHash' : window.sessionHash,382 'fim3_userId' : window.userId,383 'fim3_format' : 'json',384 'list' : list,385 'search' : search.term386 },387 success : function(json) {388 callback(json.acHelper.entries);389 console.log(json);390 }391 });392 }393 },394395396397 editFile : function(params, requestSettings) {398 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['parentalFlags']), {399 'fim3_sessionHash' : window.sessionHash,400 'fim3_userId' : window.userId,401 'fim3_format' : 'json',402 'action' : 'create',403 'daataEncode' : 'base64',404 'uploadMethod' : 'raw',405 'autoInsert' : true,406 'roomId' : null,407 'fileName' : '',408 'fileData' : '',409 'parentalFlags' : '[]',410 'parentalAge' : 0,411 'md5hash' : null412 });413414 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);415416 $.ajax({417 url : directory + 'api/editFile.php',418 type : 'POST',419 data : params,420 cache : false,421 timeout : requestSettings.timeout,422 success : function(json) {423 requestSettings.callback(json);424 },425 error : function(json) {426 requestSettings.error(json);427 }428 });429 },430431432 sendMessage : function(params, requestSettings) {433 var params = fimApi.mergeDefaults(fimApi.jsonify(params, ['parentalFlags']), {434 'fim3_sessionHash' : window.sessionHash,435 'fim3_userId' : window.userId,436 'fim3_format' : 'json',437 'roomId' : null,438 'confirmed' : false, // TODO439 'message' : null,440 'flag' : null441 });442443 var requestSettings = fimApi.mergeDefaults(requestSettings, fimApi.requestDefaults);444445 $.ajax({446 url: directory + 'api/sendMessage.php',447 type: 'POST',448 data: params,449 cache: false,450 timeout : requestSettings.timeout,451 success : function(json) {452 requestSettings.callback(json);453 },454 error : function(json) {455 requestSettings.error(json);456 }457 }); ...

Full Screen

Full Screen

routesSpec.js

Source:routesSpec.js Github

copy

Full Screen

...16module.exports = () => {17 before(async() => await server.liftOff(get));18 describe('get', () => {19 it('replies 200 and presetConfig provided uuid that exists in the db', (done) => {20 const request = mergeDefaults({21 method: 'GET',22 url: `/config/${seedId}`23 });24 server.inject(request).then(function(r) {25 const statusCode = r.statusCode;26 const presetConfig = r.result;27 const validation = Joi.validate(presetConfig, presetConfigSchema);28 expect(statusCode).to.equal(200);29 expect(validation.error).to.be.null;30 done();31 }).catch(function(err) {32 throw err;33 });34 });35 it('replies 400 if uuid is invalid', (done) => {36 const request = mergeDefaults({37 method: 'GET',38 url: `/config/${uuidv1()}`39 });40 server.inject(request).then(function(r) {41 const { statusCode, message, error } = r.result;42 expect(statusCode).to.equal(400);43 expect(message).to.eql('id path parameter is invalid');44 expect(error).to.eql('Bad Request');45 done();46 }).catch(function(err) {47 throw err;48 });49 });50 it('replies 404 if the the uuid is not in the db', (done) => {51 const request = mergeDefaults({52 method: 'GET',53 url: `/config/${uuidv4()}`54 });55 server.inject(request).then(function(r) {56 expect(r.statusCode).to.equal(404);57 done();58 }).catch(function(err) {59 throw err;60 });61 });62 });63 before(async() => await server.liftOff(put));64 describe('put', () => {65 it('replies 200 when the uuid exists in db and presetConfig is valid', (done) => {66 let test = Object.assign({}, validPresetConfig); test.name = 'bew';67 const request = mergeDefaults({68 method: 'PUT',69 payload: test,70 url: `/config/${seedId}`71 }, true);72 server.inject(request).then(function(r) {73 expect(r.statusCode).to.equal(200);74 done();75 }).catch(function(err) {76 throw err;77 });78 });79 it('replies 400 if the presetConfig is invalid', (done) => {80 const request = mergeDefaults({81 method: 'PUT',82 payload: invalidPresetConfig,83 url: `/config/${seedId}`84 }, true);85 server.inject(request).then(function(r) {86 const { statusCode, message, error } = r.result;87 expect(statusCode).to.be.equal(400);88 expect(message).to.eql('child "name" fails because ["name" is required]');89 expect(error).to.eql('Bad Request');90 done();91 }).catch(function(err) {92 throw err;93 });94 });95 it('replies 400 if the uuid is invalid', (done) => {96 const request = mergeDefaults({97 method: 'PUT',98 payload: invalidPresetConfig,99 url: `/config/${uuidv1()}`100 }, true);101 server.inject(request).then(function(r) {102 const { statusCode, message, error } = r.result;103 expect(statusCode).to.equal(400);104 expect(message).to.eql('id path parameter is invalid');105 expect(error).to.eql('Bad Request');106 done();107 }).catch(function(err) {108 throw err;109 });110 });111 it('replies 404 if the uuid is not in the db', (done) => {112 const request = mergeDefaults({113 method: 'PUT',114 payload: validPresetConfig,115 url: `/config/${uuidv4()}`116 }, true);117 server.inject(request).then(function(r) {118 let { statusCode, error, message } = r.result;119 expect(statusCode).to.eql(404);120 expect(error).to.eql('Not Found');121 expect(message).to.eql('Cannot find config for provided id and user');122 done();123 }).catch(function(err) {124 throw err;125 });126 });127 });128 before(async() => await server.liftOff(post));129 describe('post', () => {130 it('replies 200 if provided presetConfig is valid', (done) => {131 const request = mergeDefaults({132 method: 'POST',133 payload: validPresetConfig,134 url: '/config'135 }, true);136 server.inject(request).then(function(r) {137 const isAuthenticated = r.request.auth.isAuthenticated;138 const statusCode = r.statusCode;139 const { upload, id } = r.result;140 const { error, value } = Joi.validate(id, uuidSchema);141 /**142 * show that...143 * - we get a 200144 * - have authenticated w/the signed JWT145 * - the payload gives success response and the preset's id in the db...146 */147 expect(statusCode).to.equal(200);148 expect(isAuthenticated).to.be.true;149 expect(upload).to.eql('successful');150 expect(error).to.be.null;151 expect(value).to.eql(id);152 done();153 }).catch(function(err) {154 throw err;155 });156 });157 it('replies 400 if provided presetConfig is invalid', (done) => {158 const request = mergeDefaults({159 method: 'POST',160 payload: invalidPresetConfig,161 url: '/config'162 }, true);163 server.inject(request).then(function(r) {164 const { statusCode, message, error } = r.result;165 expect(statusCode).to.equal(400);166 expect(message).to.eql('child "name" fails because ["name" is required]');167 expect(error).to.eql('Bad Request');168 done();169 }).catch(function(err) {170 throw err;171 });172 });...

Full Screen

Full Screen

componentPropDefaults.js

Source:componentPropDefaults.js Github

copy

Full Screen

...17 let pathMixinDefaults = extractDefaults(PathMixin)18 let rectangularMixinDefaults = extractDefaults(Rectangular)19 // vgg-area20 let areaMarkDefaults = extractDefaults(Area)21 defaults['vgg-area'] = mergeDefaults(pathMixinDefaults, areaMarkDefaults)22 // vgg-label23 defaults['vgg-label'] = extractDefaults(Label)24 // vgg-line25 defaults['vgg-line'] = extractDefaults(Line)26 // vgg-multi-line27 let multiLineDefaults = extractDefaults(MultiLine)28 defaults['vgg-multi-line'] = mergeDefaults(pathMixinDefaults, multiLineDefaults)29 // vgg-path30 let pathDefaults = extractDefaults(Path)31 defaults['vgg-path'] = mergeDefaults(pathMixinDefaults, pathDefaults)32 // vgg-point33 defaults['vgg-point'] = extractDefaults(Point)34 // vgg-polygon35 let polygonDefaults = extractDefaults(Polygon)36 defaults['vgg-polygon'] = mergeDefaults(pathMixinDefaults, polygonDefaults)37 // vgg-rectangle38 let rectangleDefaults = extractDefaults(Rectangle)39 defaults['vgg-rectangle'] = mergeDefaults(rectangularMixinDefaults, rectangleDefaults)40 // vgg-symbol41 defaults['vgg-symbol'] = extractDefaults(Symbol)42 // vgg-trail43 let trailDefaults = extractDefaults(Trail)44 defaults['vgg-trail'] = mergeDefaults(pathMixinDefaults, trailDefaults)45 // vgg-multi-point46 defaults['vgg-multi-point'] = extractDefaults(MultiPoint)47 // vgg-section48 let sectionDefaults = extractDefaults(Section)49 defaults['vgg-section'] = mergeDefaults(rectangularMixinDefaults, sectionDefaults)50}51function extractDefaults (component) {52 let defaults = {}53 let props = component.props54 for (let propName in props) {55 let prop = props[propName]56 if (prop.hasOwnProperty('default') && prop.default !== undefined) {57 defaults[propName] = prop.default58 }59 }60 return defaults61}62function mergeDefaults (mixin, component) {63 return Object.assign(JSON.parse(JSON.stringify(mixin)), component)...

Full Screen

Full Screen

config.test.js

Source:config.test.js Github

copy

Full Screen

...16 expect(validity.valid).toBe(false)17 expect(validity.errors[0]).toEqual({ key: 'str', message: 'never valid', value: undefined })18 })19 })20 describe('mergeDefaults()', () => {21 it('needs opts/schema', () => {22 expect(() => config.mergeDefaults()).toThrow()23 expect(() => config.mergeDefaults({})).toThrow()24 })25 it('merges correctly', () => {26 const str = 'bugs bugs bugs'27 const a = config.mergeDefaults({}, { str: { defaultValue: () => str } })28 expect(a.str).toBe(str)29 const b = config.mergeDefaults({ str }, { str: { defaultValue: () => 'not bugs' } })30 expect(b.str).toBe(str)31 const c = config.mergeDefaults({ str: '', bool: false }, {32 str: { defaultValue: () => str },33 bool: { defaultValue: () => true }34 })35 expect(c).toEqual({ str: '', bool: false })36 const d = config.mergeDefaults({ str: undefined, bool: undefined }, {37 str: { defaultValue: () => str },38 bool: { defaultValue: () => true }39 })40 expect(d).toEqual({ str: str, bool: true })41 })42 })43 describe('schema', () => {44 it('has the required properties { validate(), defaultValue(), message }', () => {45 Object.keys(config.schema).forEach(k => {46 config.schema[k].defaultValue()47 config.schema[k].validate()48 config.schema[k].validate(-1)49 config.schema[k].validate('stringy stringerson')50 config.schema[k].validate([ 'foo', 'bar', 'baz' ])...

Full Screen

Full Screen

defaults.js

Source:defaults.js Github

copy

Full Screen

1'use strict';2const test = require('ava');3const mergeDefaults = require('../lib/upload').mergeDefaults;4test('mergeDefaults({}) => skip=true', (t) => {5 const options = mergeDefaults({});6 t.is(options.skip, true);7});8test('mergeDefaults({ skip: true }) => skip=true', (t) => {9 const options = mergeDefaults({ skip: true });10 t.is(options.skip, true);11});12test('mergeDefaults({ skip: false }) => skip=false', (t) => {13 const options = mergeDefaults({ skip: false });14 t.is(options.skip, false);15});16test('mergeDefaults({prune: true}) => prune=true', (t) => {17 const options = mergeDefaults({ prune: true });18 t.is(options.prune, true);19});20test('mergeDefaults({prune: false}) => prune=false', (t) => {21 const options = mergeDefaults({ prune: false });22 t.is(options.prune, false);23});24test('mergeDefaults({bucketPathPrefix: ""}) => bucketPathPrefix=""', (t) => {25 const options = mergeDefaults({ bucketPathPrefix: '' });26 t.is(options.bucketPathPrefix, '');27});28test('mergeDefaults({bucketPathPrefix: "dev/"}) => bucketPathPrefix="dev/"', (t) => {29 const options = mergeDefaults({ bucketPathPrefix: 'dev/' });30 t.is(options.bucketPathPrefix, 'dev/');...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

...12};13var isEmpty = function isEmpty(obj) {14 return (obj === null || obj === undefined || obj === "");15};16var mergeDefaults = function mergeDefaults(config, defaults, _result) {17 _result = _result || {};18 19 for (var prop in config) {20 if (!isEmpty(config[prop])) {21 if (naiveIsObject(config[prop])) {22 _result[prop] = {};23 mergeDefaults(config[prop], defaults[prop], _result[prop]);24 continue;25 }26 27 _result[prop] = config[prop];28 continue;29 }30 31 if (!isEmpty(defaults[prop])) {32 _result[prop] = defaults[prop];33 }34 }35 36 return _result;37};38var merged = mergeDefaults(CONFIG, defaults);...

Full Screen

Full Screen

mergeDefaults.js

Source:mergeDefaults.js Github

copy

Full Screen

...7 * @param {*} objectValue The destination object property value.8 * @param {*} sourceValue The source object property value.9 * @returns {*} Returns the value to assign to the destination object.10 */11 function mergeDefaults(objectValue, sourceValue) {12 return objectValue === undefined ? sourceValue : (0, _lodashObjectMerge['default'])(objectValue, sourceValue, mergeDefaults);13 }14 exports['default'] = mergeDefaults;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('mergeDefaults', (options) => {2 const defaults = {3 body: {4 }5 };6 return Cypress._.merge(defaults, options);7});8describe('test', () => {9 it('test', () => {10 const options = {11 body: {12 }13 };14 cy.mergeDefaults(options);15 });16});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 it('test', () => {3 cy.get('input').type('test')4 cy.get('button').click()5 })6})7const mergeDefaults = require('lodash/mergeWith')8Cypress._.mergeDefaults = (obj, defaults) => {9 return mergeDefaults(obj, defaults, (objValue, srcValue) => {10 })11}12Cypress.Commands.add('mergeDefaults', (obj, defaults) => {13 return Cypress._.mergeDefaults(obj, defaults)14})15describe('test', () => {16 it('test', () => {17 cy.get('input').type('test')18 cy.get('button').click()19 })20})21const mergeDefaults = require('lodash/mergeWith')22Cypress._.mergeDefaults = (obj, defaults) => {23 return mergeDefaults(obj, defaults, (objValue, srcValue) => {24 })25}26Cypress.Commands.add('mergeDefaults', (obj, defaults) => {27 return Cypress._.mergeDefaults(obj, defaults)28})29describe('test', () => {30 it('test', () => {31 cy.get('input').type('test')32 cy.get('button').click()33 })34})35const mergeDefaults = require('lodash/mergeWith')36Cypress._.mergeDefaults = (obj, defaults) => {37 return mergeDefaults(obj, defaults, (objValue, srcValue) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { mergeDefaults } from 'cypress/types/lodash';2import { merge } from 'cypress/types/lodash';3var defaultOptions = {4 nested: {5 }6};7var options = {8 nested: {9 }10};11var merged = merge(defaultOptions, options);12console.log(merged);13import { mergeDefaults } from 'cypress/types/lodash';14import { merge } from 'cypress/types/lodash';15var defaultOptions = {16 nested: {17 }18};19var options = {20 nested: {21 }22};23var merged = merge(defaultOptions, options);24console.log(merged);25import { mergeDefaults } from 'cypress/types/lodash';26import { merge } from 'cypress/types/lodash';27var defaultOptions = {28 nested: {29 }30};31var options = {32 nested: {33 }34};35var merged = merge(defaultOptions, options);36console.log(merged);37import { mergeDefaults } from 'cypress/types/lodash';38import { merge } from 'cypress/types/lodash';39var defaultOptions = {40 nested: {41 }42};43var options = {44 nested: {45 }46};47var merged = merge(defaultOptions, options);48console.log(merged);

Full Screen

Using AI Code Generation

copy

Full Screen

1const mergeDefaults = require('cypress-merge-defaults');2const defaults = {3 env: {4 }5};6module.exports = (on, config) => {7 mergeDefaults(config, defaults);8};9{10 "env": {11 }12}13const mergeDefaults = require('cypress-merge-defaults');14const defaults = {15 env: {16 }17};18module.exports = (on, config) => {19 mergeDefaults(config, defaults);20};21const mergeDefaults = require('cypress-merge-defaults');22const defaults = {23 env: {24 }25};26module.exports = (on, config) => {27 mergeDefaults(config, defaults);28 mergeDefaults.mergeFiles('cypress.json', 'cypress/integration/cypress.json');29};30{31 "env": {32 }33}34{

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress._.mergeDefaults = (defaults, options) => {2 const merged = {};3 for (const key in defaults) {4 if (defaults.hasOwnProperty(key)) {5 let value = defaults[key];6 if (options.hasOwnProperty(key)) {7 value = options[key];8 }9 merged[key] = value;10 }11 }12 return merged;13};14Cypress.config = (options) => {15 const defaults = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const mergeDefaults = require('merge-defaults');2module.exports = (on, config) => {3 on('task', {4 });5};6describe('Test', () => {7 it('test', () => {8 cy.task('mergeDefaults', {9 defaultOptions: {10 },11 userOptions: {12 }13 }).then((options) => {14 console.log(options);15 });16 });17});18const mergeDefaults = require('merge-defaults');19module.exports = (on, config) => {20 on('task', {21 });22};23describe('Test', () => {24 it('test', () => {25 cy.task('mergeDefaults', {26 defaultOptions: {27 },28 userOptions: {29 }30 }).then((options) => {31 console.log(options);32 });33 });34});35{ option1: 'option1', option2: 'option2', option3: 'option3' }

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful