Best JavaScript code snippet using stryker-parent
PostData.js
Source:PostData.js
1/**2 * @module PostData3 * @description4 * Posts data through server services5 */6(function () {7 var Deferred = appMeta.Deferred;8 var getDataUtils = appMeta.getDataUtils;9 var logger = appMeta.logger;10 var logType = appMeta.logTypeEnum;11 var methodEnum = appMeta.routing.methodEnum;12 /**13 * @constructor PostData14 * @description15 */16 function PostData() {17 "use strict";18 }19 PostData.prototype = {20 constructor: PostData,21 /**22 * @method saveDataSet23 * @public24 * @description ASYNC25 * Sends the dataset with the modifies on the server. The server saves it if possible. Returns the ds and the array of message errors26 * @method saveDataSet27 * @private28 * @param {DataSet} ds29 * @param {string} tableName30 * @param {string} editType31 * @param {Array} messages32 * @returns {Deferred(boolean|DataSet)}33 */34 saveDataSet:function (ds, tableName, editType, messages) {35 var def = Deferred("saveDataSet");36 var objConn = {37 method: methodEnum.saveDataSet,38 prm: {39 ds: getDataUtils.getJsonFromJsDataSet(ds, true),40 tableName: tableName,41 editType: editType,42 messages: getDataUtils.getJsonFromMessages(messages)43 }44 };45 appMeta.connection.call(objConn)46 .then(function (jsonRes) {47 try{48 // recupero oggetto json49 var obj = getDataUtils.getJsObjectFromJson(jsonRes);50 // dal json obj recupero i vari pezzi. 1. dataset 2. success 3. canIgnore 4. messages51 // messages a sua volta sarà un array di oggetti che metterò in obj js di tipo DbProcedureMessage52 var dsOut = getDataUtils.getJsDataSetFromJson(obj.dataset);53 var success = obj.success;54 var canIgnore = obj.canIgnore;55 var messages = [];56 // a prescindere se il salvataggio è avvenuto, mergio il ds di output del metodo save con quello di input57 var changesCommittedToDB = (obj.messages.length === 0); // se non ci sono msg e quindi è andato bene sono effettivamente da calcellare58 getDataUtils.mergeDataSetChanges(ds, dsOut, changesCommittedToDB );59 // popolo array di messaggi, creando un opportuno oggetto DbProcedureMessage.60 _.forEach(obj.messages,61 function (message) {62 var id = message.id;63 var description = message.description;64 var audit = message.audit;65 var severity = message.severity;66 var table = message.table;67 var canIgnore = message.canIgnore;68 var m = new appMeta.DbProcedureMessage(id, description, audit, severity, table, canIgnore);69 messages.push(m)70 });71 return def.resolve(ds, messages, success, canIgnore);72 } catch (e){73 console.log(e);74 return def.resolve(false);75 }76 }, function(err) {77 return def.reject(false);78 }79 )80 return def.promise();81 },82 /**83 * @method doPost84 * @public85 * @description ASYNC86 * RECURSIVE87 * Sends the dataset with the modifies on the server. The server saves it if possible. returns the ds and the array of message errors88 * Manages the call to save data on db; if there are warning or error messages it shows a form,89 * In the form user can push "ignore and save" if there are only warnings, or "no save" button always visible90 * @param {DataSet} ds91 * @param {string} tableName92 * @param {string} editType93 * @param {Array} inputMessages94 * @param {MetaPage} metaPage95 * @returns {Deferred(boolean|DataSet)}96 */97 doPost:function (ds, tableName, editType, inputMessages, metaPage) {98 var def = Deferred("doPost");99 inputMessages = inputMessages || [];100 var self = this;101 // invocazione metodo backend102 var res = this.saveDataSet(ds, tableName, editType, inputMessages)103 .then(function (dsOut, newMessages, success, canIgnore) {104 // se ritorna con successo esco con true105 if(success) return def.resolve(true);106 // se ci sono messaggi mostro form con lista degli errori.107 // l'utente potrà uscire e non salvare , oppure provare ad ignorare e salvare108 if (newMessages.length > 0) {109 // mostra solo errori ricevuti in questo step di salvataggio110 return self.showErrorList(newMessages, canIgnore, metaPage)111 .then(function (res) {112 // se esce con true, significa che l'utente ha potuto "ignorare e provare a ri-salvare"113 if (res){114 // messaggi non ignorati, quindi aggiungo alla lista dei messaggi115 inputMessages = _.union(inputMessages, newMessages);116 // vado in ricorsione117 return def.from(self.doPost(ds, tableName, editType, inputMessages, metaPage)).promise();118 }else{119 // uscito con false, l'utente ha deciso di non salvare120 return def.resolve(false);121 }122 });123 } else {124 // N.B se "success" è false devono esserci dei messaggi, altrimenti c'è anomalia da qualche parte! Mostro messaggio di errore all'utente125 logger.log(logType.ERROR, "save unsucceded, but no procedure db error message found");126 return def.resolve(false);127 }128 });129 return def.from(res).promise();130 },131 /**132 * @method doPostSilent133 * @public134 * @description ASYNC135 * Sends the dataset with the modifies on the server. The server saves it if possible. returns the ds and the array of message errors136 * If all messages are ignorable, save it otherwise, do nothing!137 * @param {DataSet} ds138 * @param {string} tableName139 * @param {string} editType140 * @param {Array} inputMessages141 * @returns {Deferred(boolean, dsOut)}142 */143 doPostSilent:function (ds, tableName, editType, inputMessages) {144 var def = Deferred("doPostSilent");145 inputMessages = inputMessages || [];146 var self = this;147 // invocazione metodo backend148 var res = this.saveDataSet(ds, tableName, editType, inputMessages)149 .then(function (dsOut, newMessages, success, canIgnore) {150 // se ritorna con successo esco con true151 if(success) return def.resolve(true);152 // se ci sono messaggi nella silent non mostro form, ma provo a salvare se sono tutti ignorabili153 if (newMessages.length > 0) {154 // e posso ignorare, automaticamente riprovo la post, cioè la saveDataSet155 if (canIgnore){156 // messaggi non ignorati, quindi aggiungo alla lista dei messaggi157 inputMessages = _.union(inputMessages, newMessages);158 // vado in ricorsione159 return def.from(self.doPostSilent(ds, tableName, editType, inputMessages)).promise();160 }161 var warnmsg = "TableName: " + tableName + " - EditType: " + editType + ". Save not succeded";162 console.warn([warnmsg, JSON.stringify(newMessages) ]);163 // se nin sono ignorabili esco164 return def.resolve(false, newMessages);165 } else {166 // N.B se success è false devono esserci dei messaggi, altrimenti c'è anomalia da qualche parte! Mostro messaggio di errore167 logger.log(logType.WARNING, "Save not succeded, but no procedure db error message found");168 return def.resolve(false);169 }170 });171 return def.from(res).promise();172 },173 /**174 * @method showErrorList175 * @private176 * @description ASYNC177 * Show a modal form with a grid with the info on the messages.178 * @param {DbProcedureMessage[]} messages179 * @param {boolean} canIgnore180 * @param {MetaPage} metaPage181 * @returns {Deferred}182 */183 showErrorList:function (messages, canIgnore, metaPage) {184 var def = Deferred("showErrorList");185 var formProcedureMessage = new appMeta.FormProcedureMessage(metaPage.rootElement, messages, canIgnore, metaPage);186 return def.from(formProcedureMessage.fillControl()).promise();187 },188 };189 appMeta.postData = new PostData();...
class_name_bindings_test.js
Source:class_name_bindings_test.js
1// ==========================================================================2// Project: SproutCore - JavaScript Application Framework3// Copyright: ©2006-2011 Apple Inc. and contributors.4// License: Licensed under MIT license (see license.js)5// ==========================================================================6/*global module test equals context ok same */7module("SC.CoreView - Class Name Bindings");8test("should apply bound class names to the element", function() {9 var view = SC.View.create({10 classNameBindings: ['priority', 'isUrgent', 'isClassified:classified', 'canIgnore'],11 priority: 'high',12 isUrgent: true,13 isClassified: true,14 canIgnore: false15 });16 view.createLayer();17 ok(view.$().hasClass('high'), "adds string values as class name");18 ok(view.$().hasClass('is-urgent'), "adds true Boolean values by dasherizing");19 ok(view.$().hasClass('classified'), "supports customizing class name for Boolean values");20 ok(!view.$().hasClass('can-ignore'), "does not add false Boolean values as class");21});22test("should add, remove, or change class names if changed after element is created", function() {23 var view = SC.View.create({24 classNameBindings: ['priority', 'isUrgent', 'isClassified:classified', 'canIgnore'],25 priority: 'high',26 isUrgent: true,27 isClassified: true,28 canIgnore: false29 });30 view.createLayer();31 view.set('priority', 'orange');32 view.set('isUrgent', false);33 view.set('isClassified', false);34 view.set('canIgnore', true);35 ok(view.$().hasClass('orange'), "updates string values");36 ok(!view.$().hasClass('high'), "removes old string value");37 ok(!view.$().hasClass('is-urgent'), "removes dasherized class when changed from true to false");38 ok(!view.$().hasClass('classified'), "removes customized class name when changed from true to false");39 ok(view.$().hasClass('can-ignore'), "adds dasherized class when changed from false to true");40});41test("should preserve class names applied via classNameBindings when view layer is updated",42function(){43 var view = SC.View.create({44 classNameBindings: ['isUrgent', 'isClassified:classified'],45 isClassified: true,46 isUrgent: false47 });48 view.createLayer();49 ok(!view.$().hasClass('can-ignore'), "does not add false Boolean values as class");50 ok(view.$().hasClass('classified'), "supports customizing class name for Boolean values");51 view.set('isClassified', false);52 view.set('isUrgent', true);53 ok(view.$().hasClass('is-urgent'), "adds dasherized class when changed from false to true");54 ok(!view.$().hasClass('classified'), "removes customized class name when changed from true to false");55 view.set('layerNeedsUpdate', YES);56 view.updateLayer();57 ok(view.$().hasClass('is-urgent'), "still has class when view display property is updated");58 ok(!view.$().hasClass('classified'), "still does not have customized class when view display property is updated");...
DbProcedureMessage.js
Source:DbProcedureMessage.js
1/**2 * @module DbProcedureMessage3 * @description4 * Contains a model for a database message object.5 */6(function () {7 /**8 * @constructor DbProcedureMessage9 * @description10 * Accepts all the parameters to build a model for a database message object.11 * @param {String} id12 * @param {String} description13 * @param {String} audit14 * @param {String} severity15 * @param {String} table16 * @param {Boolean} canIgnore17 */18 function DbProcedureMessage(id, description, audit, severity, table, canIgnore) {19 if (this.constructor !== DbProcedureMessage) {20 return new DbProcedureMessage(id, description, audit, severity, table, canIgnore);21 }22 this.id = id; // pre_post + "/" + pm.TableName + "/" + pm.Operation.Substring(0, 1) + "/" + pm.EnforcementNumber.ToString() || dberror23 this.description = description;24 this.audit = audit;25 this.severity = severity; // "Errore" || "Avvertimento" || "Disabilitata"26 this.table = table;27 this.canIgnore = canIgnore; // true/false28 return this;29 }30 DbProcedureMessage.prototype = {31 constructor: DbProcedureMessage32 };33 appMeta.DbProcedureMessage = DbProcedureMessage;...
Using AI Code Generation
1var canIgnore = require('stryker-parent').canIgnore;2var ignore = require('stryker-parent').ignore;3var ignore = require('stryker-parent').ignore;4var canIgnore = require('stryker-parent').canIgnore;5var ignore = require('stryker-parent').ignore;6var canIgnore = require('stryker-parent').canIgnore;7var ignore = require('stryker-parent').ignore;8var canIgnore = require('stryker-parent').canIgnore;9var ignore = require('stryker-parent').ignore;10var canIgnore = require('stryker-parent').canIgnore;11var ignore = require('stryker-parent').ignore;12var canIgnore = require('stryker-parent').canIgnore;13var ignore = require('stryker-parent').ignore;14var canIgnore = require('stryker-parent').canIgnore;15var ignore = require('stryker-parent').ignore;16var canIgnore = require('stryker-parent').canIgnore;17var ignore = require('stryker-parent').ignore;18var canIgnore = require('stryker-parent').canIgnore;19var ignore = require('stryker-parent').ignore;
Using AI Code Generation
1const canIgnore = require('stryker-parent').canIgnore;2const canIgnore = require('stryker-parent').canIgnore;3const canIgnore = require('stryker-parent').canIgnore;4const canIgnore = require('stryker-parent').canIgnore;5const canIgnore = require('stryker-parent').canIgnore;6const canIgnore = require('stryker-parent').canIgnore;7const canIgnore = require('stryker-parent').canIgnore;8const canIgnore = require('stryker-parent').canIgnore;9const canIgnore = require('stryker-parent').canIgnore;10const canIgnore = require('stryker-parent').canIgnore;11const canIgnore = require('stryker-parent').canIgnore;12const canIgnore = require('stryker-parent').canIgnore;13const canIgnore = require('stryker-parent').canIgnore;14const canIgnore = require('stryker-parent').canIgnore;15const canIgnore = require('stryker-parent').canIgnore;16const canIgnore = require('stryker-parent').canIgnore;17const canIgnore = require('stryker-parent').canIgnore;18const canIgnore = require('stryker-parent
Using AI Code Generation
1const canIgnore = require('stryker-parent').canIgnore;2console.log(canIgnore('test.js'));3const canIgnore = require('stryker-parent').canIgnore;4console.log(canIgnore('src/test.js'));5const canIgnore = require('stryker-parent').canIgnore;6console.log(canIgnore('src/test.js', ['src']));7const canIgnore = require('stryker-parent').canIgnore;8console.log(canIgnore('src/test.js', ['src', 'test']));9const canIgnore = require('stryker-parent').canIgnore;10console.log(canIgnore('src/test.js', ['src', 'test'], ['src/test.js']));11const canIgnore = require('stryker-parent').canIgnore;12console.log(canIgnore('src/test.js', ['src', 'test'], ['src/test.js', 'src/test1.js']));13const canIgnore = require('stryker-parent').canIgnore;14console.log(canIgnore('src/test.js', ['src', 'test'], ['src/test.js', 'src/test1.js'], ['src/test.js']));15const canIgnore = require('stryker-parent').canIgnore;16console.log(canIgnore('src/test.js', ['src', 'test'], ['src/test.js', 'src/test1.js'], ['src/test.js', 'src/test1.js']));17const canIgnore = require('stryker-parent').canIgnore;18console.log(canIgnore('src/test.js', ['src', 'test'], ['src/test.js', 'src/test1.js'], ['src/test.js', '
Using AI Code Generation
1const canIgnore = require('stryker-parent').canIgnore;2const shouldIgnore = canIgnore('test.js');3const canIgnore = require('stryker-parent').canIgnore;4const shouldIgnore = canIgnore('test.js');5const canIgnore = require('stryker-parent').canIgnore;6const shouldIgnore = canIgnore('test.js');7const canIgnore = require('stryker-parent').canIgnore;8const shouldIgnore = canIgnore('test.js');9const canIgnore = require('stryker-parent').canIgnore;10const shouldIgnore = canIgnore('test.js');11const canIgnore = require('stryker-parent').canIgnore;12const shouldIgnore = canIgnore('test.js');13const canIgnore = require('stryker-parent').canIgnore;14const shouldIgnore = canIgnore('test.js');15const canIgnore = require('stryker-parent').canIgnore;16const shouldIgnore = canIgnore('test.js');17const canIgnore = require('stryker-parent').canIgnore;18const shouldIgnore = canIgnore('test.js');19const canIgnore = require('stryker-parent').canIgnore;20const shouldIgnore = canIgnore('test.js');21const canIgnore = require('stryker-parent').canIgnore;22const shouldIgnore = canIgnore('test.js');23const canIgnore = require('stryker-parent').canIgnore;24const shouldIgnore = canIgnore('test.js');25const canIgnore = require('stryker-parent').canIgnore;26const shouldIgnore = canIgnore('test.js');27const canIgnore = require('stryker-parent').canIgnore;28const shouldIgnore = canIgnore('test.js');
Using AI Code Generation
1const canIgnore = require('stryker-parent').canIgnore;2const ignored = canIgnore('test.js');3const ignored = require('stryker-parent').canIgnore('test.js');4const ignored = require('stryker-parent').canIgnore;5import { canIgnore } from 'stryker-parent';6const ignored = canIgnore('test.js');7import { canIgnore } from 'stryker-parent';8const ignored = canIgnore;9import { canIgnore } from 'stryker-parent';10import { canIgnore } from 'stryker-parent';11import { canIgnore } from 'stryker-parent';12import { canIgnore } from 'stryker-parent';13import { canIgnore } from 'stryker-parent';14import { canIgnore } from 'stryker-parent';15import { canIgnore } from 'stryker-parent';
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!