Best Python code snippet using sure_python
test-metrics_test.js
Source:test-metrics_test.js
1'use strict';2describe('continuumAssessmentPlatform.test-metrics module', function() {3 beforeEach(module('continuumAssessmentPlatform.test-metrics'));4 describe('Test Metrics controller', function(){5 var controller;6 var scope, rootScope;7 beforeEach(inject(function($controller, $rootScope){8 rootScope = $rootScope;9 scope = rootScope.$new();10 controller = $controller('TestMetricsCtrl', {'$scope': scope, '$rootScope': rootScope});11 }));12 it('should be defined', function() {13 expect(controller).toBeDefined();14 });15 it('should have defaults as false for the traveller questions', function(){16 expect(scope.traveller1).toBeDefined();17 expect(scope.traveller2).toBeDefined();18 expect(scope.traveller3).toBeDefined();19 expect(scope.traveller4).toBeDefined();20 expect(scope.traveller5).toBeDefined();21 expect(scope.traveller1).toBeFalsy();22 expect(scope.traveller2).toBeFalsy();23 expect(scope.traveller3).toBeFalsy();24 expect(scope.traveller4).toBeFalsy();25 expect(scope.traveller5).toBeFalsy();26 });27 it('should have defaults as false for the artisan questions', function(){28 expect(scope.artisan1).toBeDefined();29 expect(scope.artisan2).toBeDefined();30 expect(scope.artisan3).toBeDefined();31 expect(scope.artisan4).toBeDefined();32 expect(scope.artisan5).toBeDefined();33 expect(scope.artisan6).toBeDefined();34 expect(scope.artisan7).toBeDefined();35 expect(scope.artisan8).toBeDefined();36 expect(scope.artisan1).toBeFalsy();37 expect(scope.artisan2).toBeFalsy();38 expect(scope.artisan3).toBeFalsy();39 expect(scope.artisan4).toBeFalsy();40 expect(scope.artisan5).toBeFalsy();41 expect(scope.artisan6).toBeFalsy();42 expect(scope.artisan7).toBeFalsy();43 expect(scope.artisan8).toBeFalsy();44 });45 it('should have defaults as false for the expert questions', function(){46 expect(scope.expert1).toBeDefined();47 expect(scope.expert2).toBeDefined();48 expect(scope.expert3).toBeDefined();49 expect(scope.expert4).toBeDefined();50 expect(scope.expert5).toBeDefined();51 expect(scope.expert6).toBeDefined();52 expect(scope.expert7).toBeDefined();53 expect(scope.expert8).toBeDefined();54 expect(scope.expert1).toBeFalsy();55 expect(scope.expert2).toBeFalsy();56 expect(scope.expert3).toBeFalsy();57 expect(scope.expert4).toBeFalsy();58 expect(scope.expert5).toBeFalsy();59 expect(scope.expert6).toBeFalsy();60 expect(scope.expert7).toBeFalsy();61 expect(scope.expert8).toBeFalsy();62 });63 it('should have defaults as false for the professional questions', function(){64 expect(scope.professional1).toBeDefined();65 expect(scope.professional2).toBeDefined();66 expect(scope.professional3).toBeDefined();67 expect(scope.professional4).toBeDefined();68 expect(scope.professional5).toBeDefined();69 expect(scope.professional6).toBeDefined();70 expect(scope.professional7).toBeDefined();71 expect(scope.professional8).toBeDefined();72 expect(scope.professional9).toBeDefined();73 expect(scope.professional10).toBeDefined();74 expect(scope.professional11).toBeDefined();75 expect(scope.professional12).toBeDefined();76 expect(scope.professional1).toBeFalsy();77 expect(scope.professional2).toBeFalsy();78 expect(scope.professional3).toBeFalsy();79 expect(scope.professional4).toBeFalsy();80 expect(scope.professional5).toBeFalsy();81 expect(scope.professional6).toBeFalsy();82 expect(scope.professional7).toBeFalsy();83 expect(scope.professional8).toBeFalsy();84 expect(scope.professional9).toBeFalsy();85 expect(scope.professional10).toBeFalsy();86 expect(scope.professional11).toBeFalsy();87 expect(scope.professional12).toBeFalsy();88 });89 it('should have defaults as false for the master questions', function(){90 expect(scope.master1).toBeDefined();91 expect(scope.master2).toBeDefined();92 expect(scope.master3).toBeDefined();93 expect(scope.master4).toBeDefined();94 expect(scope.master5).toBeDefined();95 expect(scope.master6).toBeDefined();96 expect(scope.master7).toBeDefined();97 expect(scope.master8).toBeDefined();98 expect(scope.master9).toBeDefined();99 expect(scope.master10).toBeDefined();100 expect(scope.master11).toBeDefined();101 expect(scope.master12).toBeDefined();102 expect(scope.master13).toBeDefined();103 expect(scope.master1).toBeFalsy();104 expect(scope.master2).toBeFalsy();105 expect(scope.master3).toBeFalsy();106 expect(scope.master4).toBeFalsy();107 expect(scope.master5).toBeFalsy();108 expect(scope.master6).toBeFalsy();109 expect(scope.master7).toBeFalsy();110 expect(scope.master8).toBeFalsy();111 expect(scope.master9).toBeFalsy();112 expect(scope.master10).toBeFalsy();113 expect(scope.master11).toBeFalsy();114 expect(scope.master12).toBeFalsy();115 expect(scope.master13).toBeFalsy();116 });117 it('should set the default values based on the rootScope if they are present', inject(function($controller){118 rootScope = {'assessmentsQaMaM': {'test-metrics': {119 'traveller1': true, 'traveller2': true, 'traveller3': true, 'traveller4': true, 'traveller5': true,120 'artisan1': true, 'artisan2': false, 'artisan3': false, 'artisan4': false, 'artisan5': false, 'artisan6': false, 'artisan7': false, 'artisan8': false,121 'expert1': true, 'expert2': false, 'expert3': false, 'expert4': false, 'expert5': false, 'expert6': false, 'expert7': false, 'expert8': false,122 'professional1': false, 'professional2': true, 'professional3': false, 'professional4': false, 'professional5': false, 'professional6': false, 'professional7': false, 'professional8': false, 'professional9': false, 'professional10': false, 'professional11': false, 'professional12': false,123 'master1': false, 'master2': false, 'master3': true, 'master4': false, 'master5': false, 'master6': false, 'master7': false, 'master8': false, 'master9': false, 'master10': false, 'master11': false, 'master12': false, 'master13': false}}};124 controller = $controller('TestMetricsCtrl', {'$scope': scope, '$rootScope': rootScope});125 scope.init();126 expect(scope.traveller1).toBeTruthy();127 expect(scope.traveller2).toBeTruthy();128 expect(scope.traveller3).toBeTruthy();129 expect(scope.traveller4).toBeTruthy();130 expect(scope.traveller5).toBeTruthy();131 expect(scope.artisan1).toBeTruthy();132 expect(scope.artisan2).toBeFalsy();133 expect(scope.artisan3).toBeFalsy();134 expect(scope.artisan4).toBeFalsy();135 expect(scope.artisan5).toBeFalsy();136 expect(scope.artisan6).toBeFalsy();137 expect(scope.artisan7).toBeFalsy();138 expect(scope.artisan8).toBeFalsy();139 expect(scope.expert1).toBeTruthy();140 expect(scope.expert2).toBeFalsy();141 expect(scope.expert3).toBeFalsy();142 expect(scope.expert4).toBeFalsy();143 expect(scope.expert5).toBeFalsy();144 expect(scope.expert6).toBeFalsy();145 expect(scope.expert7).toBeFalsy();146 expect(scope.expert8).toBeFalsy();147 expect(scope.professional1).toBeFalsy();148 expect(scope.professional2).toBeTruthy();149 expect(scope.professional3).toBeFalsy();150 expect(scope.professional4).toBeFalsy();151 expect(scope.professional5).toBeFalsy();152 expect(scope.professional6).toBeFalsy();153 expect(scope.professional7).toBeFalsy();154 expect(scope.professional8).toBeFalsy();155 expect(scope.professional9).toBeFalsy();156 expect(scope.professional10).toBeFalsy();157 expect(scope.professional11).toBeFalsy();158 expect(scope.professional12).toBeFalsy();159 expect(scope.master1).toBeFalsy();160 expect(scope.master2).toBeFalsy();161 expect(scope.master3).toBeTruthy();162 expect(scope.master4).toBeFalsy();163 expect(scope.master5).toBeFalsy();164 expect(scope.master6).toBeFalsy();165 expect(scope.master7).toBeFalsy();166 expect(scope.master8).toBeFalsy();167 expect(scope.master9).toBeFalsy();168 expect(scope.master10).toBeFalsy();169 expect(scope.master11).toBeFalsy();170 expect(scope.master12).toBeFalsy();171 expect(scope.master13).toBeFalsy();172 }));173 it('should set the default values based on the initial values if rootScope not set', inject(function($controller){174 rootScope = {};175 controller = $controller('TestMetricsCtrl', {'$scope': scope, '$rootScope': rootScope});176 scope.init();177 expect(scope.traveller1).toBeFalsy();178 expect(scope.traveller2).toBeFalsy();179 expect(scope.traveller3).toBeFalsy();180 expect(scope.traveller4).toBeFalsy();181 expect(scope.traveller5).toBeFalsy();182 expect(scope.artisan1).toBeFalsy();183 expect(scope.artisan2).toBeFalsy();184 expect(scope.artisan3).toBeFalsy();185 expect(scope.artisan4).toBeFalsy();186 expect(scope.artisan5).toBeFalsy();187 expect(scope.artisan6).toBeFalsy();188 expect(scope.artisan7).toBeFalsy();189 expect(scope.artisan8).toBeFalsy();190 expect(scope.expert1).toBeFalsy();191 expect(scope.expert2).toBeFalsy();192 expect(scope.expert3).toBeFalsy();193 expect(scope.expert4).toBeFalsy();194 expect(scope.expert5).toBeFalsy();195 expect(scope.expert6).toBeFalsy();196 expect(scope.expert7).toBeFalsy();197 expect(scope.expert8).toBeFalsy();198 expect(scope.professional1).toBeFalsy();199 expect(scope.professional2).toBeFalsy();200 expect(scope.professional3).toBeFalsy();201 expect(scope.professional4).toBeFalsy();202 expect(scope.professional5).toBeFalsy();203 expect(scope.professional6).toBeFalsy();204 expect(scope.professional7).toBeFalsy();205 expect(scope.professional8).toBeFalsy();206 expect(scope.professional9).toBeFalsy();207 expect(scope.professional10).toBeFalsy();208 expect(scope.professional11).toBeFalsy();209 expect(scope.professional12).toBeFalsy();210 expect(scope.master1).toBeFalsy();211 expect(scope.master2).toBeFalsy();212 expect(scope.master3).toBeFalsy();213 expect(scope.master4).toBeFalsy();214 expect(scope.master5).toBeFalsy();215 expect(scope.master6).toBeFalsy();216 expect(scope.master7).toBeFalsy();217 expect(scope.master8).toBeFalsy();218 expect(scope.master9).toBeFalsy();219 expect(scope.master10).toBeFalsy();220 expect(scope.master11).toBeFalsy();221 expect(scope.master12).toBeFalsy();222 expect(scope.master13).toBeFalsy();223 }));224 it('should set the default values based on the initial values if rootScope not set even though there are assessments', inject(function($controller){225 rootScope = {'assessmentsQaMaM': {'ci': {}}};226 controller = $controller('TestMetricsCtrl', {'$scope': scope, '$rootScope': rootScope});227 scope.init();228 expect(scope.traveller1).toBeFalsy();229 expect(scope.traveller2).toBeFalsy();230 expect(scope.traveller3).toBeFalsy();231 expect(scope.traveller4).toBeFalsy();232 expect(scope.traveller5).toBeFalsy();233 expect(scope.artisan1).toBeFalsy();234 expect(scope.artisan2).toBeFalsy();235 expect(scope.artisan3).toBeFalsy();236 expect(scope.artisan4).toBeFalsy();237 expect(scope.artisan5).toBeFalsy();238 expect(scope.artisan6).toBeFalsy();239 expect(scope.artisan7).toBeFalsy();240 expect(scope.artisan8).toBeFalsy();241 expect(scope.expert1).toBeFalsy();242 expect(scope.expert2).toBeFalsy();243 expect(scope.expert3).toBeFalsy();244 expect(scope.expert4).toBeFalsy();245 expect(scope.expert5).toBeFalsy();246 expect(scope.expert6).toBeFalsy();247 expect(scope.expert7).toBeFalsy();248 expect(scope.expert8).toBeFalsy();249 expect(scope.professional1).toBeFalsy();250 expect(scope.professional2).toBeFalsy();251 expect(scope.professional3).toBeFalsy();252 expect(scope.professional4).toBeFalsy();253 expect(scope.professional5).toBeFalsy();254 expect(scope.professional6).toBeFalsy();255 expect(scope.professional7).toBeFalsy();256 expect(scope.professional8).toBeFalsy();257 expect(scope.professional9).toBeFalsy();258 expect(scope.professional10).toBeFalsy();259 expect(scope.professional11).toBeFalsy();260 expect(scope.professional12).toBeFalsy();261 expect(scope.master1).toBeFalsy();262 expect(scope.master2).toBeFalsy();263 expect(scope.master3).toBeFalsy();264 expect(scope.master4).toBeFalsy();265 expect(scope.master5).toBeFalsy();266 expect(scope.master6).toBeFalsy();267 expect(scope.master7).toBeFalsy();268 expect(scope.master8).toBeFalsy();269 expect(scope.master9).toBeFalsy();270 expect(scope.master10).toBeFalsy();271 expect(scope.master11).toBeFalsy();272 expect(scope.master12).toBeFalsy();273 expect(scope.master13).toBeFalsy();274 }));275 it('should save the values for the assessment results for test metrics', function(){276 scope.traveller1 = true;277 scope.traveller2 = true;278 scope.traveller3 = true;279 scope.traveller4 = true;280 scope.traveller5 = true;281 scope.artisan1 = true;282 scope.artisan2 = false;283 scope.artisan3 = false;284 scope.artisan4 = false;285 scope.artisan5 = false;286 scope.artisan6 = false;287 scope.artisan7 = false;288 scope.artisan8 = false;289 scope.expert1 = true;290 scope.expert2 = false;291 scope.expert3 = false;292 scope.expert4 = false;293 scope.expert5 = false;294 scope.expert6 = false;295 scope.expert7 = false;296 scope.expert8 = false;297 scope.professional1 = false;298 scope.professional2 = false;299 scope.professional3 = false;300 scope.professional4 = false;301 scope.professional5 = false;302 scope.professional6 = false;303 scope.professional7 = false;304 scope.professional8 = false;305 scope.professional9 = false;306 scope.professional10 = false;307 scope.professional11 = false;308 scope.professional12 = false;309 scope.master1 = false;310 scope.master2 = false;311 scope.master3 = false;312 scope.master4 = false;313 scope.master5 = false;314 scope.master6 = false;315 scope.master7 = false;316 scope.master8 = false;317 scope.master9 = false;318 scope.master10 = false;319 scope.master11 = false;320 scope.master12 = false;321 scope.master13 = false;322 var expectedTestMetrics = {323 'traveller1': true, 'traveller2': true, 'traveller3': true, 'traveller4': true, 'traveller5': true,324 'artisan1': true, 'artisan2': false, 'artisan3': false, 'artisan4': false, 'artisan5': false, 'artisan6': false, 'artisan7': false, 'artisan8': false,325 'expert1': true, 'expert2': false, 'expert3': false, 'expert4': false, 'expert5': false, 'expert6': false, 'expert7': false, 'expert8': false,326 'professional1': false, 'professional2': false, 'professional3': false, 'professional4': false, 'professional5': false, 'professional6': false, 'professional7': false, 'professional8': false, 'professional9': false, 'professional10': false, 'professional11': false, 'professional12': false,327 'master1': false, 'master2': false, 'master3': false, 'master4': false, 'master5': false, 'master6': false, 'master7': false, 'master8': false, 'master9': false, 'master10': false, 'master11': false, 'master12': false, 'master13': false};328 scope.saveAssessments();329 var testMetrics = rootScope.assessmentsQaMaM['test-metrics'];330 expect(testMetrics['traveller1']).toEqual(expectedTestMetrics[['traveller1']]);331 expect(testMetrics['traveller2']).toEqual(expectedTestMetrics[['traveller2']]);332 expect(testMetrics['traveller3']).toEqual(expectedTestMetrics[['traveller3']]);333 expect(testMetrics['traveller4']).toEqual(expectedTestMetrics[['traveller4']]);334 expect(testMetrics['traveller5']).toEqual(expectedTestMetrics[['traveller5']]);335 expect(testMetrics['artisan1']).toEqual(expectedTestMetrics[['artisan1']]);336 expect(testMetrics['artisan2']).toEqual(expectedTestMetrics[['artisan2']]);337 expect(testMetrics['artisan3']).toEqual(expectedTestMetrics[['artisan3']]);338 expect(testMetrics['artisan4']).toEqual(expectedTestMetrics[['artisan4']]);339 expect(testMetrics['artisan5']).toEqual(expectedTestMetrics[['artisan5']]);340 expect(testMetrics['artisan6']).toEqual(expectedTestMetrics[['artisan6']]);341 expect(testMetrics['artisan7']).toEqual(expectedTestMetrics[['artisan7']]);342 expect(testMetrics['artisan8']).toEqual(expectedTestMetrics[['artisan8']]);343 expect(testMetrics['expert1']).toEqual(expectedTestMetrics[['expert1']]);344 expect(testMetrics['expert2']).toEqual(expectedTestMetrics[['expert2']]);345 expect(testMetrics['expert3']).toEqual(expectedTestMetrics[['expert3']]);346 expect(testMetrics['expert4']).toEqual(expectedTestMetrics[['expert4']]);347 expect(testMetrics['expert5']).toEqual(expectedTestMetrics[['expert5']]);348 expect(testMetrics['expert6']).toEqual(expectedTestMetrics[['expert6']]);349 expect(testMetrics['expert7']).toEqual(expectedTestMetrics[['expert7']]);350 expect(testMetrics['expert8']).toEqual(expectedTestMetrics[['expert8']]);351 expect(testMetrics['professional1']).toEqual(expectedTestMetrics[['professional1']]);352 expect(testMetrics['professional2']).toEqual(expectedTestMetrics[['professional2']]);353 expect(testMetrics['professional3']).toEqual(expectedTestMetrics[['professional3']]);354 expect(testMetrics['professional4']).toEqual(expectedTestMetrics[['professional4']]);355 expect(testMetrics['professional5']).toEqual(expectedTestMetrics[['professional5']]);356 expect(testMetrics['professional6']).toEqual(expectedTestMetrics[['professional6']]);357 expect(testMetrics['professional7']).toEqual(expectedTestMetrics[['professional7']]);358 expect(testMetrics['professional8']).toEqual(expectedTestMetrics[['professional8']]);359 expect(testMetrics['professional9']).toEqual(expectedTestMetrics[['professional9']]);360 expect(testMetrics['professional10']).toEqual(expectedTestMetrics[['professional10']]);361 expect(testMetrics['professional11']).toEqual(expectedTestMetrics[['professional11']]);362 expect(testMetrics['professional12']).toEqual(expectedTestMetrics[['professional12']]);363 expect(testMetrics['master1']).toEqual(expectedTestMetrics[['master1']]);364 expect(testMetrics['master2']).toEqual(expectedTestMetrics[['master2']]);365 expect(testMetrics['master3']).toEqual(expectedTestMetrics[['master3']]);366 expect(testMetrics['master4']).toEqual(expectedTestMetrics[['master4']]);367 expect(testMetrics['master5']).toEqual(expectedTestMetrics[['master5']]);368 expect(testMetrics['master6']).toEqual(expectedTestMetrics[['master6']]);369 expect(testMetrics['master7']).toEqual(expectedTestMetrics[['master7']]);370 expect(testMetrics['master8']).toEqual(expectedTestMetrics[['master8']]);371 expect(testMetrics['master9']).toEqual(expectedTestMetrics[['master9']]);372 expect(testMetrics['master10']).toEqual(expectedTestMetrics[['master10']]);373 expect(testMetrics['master11']).toEqual(expectedTestMetrics[['master11']]);374 expect(testMetrics['master12']).toEqual(expectedTestMetrics[['master12']]);375 expect(testMetrics['master13']).toEqual(expectedTestMetrics[['master13']]);376 });377 it('should save the score for test metrics as 1 if no question is answered', function(){378 scope.traveller1 = false;379 scope.traveller2 = false;380 scope.traveller3 = false;381 scope.traveller4 = false;382 scope.traveller5 = false;383 scope.artisan1 = false;384 scope.artisan2 = false;385 scope.artisan3 = false;386 scope.artisan4 = false;387 scope.artisan5 = false;388 scope.artisan6 = false;389 scope.artisan7 = false;390 scope.artisan8 = false;391 scope.expert1 = false;392 scope.expert2 = false;393 scope.expert3 = false;394 scope.expert4 = false;395 scope.expert5 = false;396 scope.expert6 = false;397 scope.expert7 = false;398 scope.expert8 = false;399 scope.professional1 = false;400 scope.professional2 = false;401 scope.professional3 = false;402 scope.professional4 = false;403 scope.professional5 = false;404 scope.professional6 = false;405 scope.professional7 = false;406 scope.professional8 = false;407 scope.professional9 = false;408 scope.professional10 = false;409 scope.professional11 = false;410 scope.professional12 = false;411 scope.master1 = false;412 scope.master2 = false;413 scope.master3 = false;414 scope.master4 = false;415 scope.master5 = false;416 scope.master6 = false;417 scope.master7 = false;418 scope.master8 = false;419 scope.master9 = false;420 scope.master10 = false;421 scope.master11 = false;422 scope.master12 = false;423 scope.master13 = false;424 var expectedTestMetricsScore = 1;425 scope.saveAssessments();426 var testMetrics = rootScope.assessmentsQaMaM['test-metrics'];427 expect(testMetrics['score']).toEqual(expectedTestMetricsScore);428 });429 it('should save the score for test metrics as 1 if traveller question is answered as yes', function(){430 scope.traveller1 = true;431 scope.traveller2 = true;432 scope.traveller3 = true;433 scope.traveller4 = true;434 scope.traveller5 = true;435 scope.artisan1 = true;436 scope.artisan2 = false;437 scope.artisan3 = false;438 scope.artisan4 = false;439 scope.artisan5 = false;440 scope.artisan6 = false;441 scope.artisan7 = false;442 scope.artisan8 = false;443 scope.expert1 = false;444 scope.expert2 = false;445 scope.expert3 = false;446 scope.expert4 = false;447 scope.expert5 = false;448 scope.expert6 = false;449 scope.expert7 = false;450 scope.expert8 = false;451 scope.professional1 = false;452 scope.professional2 = false;453 scope.professional3 = false;454 scope.professional4 = false;455 scope.professional5 = false;456 scope.professional6 = false;457 scope.professional7 = false;458 scope.professional8 = false;459 scope.professional9 = false;460 scope.professional10 = false;461 scope.professional11 = false;462 scope.professional12 = false;463 scope.master1 = false;464 scope.master2 = false;465 scope.master3 = false;466 scope.master4 = false;467 scope.master5 = false;468 scope.master6 = false;469 scope.master7 = false;470 scope.master8 = false;471 scope.master9 = false;472 scope.master10 = false;473 scope.master11 = false;474 scope.master12 = false;475 scope.master13 = false;476 var expectedTestMetricsScore = 1;477 scope.saveAssessments();478 var testMetrics = rootScope.assessmentsQaMaM['test-metrics'];479 expect(testMetrics['score']).toEqual(expectedTestMetricsScore);480 });481 it('should save the score for test metrics as 2 if traveller question is answered as no and all the artisan questions answered as yes', function(){482 scope.traveller1 = false;483 scope.traveller2 = false;484 scope.traveller3 = false;485 scope.traveller4 = false;486 scope.traveller5 = false;487 scope.artisan1 = true;488 scope.artisan2 = true;489 scope.artisan3 = true;490 scope.artisan4 = true;491 scope.artisan5 = true;492 scope.artisan6 = true;493 scope.artisan7 = true;494 scope.artisan8 = true;495 scope.expert1 = true;496 scope.expert2 = true;497 scope.expert3 = false;498 scope.expert4 = false;499 scope.expert5 = false;500 scope.expert6 = false;501 scope.expert7 = false;502 scope.expert8 = false;503 scope.professional1 = false;504 scope.professional2 = false;505 scope.professional3 = false;506 scope.professional4 = false;507 scope.professional5 = false;508 scope.professional6 = false;509 scope.professional7 = false;510 scope.professional8 = false;511 scope.professional9 = false;512 scope.professional10 = false;513 scope.professional11 = false;514 scope.professional12 = false;515 scope.master1 = false;516 scope.master2 = false;517 scope.master3 = false;518 scope.master4 = false;519 scope.master5 = false;520 scope.master6 = false;521 scope.master7 = false;522 scope.master8 = false;523 scope.master9 = false;524 scope.master10 = false;525 scope.master11 = false;526 scope.master12 = false;527 scope.master13 = false;528 var expectedTestMetricsScore = 2;529 scope.saveAssessments();530 var testMetrics = rootScope.assessmentsQaMaM['test-metrics'];531 expect(testMetrics['score']).toEqual(expectedTestMetricsScore);532 });533 it('should save the score for test metrics as 3 if traveller question is answered as no and all the artisan questions answered as yes' +534 'and the expert questions are answered as yes', function(){535 scope.traveller1 = false;536 scope.traveller2 = false;537 scope.traveller3 = false;538 scope.traveller4 = false;539 scope.traveller5 = false;540 scope.artisan1 = false;541 scope.artisan2 = false;542 scope.artisan3 = true;543 scope.artisan4 = false;544 scope.artisan5 = false;545 scope.artisan6 = false;546 scope.artisan7 = false;547 scope.artisan8 = true;548 scope.expert1 = true;549 scope.expert2 = true;550 scope.expert3 = true;551 scope.expert4 = true;552 scope.expert5 = true;553 scope.expert6 = true;554 scope.expert7 = true;555 scope.expert8 = true;556 scope.professional1 = true;557 scope.professional2 = false;558 scope.professional3 = false;559 scope.professional4 = false;560 scope.professional5 = false;561 scope.professional6 = false;562 scope.professional7 = false;563 scope.professional8 = false;564 scope.professional9 = false;565 scope.professional10 = false;566 scope.professional11 = false;567 scope.professional12 = false;568 scope.master1 = false;569 scope.master2 = false;570 scope.master3 = false;571 scope.master4 = false;572 scope.master5 = false;573 scope.master6 = false;574 scope.master7 = false;575 scope.master8 = false;576 scope.master9 = false;577 scope.master10 = false;578 scope.master11 = false;579 scope.master12 = false;580 scope.master13 = false;581 var expectedTestMetricsScore = 3;582 scope.saveAssessments();583 var testMetrics = rootScope.assessmentsQaMaM['test-metrics'];584 expect(testMetrics['score']).toEqual(expectedTestMetricsScore);585 });586 it('should save the score for test metrics as 4 if traveller question is answered as no and all the artisan questions answered as yes' +587 'and the expert questions are answered as yes and the professional questions are answered as yes', function(){588 scope.traveller1 = false;589 scope.traveller2 = false;590 scope.traveller3 = false;591 scope.traveller4 = false;592 scope.traveller5 = false;593 scope.artisan1 = false;594 scope.artisan2 = false;595 scope.artisan3 = true;596 scope.artisan4 = false;597 scope.artisan5 = false;598 scope.artisan6 = false;599 scope.artisan7 = false;600 scope.artisan8 = true;601 scope.expert1 = true;602 scope.expert2 = true;603 scope.expert3 = true;604 scope.expert4 = true;605 scope.expert5 = true;606 scope.expert6 = true;607 scope.expert7 = true;608 scope.expert8 = true;609 scope.professional1 = true;610 scope.professional2 = true;611 scope.professional3 = true;612 scope.professional4 = true;613 scope.professional5 = true;614 scope.professional6 = true;615 scope.professional7 = true;616 scope.professional8 = true;617 scope.professional9 = true;618 scope.professional10 = true;619 scope.professional11 = true;620 scope.professional12 = true;621 scope.master1 = true;622 scope.master2 = false;623 scope.master3 = false;624 scope.master4 = false;625 scope.master5 = false;626 scope.master6 = false;627 scope.master7 = false;628 scope.master8 = false;629 scope.master9 = false;630 scope.master10 = false;631 scope.master11 = false;632 scope.master12 = false;633 scope.master13 = false;634 var expectedTestMetricsScore = 4;635 scope.saveAssessments();636 var testMetrics = rootScope.assessmentsQaMaM['test-metrics'];637 expect(testMetrics['score']).toEqual(expectedTestMetricsScore);638 });639 it('should save the score for test metrics as 5 if traveller question is answered as no and all the artisan questions answered as yes' +640 'and the expert questions are answered as yes, professional questions answered as yes and the master questions are answered as yes', function(){641 scope.traveller1 = false;642 scope.traveller2 = false;643 scope.traveller3 = false;644 scope.traveller4 = false;645 scope.traveller5 = false;646 scope.artisan1 = false;647 scope.artisan2 = false;648 scope.artisan3 = true;649 scope.artisan4 = false;650 scope.artisan5 = false;651 scope.artisan6 = false;652 scope.artisan7 = false;653 scope.artisan8 = true;654 scope.expert1 = true;655 scope.expert2 = true;656 scope.expert3 = true;657 scope.expert4 = true;658 scope.expert5 = true;659 scope.expert6 = true;660 scope.expert7 = true;661 scope.expert8 = true;662 scope.professional1 = true;663 scope.professional2 = true;664 scope.professional3 = true;665 scope.professional4 = true;666 scope.professional5 = true;667 scope.professional6 = true;668 scope.professional7 = true;669 scope.professional8 = true;670 scope.professional9 = true;671 scope.professional10 = true;672 scope.professional11 = true;673 scope.professional12 = true;674 scope.master1 = true;675 scope.master2 = true;676 scope.master3 = true;677 scope.master4 = true;678 scope.master5 = true;679 scope.master6 = true;680 scope.master7 = true;681 scope.master8 = true;682 scope.master9 = true;683 scope.master10 = true;684 scope.master11 = true;685 scope.master12 = true;686 scope.master13 = true;687 var expectedTestMetricsScore = 5;688 scope.saveAssessments();689 var testMetrics = rootScope.assessmentsQaMaM['test-metrics'];690 expect(testMetrics['score']).toEqual(expectedTestMetricsScore);691 });692 describe('#getClass', function () {693 it('should get the warning class for parameters that are false', function(){694 var warningClass = 'bg-warning';695 expect(scope.getClass(false)).toEqual(warningClass);696 });697 it('should get the info class for parameters that are false', function(){698 var infoClass = 'bg-info';699 expect(scope.getClass(true)).toEqual(infoClass);700 });701 });702 });...
spec.js
Source:spec.js
1describe("isNumeric", function() {23 it("should have a global isNumeric object", function() {4 expect(isNumeric).toBeDefined();5 });67 it("should return true for integers", function() {8 expect(isNumeric(1)).toBeTruthy();9 expect(isNumeric(-1)).toBeTruthy();10 expect(isNumeric(0)).toBeTruthy();11 expect(isNumeric("1")).toBeTruthy();12 expect(isNumeric("-1")).toBeTruthy();13 expect(isNumeric("0")).toBeTruthy();14 expect(isNumeric("1.")).toBeTruthy();15 });1617 it("should return true for min / max numbers", function() {18 expect(isNumeric(Number.MAX_VALUE)).toBeTruthy();19 expect(isNumeric(Number.MIN_VALUE)).toBeTruthy();20 });2122 it("should return true for octals", function() {23 expect(isNumeric(0144)).toBeTruthy();24 expect(isNumeric("0144")).toBeTruthy();25 });2627 it("should return true for hexadecimals", function() {28 expect(isNumeric(0xFF)).toBeTruthy();29 expect(isNumeric("0xFF")).toBeTruthy();30 });3132 it("should return true for floating-points", function() {33 expect(isNumeric(1.1)).toBeTruthy();34 expect(isNumeric(0.1)).toBeTruthy();35 expect(isNumeric(-1.1)).toBeTruthy();36 expect(isNumeric(-0.1)).toBeTruthy();37 expect(isNumeric("1.1")).toBeTruthy();38 expect(isNumeric("0.1")).toBeTruthy();39 expect(isNumeric("-1.1")).toBeTruthy();40 expect(isNumeric("-0.1")).toBeTruthy();41 expect(isNumeric(".1")).toBeTruthy();42 });4344 it("should return true for exponentials", function() {45 expect(isNumeric(3e5)).toBeTruthy();46 expect(isNumeric(123e-2)).toBeTruthy();47 expect(isNumeric("3e5")).toBeTruthy();48 expect(isNumeric("123e-2")).toBeTruthy();49 });5051 it("should return true with decimal commas", function() {52 expect(isNumeric(1,1)).toBeTruthy();53 expect(isNumeric("1,1")).toBeTruthy();54 });5556 it("should return true for multiple commas", function() {57 expect(isNumeric("1,1,1")).toBeTruthy();58 expect(isNumeric("1,1,1,1")).toBeTruthy();59 });6061 it("should return false for empty / whitespace", function() {62 expect(isNumeric()).toBeFalsy();63 expect(isNumeric("")).toBeFalsy();64 expect(isNumeric(" ")).toBeFalsy();65 expect(isNumeric(" ")).toBeFalsy();66 expect(isNumeric("\t")).toBeFalsy();67 expect(isNumeric("\n")).toBeFalsy();68 expect(isNumeric("\r")).toBeFalsy();69 });7071 it("should return false for strings that aren't numeric", function() {72 expect(isNumeric("ABC")).toBeFalsy();73 expect(isNumeric("abc")).toBeFalsy();74 expect(isNumeric("ABC123")).toBeFalsy();75 expect(isNumeric("abc123")).toBeFalsy();76 expect(isNumeric("123ABC")).toBeFalsy();77 expect(isNumeric("123abc")).toBeFalsy();78 });7980 it("should return false for multiple decimals", function() {81 expect(isNumeric("1.1.1")).toBeFalsy();82 expect(isNumeric("1.1.1.1")).toBeFalsy();83 });8485 it("should return false for booleans", function() {86 expect(isNumeric(true)).toBeFalsy();87 expect(isNumeric(false)).toBeFalsy();88 });8990 it("should return false for null / undefined / NaN", function() {91 expect(isNumeric(null)).toBeFalsy();92 expect(isNumeric(undefined)).toBeFalsy();93 expect(isNumeric(NaN)).toBeFalsy();94 });9596 it("should return false for infinity and Number._INFINITY (ironically)", function() {97 expect(isNumeric(Infinity)).toBeFalsy();98 expect(isNumeric(Number.POSITIVE_INFINITY)).toBeFalsy();99 expect(isNumeric(Number.NEGATIVE_INFINITY)).toBeFalsy();100 });101102 it("should return false for dates", function() {103 expect(isNumeric(new Date())).toBeFalsy();104 expect(isNumeric(new Date(2000, 1, 1))).toBeFalsy();105 });106107 it("should return false for arrays", function() {108 expect(isNumeric([])).toBeFalsy();109 expect(isNumeric([1])).toBeFalsy();110 expect(isNumeric([1, 2])).toBeFalsy();111 expect(isNumeric(["a"])).toBeFalsy();112 expect(isNumeric(["a", "b"])).toBeFalsy();113 });114115 it("should return false for empty objects", function() {116 expect(isNumeric({})).toBeFalsy();117 });118119 it("should return false for functions", function() {120 expect(isNumeric(function() { })).toBeFalsy();121 expect(isNumeric(function(a) { })).toBeFalsy();122 expect(isNumeric(function() { return "a"; })).toBeFalsy();123 expect(isNumeric(function() { return 1; })).toBeFalsy();124 });125
...
test_boolean.py
Source:test_boolean.py
1import pytest2from phantom.boolean import Falsy3from phantom.boolean import Truthy4parametrize_truthy = pytest.mark.parametrize("v", (object(), ("a",), 1, True))5parametrize_falsy = pytest.mark.parametrize("v", ((), 0, False))6class TestTruthy:7 @parametrize_truthy8 def test_truthy_value_is_instance(self, v):9 assert isinstance(v, Truthy)10 @parametrize_falsy11 def test_falsy_value_is_not_instance(self, v):12 assert not isinstance(v, Truthy)13 @parametrize_truthy14 def test_instantiation_returns_instance(self, v):15 assert v is Truthy.parse(v)16 @parametrize_falsy17 def test_instantiation_raises_for_falsy_value(self, v):18 with pytest.raises(TypeError):19 Truthy.parse(v)20class TestFalsy:21 @parametrize_falsy22 def test_falsy_value_is_instance(self, v):23 assert isinstance(v, Falsy)24 @parametrize_truthy25 def test_truthy_value_is_not_instance(self, v):26 assert not isinstance(v, Falsy)27 @parametrize_falsy28 def test_instantiation_returns_instance(self, v):29 assert v is Falsy.parse(v)30 @parametrize_truthy31 def test_instantiation_raises_for_truthy_value(self, v):32 with pytest.raises(TypeError):...
truthy_or_falsy.py
Source:truthy_or_falsy.py
2# The function should return a string that reads "The value _____ is ______"3# where the first space is the argument and the second space4# is either truthy or falsy.5#6# truthy_or_falsy(0) => "The value 0 is falsy"7# truthy_or_falsy(5) => "The value 5 is truthy"8# truthy_or_falsy("Hello") => "The value Hello is truthy"9# truthy_or_falsy("") => "The value is falsy"10def truthy_or_falsy(sing_arg):11 if sing_arg:12 return "The value " + str(sing_arg) + " is truthy"13 else:14 return "The value " + str(sing_arg) + " is falsy"15 16print(truthy_or_falsy(0))17print(truthy_or_falsy(5))18print(truthy_or_falsy("Hello"))...
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!!