How to use plan method in stryker-parent

Best JavaScript code snippet using stryker-parent

planactions.js

Source:planactions.js Github

copy

Full Screen

1// This file is part of Moodle - http://moodle.org/2//3// Moodle is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// Moodle is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.12//13// You should have received a copy of the GNU General Public License14// along with Moodle. If not, see <http://www.gnu.org/licenses/>.15/**16 * Plan actions via ajax.17 *18 * @module tool_lp/planactions19 * @package tool_lp20 * @copyright 2015 David Monllao21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later22 */23define(['jquery',24 'core/templates',25 'core/ajax',26 'core/notification',27 'core/str',28 'tool_lp/menubar',29 'tool_lp/dialogue'],30 function($, templates, ajax, notification, str, Menubar, Dialogue) {31 /**32 * PlanActions class.33 *34 * Note that presently this cannot be instantiated more than once per page.35 *36 * @param {String} type The type of page we're in.37 */38 var PlanActions = function(type) {39 this._type = type;40 if (type === 'plan') {41 // This is the page to view one plan.42 this._region = '[data-region="plan-page"]';43 this._planNode = '[data-region="plan-page"]';44 this._template = 'tool_lp/plan_page';45 this._contextMethod = 'tool_lp_data_for_plan_page';46 } else if (type === 'plans') {47 // This is the page to view a list of plans.48 this._region = '[data-region="plans"]';49 this._planNode = '[data-region="plan-node"]';50 this._template = 'tool_lp/plans_page';51 this._contextMethod = 'tool_lp_data_for_plans_page';52 } else {53 throw new TypeError('Unexpected type.');54 }55 };56 /** @type {String} Ajax method to fetch the page data from. */57 PlanActions.prototype._contextMethod = null;58 /** @type {String} Selector to find the node describing the plan. */59 PlanActions.prototype._planNode = null;60 /** @type {String} Selector mapping to the region to update. Usually similar to wrapper. */61 PlanActions.prototype._region = null;62 /** @type {String} Name of the template used to render the region. */63 PlanActions.prototype._template = null;64 /** @type {String} Type of page/region we're in. */65 PlanActions.prototype._type = null;66 /**67 * Resolve the arguments to refresh the region.68 *69 * @param {Object} planData Plan data from plan node.70 * @return {Object} List of arguments.71 */72 PlanActions.prototype._getContextArgs = function(planData) {73 var self = this,74 args = {};75 if (self._type === 'plan') {76 args = {77 planid: planData.id78 };79 } else if (self._type === 'plans') {80 args = {81 userid: planData.userid82 };83 }84 return args;85 };86 /**87 * Refresh the plan view.88 *89 * This is useful when you only want to refresh the view.90 *91 * @param {String} selector The node to search the plan data from.92 */93 PlanActions.prototype.refresh = function(selector) {94 var planData = this._findPlanData($(selector));95 this._callAndRefresh([], planData);96 };97 /**98 * Callback to render the region template.99 *100 * @param {Object} context The context for the template.101 */102 PlanActions.prototype._renderView = function(context) {103 var self = this;104 templates.render(self._template, context)105 .done(function(newhtml, newjs) {106 $(self._region).replaceWith(newhtml);107 templates.runTemplateJS(newjs);108 })109 .fail(notification.exception);110 };111 /**112 * Call multiple ajax methods, and refresh.113 *114 * @param {Array} calls List of Ajax calls.115 * @param {Object} planData Plan data from plan node.116 * @return {Promise}117 */118 PlanActions.prototype._callAndRefresh = function(calls, planData) {119 var self = this;120 calls.push({121 methodname: self._contextMethod,122 args: self._getContextArgs(planData)123 });124 // Apply all the promises, and refresh when the last one is resolved.125 return $.when.apply($.when, ajax.call(calls))126 .then(function() {127 self._renderView(arguments[arguments.length - 1]);128 })129 .fail(notification.exception);130 };131 /**132 * Delete a plan and reload the region.133 *134 * @param {Object} planData Plan data from plan node.135 */136 PlanActions.prototype._doDelete = function(planData) {137 var self = this,138 calls = [{139 methodname: 'core_competency_delete_plan',140 args: {id: planData.id}141 }];142 self._callAndRefresh(calls, planData);143 };144 /**145 * Delete a plan.146 *147 * @param {Object} planData Plan data from plan node.148 */149 PlanActions.prototype.deletePlan = function(planData) {150 var self = this,151 requests;152 requests = ajax.call([{153 methodname: 'core_competency_read_plan',154 args: {id: planData.id}155 }]);156 requests[0].done(function(plan) {157 str.get_strings([158 {key: 'confirm', component: 'moodle'},159 {key: 'deleteplan', component: 'tool_lp', param: plan.name},160 {key: 'delete', component: 'moodle'},161 {key: 'cancel', component: 'moodle'}162 ]).done(function(strings) {163 notification.confirm(164 strings[0], // Confirm.165 strings[1], // Delete plan X?166 strings[2], // Delete.167 strings[3], // Cancel.168 function() {169 self._doDelete(planData);170 }171 );172 }).fail(notification.exception);173 }).fail(notification.exception);174 };175 /**176 * Reopen plan and reload the region.177 *178 * @param {Object} planData Plan data from plan node.179 */180 PlanActions.prototype._doReopenPlan = function(planData) {181 var self = this,182 calls = [{183 methodname: 'core_competency_reopen_plan',184 args: {planid: planData.id}185 }];186 self._callAndRefresh(calls, planData);187 };188 /**189 * Reopen a plan.190 *191 * @param {Object} planData Plan data from plan node.192 */193 PlanActions.prototype.reopenPlan = function(planData) {194 var self = this,195 requests = ajax.call([{196 methodname: 'core_competency_read_plan',197 args: {id: planData.id}198 }]);199 requests[0].done(function(plan) {200 str.get_strings([201 {key: 'confirm', component: 'moodle'},202 {key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name},203 {key: 'reopenplan', component: 'tool_lp'},204 {key: 'cancel', component: 'moodle'}205 ]).done(function(strings) {206 notification.confirm(207 strings[0], // Confirm.208 strings[1], // Reopen plan X?209 strings[2], // reopen.210 strings[3], // Cancel.211 function() {212 self._doReopenPlan(planData);213 }214 );215 }).fail(notification.exception);216 }).fail(notification.exception);217 };218 /**219 * Complete plan and reload the region.220 *221 * @param {Object} planData Plan data from plan node.222 */223 PlanActions.prototype._doCompletePlan = function(planData) {224 var self = this,225 calls = [{226 methodname: 'core_competency_complete_plan',227 args: {planid: planData.id}228 }];229 self._callAndRefresh(calls, planData);230 };231 /**232 * Complete a plan process.233 *234 * @param {Object} planData Plan data from plan node.235 */236 PlanActions.prototype.completePlan = function(planData) {237 var self = this,238 requests = ajax.call([{239 methodname: 'core_competency_read_plan',240 args: {id: planData.id}241 }]);242 requests[0].done(function(plan) {243 str.get_strings([244 {key: 'confirm', component: 'moodle'},245 {key: 'completeplanconfirm', component: 'tool_lp', param: plan.name},246 {key: 'completeplan', component: 'tool_lp'},247 {key: 'cancel', component: 'moodle'}248 ]).done(function(strings) {249 notification.confirm(250 strings[0], // Confirm.251 strings[1], // Complete plan X?252 strings[2], // Complete.253 strings[3], // Cancel.254 function() {255 self._doCompletePlan(planData);256 }257 );258 }).fail(notification.exception);259 }).fail(notification.exception);260 };261 /**262 * Unlink plan and reload the region.263 *264 * @param {Object} planData Plan data from plan node.265 */266 PlanActions.prototype._doUnlinkPlan = function(planData) {267 var self = this,268 calls = [{269 methodname: 'core_competency_unlink_plan_from_template',270 args: {planid: planData.id}271 }];272 self._callAndRefresh(calls, planData);273 };274 /**275 * Unlink a plan process.276 *277 * @param {Object} planData Plan data from plan node.278 */279 PlanActions.prototype.unlinkPlan = function(planData) {280 var self = this,281 requests = ajax.call([{282 methodname: 'core_competency_read_plan',283 args: {id: planData.id}284 }]);285 requests[0].done(function(plan) {286 str.get_strings([287 {key: 'confirm', component: 'moodle'},288 {key: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name},289 {key: 'unlinkplantemplate', component: 'tool_lp'},290 {key: 'cancel', component: 'moodle'}291 ]).done(function(strings) {292 notification.confirm(293 strings[0], // Confirm.294 strings[1], // Unlink plan X?295 strings[2], // Unlink.296 strings[3], // Cancel.297 function() {298 self._doUnlinkPlan(planData);299 }300 );301 }).fail(notification.exception);302 }).fail(notification.exception);303 };304 /**305 * Request review of a plan.306 *307 * @param {Object} planData Plan data from plan node.308 * @method _doRequestReview309 */310 PlanActions.prototype._doRequestReview = function(planData) {311 var calls = [{312 methodname: 'core_competency_plan_request_review',313 args: {314 id: planData.id315 }316 }];317 this._callAndRefresh(calls, planData);318 };319 /**320 * Request review of a plan.321 *322 * @param {Object} planData Plan data from plan node.323 * @method requestReview324 */325 PlanActions.prototype.requestReview = function(planData) {326 this._doRequestReview(planData);327 };328 /**329 * Cancel review request of a plan.330 *331 * @param {Object} planData Plan data from plan node.332 * @method _doCancelReviewRequest333 */334 PlanActions.prototype._doCancelReviewRequest = function(planData) {335 var calls = [{336 methodname: 'core_competency_plan_cancel_review_request',337 args: {338 id: planData.id339 }340 }];341 this._callAndRefresh(calls, planData);342 };343 /**344 * Cancel review request of a plan.345 *346 * @param {Object} planData Plan data from plan node.347 * @method cancelReviewRequest348 */349 PlanActions.prototype.cancelReviewRequest = function(planData) {350 this._doCancelReviewRequest(planData);351 };352 /**353 * Start review of a plan.354 *355 * @param {Object} planData Plan data from plan node.356 * @method _doStartReview357 */358 PlanActions.prototype._doStartReview = function(planData) {359 var calls = [{360 methodname: 'core_competency_plan_start_review',361 args: {362 id: planData.id363 }364 }];365 this._callAndRefresh(calls, planData);366 };367 /**368 * Start review of a plan.369 *370 * @param {Object} planData Plan data from plan node.371 * @method startReview372 */373 PlanActions.prototype.startReview = function(planData) {374 this._doStartReview(planData);375 };376 /**377 * Stop review of a plan.378 *379 * @param {Object} planData Plan data from plan node.380 * @method _doStopReview381 */382 PlanActions.prototype._doStopReview = function(planData) {383 var calls = [{384 methodname: 'core_competency_plan_stop_review',385 args: {386 id: planData.id387 }388 }];389 this._callAndRefresh(calls, planData);390 };391 /**392 * Stop review of a plan.393 *394 * @param {Object} planData Plan data from plan node.395 * @method stopReview396 */397 PlanActions.prototype.stopReview = function(planData) {398 this._doStopReview(planData);399 };400 /**401 * Approve a plan.402 *403 * @param {Object} planData Plan data from plan node.404 * @method _doApprove405 */406 PlanActions.prototype._doApprove = function(planData) {407 var calls = [{408 methodname: 'core_competency_approve_plan',409 args: {410 id: planData.id411 }412 }];413 this._callAndRefresh(calls, planData);414 };415 /**416 * Approve a plan.417 *418 * @param {Object} planData Plan data from plan node.419 * @method approve420 */421 PlanActions.prototype.approve = function(planData) {422 this._doApprove(planData);423 };424 /**425 * Unapprove a plan.426 *427 * @param {Object} planData Plan data from plan node.428 * @method _doUnapprove429 */430 PlanActions.prototype._doUnapprove = function(planData) {431 var calls = [{432 methodname: 'core_competency_unapprove_plan',433 args: {434 id: planData.id435 }436 }];437 this._callAndRefresh(calls, planData);438 };439 /**440 * Unapprove a plan.441 *442 * @param {Object} planData Plan data from plan node.443 * @method unapprove444 */445 PlanActions.prototype.unapprove = function(planData) {446 this._doUnapprove(planData);447 };448 /**449 * Display list of linked courses on a modal dialogue.450 *451 * @param {Event} e The event.452 */453 PlanActions.prototype._showLinkedCoursesHandler = function(e) {454 e.preventDefault();455 var competencyid = $(e.target).data('id');456 var requests = ajax.call([{457 methodname: 'tool_lp_list_courses_using_competency',458 args: {id: competencyid}459 }]);460 requests[0].done(function(courses) {461 var context = {462 courses: courses463 };464 templates.render('tool_lp/linked_courses_summary', context).done(function(html) {465 str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {466 new Dialogue(467 linkedcourses, // Title.468 html // The linked courses.469 );470 }).fail(notification.exception);471 }).fail(notification.exception);472 }).fail(notification.exception);473 };474 /**475 * Plan event handler.476 *477 * @param {String} method The method to call.478 * @param {Event} e The event.479 * @method _eventHandler480 */481 PlanActions.prototype._eventHandler = function(method, e) {482 e.preventDefault();483 var data = this._findPlanData($(e.target));484 this[method](data);485 };486 /**487 * Find the plan data from the plan node.488 *489 * @param {Node} node The node to search from.490 * @return {Object} Plan data.491 */492 PlanActions.prototype._findPlanData = function(node) {493 var parent = node.parentsUntil($(this._region).parent(), this._planNode),494 data;495 if (parent.length != 1) {496 throw new Error('The plan node was not located.');497 }498 data = parent.data();499 if (typeof data === 'undefined' || typeof data.id === 'undefined') {500 throw new Error('Plan data could not be found.');501 }502 return data;503 };504 /**505 * Enhance a menu bar.506 *507 * @param {String} selector Menubar selector.508 */509 PlanActions.prototype.enhanceMenubar = function(selector) {510 Menubar.enhance(selector, {511 '[data-action="plan-delete"]': this._eventHandler.bind(this, 'deletePlan'),512 '[data-action="plan-complete"]': this._eventHandler.bind(this, 'completePlan'),513 '[data-action="plan-reopen"]': this._eventHandler.bind(this, 'reopenPlan'),514 '[data-action="plan-unlink"]': this._eventHandler.bind(this, 'unlinkPlan'),515 '[data-action="plan-request-review"]': this._eventHandler.bind(this, 'requestReview'),516 '[data-action="plan-cancel-review-request"]': this._eventHandler.bind(this, 'cancelReviewRequest'),517 '[data-action="plan-start-review"]': this._eventHandler.bind(this, 'startReview'),518 '[data-action="plan-stop-review"]': this._eventHandler.bind(this, 'stopReview'),519 '[data-action="plan-approve"]': this._eventHandler.bind(this, 'approve'),520 '[data-action="plan-unapprove"]': this._eventHandler.bind(this, 'unapprove'),521 });522 };523 /**524 * Register the events in the region.525 *526 * At this stage this cannot be used with enhanceMenubar or multiple handlers527 * will be added to the same node.528 */529 PlanActions.prototype.registerEvents = function() {530 var wrapper = $(this._region);531 wrapper.find('[data-action="plan-delete"]').click(this._eventHandler.bind(this, 'deletePlan'));532 wrapper.find('[data-action="plan-complete"]').click(this._eventHandler.bind(this, 'completePlan'));533 wrapper.find('[data-action="plan-reopen"]').click(this._eventHandler.bind(this, 'reopenPlan'));534 wrapper.find('[data-action="plan-unlink"]').click(this._eventHandler.bind(this, 'unlinkPlan'));535 wrapper.find('[data-action="plan-request-review"]').click(this._eventHandler.bind(this, 'requestReview'));536 wrapper.find('[data-action="plan-cancel-review-request"]').click(this._eventHandler.bind(this, 'cancelReviewRequest'));537 wrapper.find('[data-action="plan-start-review"]').click(this._eventHandler.bind(this, 'startReview'));538 wrapper.find('[data-action="plan-stop-review"]').click(this._eventHandler.bind(this, 'stopReview'));539 wrapper.find('[data-action="plan-approve"]').click(this._eventHandler.bind(this, 'approve'));540 wrapper.find('[data-action="plan-unapprove"]').click(this._eventHandler.bind(this, 'unapprove'));541 wrapper.find('[data-action="find-courses-link"]').click(this._showLinkedCoursesHandler.bind(this));542 };543 return PlanActions;...

Full Screen

Full Screen

test_staffing_plan.py

Source:test_staffing_plan.py Github

copy

Full Screen

...8from erpnext.hr.doctype.staffing_plan.staffing_plan import ParentCompanyError9from frappe.utils import nowdate, add_days10test_dependencies = ["Designation"]11class TestStaffingPlan(unittest.TestCase):12 def test_staffing_plan(self):13 _set_up()14 frappe.db.set_value("Company", "_Test Company", "is_group", 1)15 if frappe.db.exists("Staffing Plan", "Test"):16 return17 staffing_plan = frappe.new_doc("Staffing Plan")18 staffing_plan.company = "_Test Company 10"19 staffing_plan.name = "Test"20 staffing_plan.from_date = nowdate()21 staffing_plan.to_date = add_days(nowdate(), 10)22 staffing_plan.append("staffing_details", {23 "designation": "Designer",24 "vacancies": 6,25 "estimated_cost_per_position": 5000026 })27 staffing_plan.insert()28 staffing_plan.submit()29 self.assertEqual(staffing_plan.total_estimated_budget, 300000.00)30 def test_staffing_plan_subsidiary_company(self):31 self.test_staffing_plan()32 if frappe.db.exists("Staffing Plan", "Test 1"):33 return34 staffing_plan = frappe.new_doc("Staffing Plan")35 staffing_plan.company = "_Test Company"36 staffing_plan.name = "Test 1"37 staffing_plan.from_date = nowdate()38 staffing_plan.to_date = add_days(nowdate(), 10)39 staffing_plan.append("staffing_details", {40 "designation": "Designer",41 "vacancies": 3,42 "estimated_cost_per_position": 4500043 })44 self.assertRaises(SubsidiaryCompanyError, staffing_plan.insert)45 def test_staffing_plan_parent_company(self):...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var plan = require('stryker-parent').plan;2plan(1);3var test = require('stryker-parent').test;4test('test name', function (t) {5 t.pass();6 t.end();7});8module.exports = function (config) {9 config.set({10 });11};

Full Screen

Using AI Code Generation

copy

Full Screen

1var plan = require('stryker-parent').plan;2plan('test');3var plan = require('stryker-parent').plan;4plan('test');5var plan = require('stryker-parent').plan;6plan('test');7var plan = require('stryker-parent').plan;8plan('test');9var plan = require('stryker-parent').plan;10plan('test');11var plan = require('stryker-parent').plan;12plan('test');13var plan = require('stryker-parent').plan;14plan('test');15var plan = require('stryker-parent').plan;16plan('test');17var plan = require('stryker-parent').plan;18plan('test');19var plan = require('stryker-parent').plan;20plan('test');21var plan = require('stryker-parent').plan;22plan('test');23var plan = require('stryker-parent').plan;24plan('test');25var plan = require('stryker-parent').plan;26plan('test');27var plan = require('stryker-parent').plan;28plan('test');29var plan = require('stryker-parent').plan;30plan('test');31var plan = require('stryker-parent').plan;32plan('test');33var plan = require('stryker-parent').plan;34plan('test');

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.plan(2);3var stryker = require('stryker-parent');4stryker.plan(2);5var stryker = require('stryker-parent');6stryker.plan(2);7var stryker = require('stryker-parent');8stryker.plan(2, '2 tests are expected to be executed in this test run');9var stryker = require('stryker-parent');10stryker.plan(2);

Full Screen

Using AI Code Generation

copy

Full Screen

1var plan = require('stryker-parent').plan;2plan(1);3test('should be ok', function (t) {4 t.ok(true);5 t.end();6});7module.exports = function (config) {8 config.set({9 jest: {10 config: require('./jest.config.js'),11 }12 });13};14module.exports = {15};

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var plan = stryker.plan();3plan.start();4var stryker = require('stryker-parent');5var plan = stryker.plan();6plan.start();7This means that the plan() method is returning a new object each time it is called. Now, let’s make sure that the plan() method returns the same object each time it is called:8var plan = null;9module.exports = {10 plan: function() {11 if (!plan) {12 plan = {13 start: function() {14 console.log('Starting the plan');15 }16 };17 }18 return plan;19 }20};21var stryker = require('stryker-parent');22var plan = stryker.plan();23plan.start();24var stryker = require('stryker-parent');25var plan = stryker.plan();26plan.start();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { plan } = require("stryker-parent");2const { Stryker } = require("stryker");3const { ConfigReader } = require("stryker-api/config");4const config = ConfigReader.readConfig();5const stryker = new Stryker(config);6plan(stryker);7module.exports = function(config) {8config.set({9});10};11{12 "scripts": {13 }14}

Full Screen

Using AI Code Generation

copy

Full Screen

1var parent = require('stryker-parent');2var child = parent.fork('./child.js');3parent.plan(child, function (err, result) {4 if (err) {5 console.error(err);6 process.exit(1);7 }8 console.log(result);9 process.exit(0);10});11var Mocha = require('mocha');12var path = require('path');13var fs = require('fs');14var mocha = new Mocha({15});16var testDir = 'test';17fs.readdirSync(testDir).filter(function(file) {18 return file.substr(-3) === '.js';19}).forEach(function(file) {20 mocha.addFile(21 path.join(testDir, file)22 );23});24mocha.run(function(failures) {25 process.on('exit', function () {26 });27});28module.exports = function (config) {29 config.set({30 });31};

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent 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