How to use util.test method in chai

Best JavaScript code snippet using chai

test.move.js

Source:test.move.js Github

copy

Full Screen

1var World = require('../world');2var Config = require('../../shared/config.js');3var Util = require('../test_util.js');4exports.testMoveTorpedo01 = function(test) {5 var map = [6 "+-----------------------------------------------+",7 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",8 "|---+-------------------------------------------|",9 "|0 | . . . . . . . . . . . . . . |",10 "|1 | . . . . . . . . . . . . . . |",11 "|2 | . . . . . . . . . . . . . . |",12 "|3 | . . . . . . . . . . . . . . |",13 "|4 | . . . . . . . . . . . . . . |",14 "|5 | . . . . . . . . . . . . . . |",15 "|6 | . . . . . . . 1v . 1t . . . . |",16 "|7 | . . . . . . . . . . . . . . |",17 "|8 | . . . . . . . . . . . . . . |",18 "|9 | . . . . . . . . . . . . . . |",19 "|10 | . . . . . . . . . . . . . . |",20 "|11 | . . . . . . . . . . . . . . |",21 "|12 | . . . . . . . . . . . . . . |",22 "|13 | . . . . . . . . . . . . . . |",23 "+-----------------------------------------------+"24 ];25 var world = new World();26 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);27 Util.testWhereCanMove(test, world, [7, 6], [[7, 4], [7, 5], [7, 7], [7, 8], [8, 6], [5, 6], [6, 6]]);28 Util.testWhereCanMove(test, world, [9, 6], [[8, 6]]);29 test.done();30};31exports.testMoveTorpedo02 = function(test) {32 var map = [33 "+-----------------------------------------------+",34 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",35 "|---+-------------------------------------------|",36 "|0 | . . . . . . . . . . . . . . |",37 "|1 | . . . . . . . . . . . . . . |",38 "|2 | . . . . . . . . . . . . . . |",39 "|3 | . . . . . . . . . . . . . . |",40 "|4 | . . . . . . . . . . . . . . |",41 "|5 | . . . . . . . . . . . . . . |",42 "|6 | . . . . . . . 1v 1t . . . . . |",43 "|7 | . . . . . . . . . . . . . . |",44 "|8 | . . . . . . . . . . . . . . |",45 "|9 | . . . . . . . . . . . . . . |",46 "|10 | . . . . . . . . . . . . . . |",47 "|11 | . . . . . . . . . . . . . . |",48 "|12 | . . . . . . . . . . . . . . |",49 "|13 | . . . . . . . . . . . . . . |",50 "+-----------------------------------------------+"51 ];52 var world = new World();53 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);54 Util.testWhereCanMove(test, world, [7, 6], [[7, 4], [7, 5], [7, 7], [7, 8], [5, 6], [6, 6]]);55 Util.testWhereCanMove(test, world, [8, 6], [[9, 6], [8, 5], [8, 7]]);56 test.done();57};58exports.testMoveTorpedo03 = function(test) {59 var map = [60 "+-----------------------------------------------+",61 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",62 "|---+-------------------------------------------|",63 "|0 | . . . . . . . . . . . . . . |",64 "|1 | . . . . . . . . . . . . . . |",65 "|2 | . . . . . . . . . . . . . . |",66 "|3 | . . . . . . . . . . . . . . |",67 "|4 | . . . . . . . . . . . . . . |",68 "|5 | . . . . . . . . 1t . . . . . |",69 "|6 | . . . . . . . 1v . . . . . . |",70 "|7 | . . . . . . . . . . . . . . |",71 "|8 | . . . . . . . . . . . . . . |",72 "|9 | . . . . . . . . . . . . . . |",73 "|10 | . . . . . . . . . . . . . . |",74 "|11 | . . . . . . . . . . . . . . |",75 "|12 | . . . . . . . . . . . . . . |",76 "|13 | . . . . . . . . . . . . . . |",77 "+-----------------------------------------------+"78 ];79 var world = new World();80 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);81 Util.testWhereCanMove(test, world, [7, 6], [[7, 4], [7, 5], [7, 7], [7, 8], [5, 6], [6, 6], [8, 6], [9, 6]]);82 Util.testWhereCanMove(test, world, [8, 5], [[8, 6], [8, 7], [7, 5], [6, 5]]);83 test.done();84};85exports.testMoveTorpedo04 = function(test) {86 var map = [87 "+-----------------------------------------------+",88 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",89 "|---+-------------------------------------------|",90 "|0 | . . . . . . . . . . . . . . |",91 "|1 | . . . . . . . . . . . . . . |",92 "|2 | . . . . . . . . . . . . . . |",93 "|3 | . . . . . . . . . . . . . . |",94 "|4 | . . . . . . . . . . . . . . |",95 "|5 | . . . . . . . . 1t . . . . . |",96 "|6 | . . . . . . . 1v 1t . . . . . |",97 "|7 | . . . . . . . . . . . . . . |",98 "|8 | . . . . . . . . . . . . . . |",99 "|9 | . . . . . . . . . . . . . . |",100 "|10 | . . . . . . . . . . . . . . |",101 "|11 | . . . . . . . . . . . . . . |",102 "|12 | . . . . . . . . . . . . . . |",103 "|13 | . . . . . . . . . . . . . . |",104 "+-----------------------------------------------+"105 ];106 var world = new World();107 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);108 Util.testWhereCanMove(test, world, [7, 6], [[7, 4], [7, 5], [7, 7], [7, 8], [5, 6], [6, 6]]);109 Util.testWhereCanMove(test, world, [8, 5], [[7, 5], [6, 5]]);110 Util.testWhereCanMove(test, world, [8, 6], [[9, 6], [8, 7]]);111 test.done();112};113exports.testMoveTorpedo05 = function(test) {114 var map = [115 "+-----------------------------------------------+",116 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",117 "|---+-------------------------------------------|",118 "|0 | . . . . . . . . . . . . . . |",119 "|1 | . . . . . . . . . . . . . . |",120 "|2 | . . . . . . . . . . . . . . |",121 "|3 | . . . . . . . . . . . . . . |",122 "|4 | . . . . . . . . . . . . . . |",123 "|5 | . . . . . . . . . . . . . . |",124 "|6 | . . . . . . . 2v 1t . . . . . |",125 "|7 | . . . . . . . . . . . . . . |",126 "|8 | . . . . . . . . . . . . . . |",127 "|9 | . . . . . . . . . . . . . . |",128 "|10 | . . . . . . . . . . . . . . |",129 "|11 | . . . . . . . . . . . . . . |",130 "|12 | . . . . . . . . . . . . . . |",131 "|13 | . . . . . . . . . . . . . . |",132 "+-----------------------------------------------+"133 ];134 var world = new World();135 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);136 Util.testWhereCanMove(test, world, [8, 6], []);137 test.done();138};139exports.testMoveVedette = function(test) {140 var map = [141 "+-----------------------------------------------+",142 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",143 "|---+-------------------------------------------|",144 "|0 | . . . . . . . . . . . . . . |",145 "|1 | . . . . . . . . . . . . . . |",146 "|2 | . . . . . . . . . . . . . . |",147 "|3 | . . . . . . . . . . . . . . |",148 "|4 | . . . . . . . . . . . . . . |",149 "|5 | . . . . . . . . . . . . . . |",150 "|6 | . . . . . . . 1v 1p . . . . . |",151 "|7 | . . . . . . . . . . . . . . |",152 "|8 | . . . . . . . . . . . . . . |",153 "|9 | . . . . . . . . . . . . . . |",154 "|10 | . . . . . . . . . . . . . . |",155 "|11 | . . . . . . . . . . . . . . |",156 "|12 | . . . . . . . . . . . . . . |",157 "|13 | . . . . . . . . . . . . . . |",158 "+-----------------------------------------------+"159 ];160 var world = new World();161 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);162 Util.testWhereCanMove(test, world, [7, 6], [[7, 4], [7, 5], [7, 7], [7, 8], [5, 6], [6, 6]]);163 Util.testWhereCanMove(test, world, [8, 6], [[9, 6], [8, 5], [8, 7]]);164 test.done();165};166exports.testMoveMine01 = function(test) {167 var map = [168 "+-----------------------------------------------+",169 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",170 "|---+-------------------------------------------|",171 "|0 | . . . . . . . . . . . . . . |",172 "|1 | . . . . . . . . . . . . . . |",173 "|2 | . . . . . . . . . . . . . . |",174 "|3 | . . . . . . . . . . . . . . |",175 "|4 | . . . . . . . . . . . . . . |",176 "|5 | . . . . . . . . . . . . . . |",177 "|6 | . . . . . . . 1d 1m . . . . . |",178 "|7 | . . . . . . . . . . . . . . |",179 "|8 | . . . . . . . . . . . . . . |",180 "|9 | . . . . . . . . . . . . . . |",181 "|10 | . . . . . . . . . . . . . . |",182 "|11 | . . . . . . . . . . . . . . |",183 "|12 | . . . . . . . . . . . . . . |",184 "|13 | . . . . . . . . . . . . . . |",185 "+-----------------------------------------------+"186 ];187 var world = new World();188 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);189 Util.testWhereCanMove(test, world, [7, 6], [[7, 5], [7, 7], [6, 6]]);190 Util.testWhereCanMove(test, world, [8, 6], [[8, 5], [8, 7]]);191 test.done();192};193exports.testMoveMine02 = function(test) {194 var map = [195 "+-----------------------------------------------+",196 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",197 "|---+-------------------------------------------|",198 "|0 | . . . . . . . . . . . . . . |",199 "|1 | . . . . . . . . . . . . . . |",200 "|2 | . . . . . . . . . . . . . . |",201 "|3 | . . . . . . . . . . . . . . |",202 "|4 | . . . . . . . . . . . . . . |",203 "|5 | . . . . . . . . 1m . . . . . |",204 "|6 | . . . . . . . 1d . . . . . . |",205 "|7 | . . . . . . . . . . . . . . |",206 "|8 | . . . . . . . . . . . . . . |",207 "|9 | . . . . . . . . . . . . . . |",208 "|10 | . . . . . . . . . . . . . . |",209 "|11 | . . . . . . . . . . . . . . |",210 "|12 | . . . . . . . . . . . . . . |",211 "|13 | . . . . . . . . . . . . . . |",212 "+-----------------------------------------------+"213 ];214 var world = new World();215 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);216 Util.testWhereCanMove(test, world, [7, 6], [[7, 5], [7, 7], [6, 6], [8, 6]]);217 Util.testWhereCanMove(test, world, [8, 5], [[7, 5], [8, 6]]);218 test.done();219};220exports.testMoveMine03 = function(test) {221 var map = [222 "+-----------------------------------------------+",223 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",224 "|---+-------------------------------------------|",225 "|0 | . . . . . . . . . . . . . . |",226 "|1 | . . . . . . . . . . . . . . |",227 "|2 | . . . . . . . . . . . . . . |",228 "|3 | . . . . . . . . . . . . . . |",229 "|4 | . . . . . . . . . . . . . . |",230 "|5 | . . . . . . 1m . 1m . . . . . |",231 "|6 | . . . . . . 1m 1d . . . . . . |",232 "|7 | . . . . . . 1m . . . . . . . |",233 "|8 | . . . . . . . . . . . . . . |",234 "|9 | . . . . . . . . . . . . . . |",235 "|10 | . . . . . . . . . . . . . . |",236 "|11 | . . . . . . . . . . . . . . |",237 "|12 | . . . . . . . . . . . . . . |",238 "|13 | . . . . . . . . . . . . . . |",239 "+-----------------------------------------------+"240 ];241 var world = new World();242 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);243 Util.testWhereCanMove(test, world, [7, 6], [[7, 5], [7, 7], [8, 6]]);244 Util.testWhereCanMove(test, world, [8, 5], [[7, 5], [8, 6]]);245 Util.testWhereCanMove(test, world, [6, 5], [[7, 5]]);246 Util.testWhereCanMove(test, world, [6, 6], []);247 Util.testWhereCanMove(test, world, [6, 7], [[7, 7]]);248 test.done();249};250exports.testMoveMine04 = function(test) {251 var map = [252 "+-----------------------------------------------+",253 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",254 "|---+-------------------------------------------|",255 "|0 | . . . . . . . . . . . . . . |",256 "|1 | . . . . . . . . . . . . . . |",257 "|2 | . . . . . . . . . . . . . . |",258 "|3 | . . . . . . . . . . . . . . |",259 "|4 | . . . . . . . . . . . . . . |",260 "|5 | . . . . . . . . 1m . . . . . |",261 "|6 | . . . . . . . 2d . . . . . . |",262 "|7 | . . . . . . . . . . . . . . |",263 "|8 | . . . . . . . . . . . . . . |",264 "|9 | . . . . . . . . . . . . . . |",265 "|10 | . . . . . . . . . . . . . . |",266 "|11 | . . . . . . . . . . . . . . |",267 "|12 | . . . . . . . . . . . . . . |",268 "|13 | . . . . . . . . . . . . . . |",269 "+-----------------------------------------------+"270 ];271 var world = new World();272 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);273 Util.testWhereCanMove(test, world, [8, 5], []);274 test.done();275};276exports.testMoveCommon = function(test) {277 var map = [278 "+-----------------------------------------------+",279 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",280 "|---+-------------------------------------------|",281 "|0 | . . . . . . . . . . . . . 1p |",282 "|1 | . . . . . . . . . . . . . . |",283 "|2 | . . . 1B . . . 1aC. . 1p . . . |",284 "|3 | . . 1v . . . . . . . . . . . |",285 "|4 | . . . . . . . . . . . . . . |",286 "|5 | . 1cS. . 1r . . 1fM. . 1b . . . |",287 "|6 | . . . . . . . . . . . . . . |",288 "|7 | . . . . . . . . . . . . . . |",289 "|8 | . 1mS. . 1fS. . 1m . . 1c . . . |",290 "|9 | . . . . . . . . . . . . . . |",291 "|10 | . . . . . . . . . . . . . . |",292 "|11 | . 1s . . 1aB. . 1a . . 1t . . . |",293 "|12 | . . . . . . . . . . . . 1v . |",294 "|13 | . . . . . . . . . . . . . . |",295 "+-----------------------------------------------+"296 ];297 var world = new World();298 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);299 Util.testWhereCanMove(test, world, [2, 3], [[2, 1], [2, 2], [0, 3], [1, 3], [3, 3], [4, 3], [2, 4], [2, 5]]);300 Util.testWhereCanMove(test, world, [3, 2], []);301 Util.testWhereCanMove(test, world, [1, 5], [[1, 4], [1, 6], [0, 5], [2, 5]]);302 Util.testWhereCanMove(test, world, [1, 8], [[1, 7], [1, 9], [0, 8], [2, 8]]);303 Util.testWhereCanMove(test, world, [1, 11], [[1, 10], [1, 12], [0, 11], [2, 11]]);304 Util.testWhereCanMove(test, world, [4, 5], [[4, 4], [4, 6], [3, 5], [5, 5]]);305 Util.testWhereCanMove(test, world, [4, 8], [[4, 7], [4, 9], [3, 8], [5, 8]]);306 Util.testWhereCanMove(test, world, [4, 11], [[4, 10], [4, 12], [3, 11], [5, 11]]);307 Util.testWhereCanMove(test, world, [7, 2], [[7, 1], [7, 3], [6, 2], [8, 2]]);308 Util.testWhereCanMove(test, world, [7, 5], []);309 Util.testWhereCanMove(test, world, [7, 8], []);310 Util.testWhereCanMove(test, world, [7, 11], []);311 Util.testWhereCanMove(test, world, [10, 2], [[10, 1], [10, 3], [9, 2], [11, 2]]);312 Util.testWhereCanMove(test, world, [10, 5], [[10, 4], [10, 6], [9, 5], [11, 5]]);313 Util.testWhereCanMove(test, world, [10, 8], [[10, 7], [10, 9], [9, 8], [11, 8]]);314 Util.testWhereCanMove(test, world, [10, 11], []);315 Util.testWhereCanMove(test, world, [12, 12], [[12, 11], [12, 10], [12, 13], [10, 12], [11, 12], [13, 12]]);316 Util.testWhereCanMove(test, world, [13, 0], [[12, 0], [13, 1]]);317 test.done();318};319exports.testMoveAirplane01 = function(test) {320 var map = [321 "+-----------------------------------------------+",322 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",323 "|---+-------------------------------------------|",324 "|0 | . . . . . . . . . . . . . . |",325 "|1 | . . . . . . . . . . . . . . |",326 "|2 | . . . . . . . . . . . . . . |",327 "|3 | . . . . . . . . . . . . . . |",328 "|4 | . . . . . . . . . . . . . . |",329 "|5 | . . . . . . . . . . . . . . |",330 "|6 | . . . . . . . 1aC1a . . . . . |",331 "|7 | . . . . . . . . . . . . . . |",332 "|8 | . . . . . . . . . . . . . . |",333 "|9 | . . . . . . . . . . . . . . |",334 "|10 | . . . . . . . . . . . . . . |",335 "|11 | . . . . . . . . . . . . . . |",336 "|12 | . . . . . . . . . . . . . . |",337 "|13 | . . . . . . . . . . . . . . |",338 "+-----------------------------------------------+"339 ];340 var world = new World();341 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);342 Util.testWhereCanMove(test, world, [7, 6], [[7, 5], [7, 7], [6, 6]]);343 Util.testWhereCanMove(test, world, [8, 6], [[8, 5], [8, 7]]);344 test.done();345};346exports.testMoveAirplane02 = function(test) {347 var map = [348 "+-----------------------------------------------+",349 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",350 "|---+-------------------------------------------|",351 "|0 | . . . . . . . . . . . . . . |",352 "|1 | . . . . . . . . . . . . . . |",353 "|2 | . . . . . . . . . . . . . . |",354 "|3 | . . . . . . . . . . . . . . |",355 "|4 | . . . . . . . . . . . . . . |",356 "|5 | . . . . . . . . 1a . . . . . |",357 "|6 | . . . . . . . 1aC. . . . . . |",358 "|7 | . . . . . . . . . . . . . . |",359 "|8 | . . . . . . . . . . . . . . |",360 "|9 | . . . . . . . . . . . . . . |",361 "|10 | . . . . . . . . . . . . . . |",362 "|11 | . . . . . . . . . . . . . . |",363 "|12 | . . . . . . . . . . . . . . |",364 "|13 | . . . . . . . . . . . . . . |",365 "+-----------------------------------------------+"366 ];367 var world = new World();368 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);369 Util.testWhereCanMove(test, world, [7, 6], [[7, 5], [7, 7], [6, 6], [8, 6]]);370 Util.testWhereCanMove(test, world, [8, 5], [[7, 5], [8, 6]]);371 test.done();372};373exports.testMoveAirplane03 = function(test) {374 var map = [375 "+-----------------------------------------------+",376 "| | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 |",377 "|---+-------------------------------------------|",378 "|0 | . . . . . . . . . . . . . . |",379 "|1 | . . . . . . . . . . . . . . |",380 "|2 | . . . . . . . . . . . . . . |",381 "|3 | . . . . . . . . . . . . . . |",382 "|4 | . . . . . . . . . . . . . . |",383 "|5 | . . . . . . . . 1a . . . . . |",384 "|6 | . . . . . . . 2aC. . . . . . |",385 "|7 | . . . . . . . . . . . . . . |",386 "|8 | . . . . . . . . . . . . . . |",387 "|9 | . . . . . . . . . . . . . . |",388 "|10 | . . . . . . . . . . . . . . |",389 "|11 | . . . . . . . . . . . . . . |",390 "|12 | . . . . . . . . . . . . . . |",391 "|13 | . . . . . . . . . . . . . . |",392 "+-----------------------------------------------+"393 ];394 var world = new World();395 Util.setupWorld(test, world, map, world.players[0].id, Config.MOVE_PHASE);396 Util.testWhereCanMove(test, world, [8, 5], []);397 test.done();...

Full Screen

Full Screen

HtmlUtilTest.js

Source:HtmlUtilTest.js Github

copy

Full Screen

1function HtmlUtilTest(name) {2 TestCase.call(this,name);3}4HtmlUtilTest.prototype = new TestCase();5HtmlUtilTest.prototype.setUp = function() {6 element1 = {id:"id1", parentNode:{}};7 window.setTimeout = function (func, time) {8 func.call();9 }10}11HtmlUtilTest.prototype.testFlashEffectShouldHighlightElementBackgroundColorThenChangeItBack = function() {12 var previousColor = "#000000";13 var highlightColor = "yellow";14 var colorsChanged = [];15 elementGetStyle = function(element, styleAttribut) {16 return previousColor;17 }18 elementSetStyle = function(element, style) {19 colorsChanged.push(style["backgroundColor"]);20 };21 22 highlight(element1);23 this.assertArrayEquals([highlightColor, previousColor], colorsChanged);24}25HtmlUtilTest.prototype.testgetKeyCodeFromKeySequenceShouldReturnCorrectAsciiCodeOfInputKeySequence = function() {26 this.assertEquals(119, getKeyCodeFromKeySequence("w"));27 this.assertEquals(119, getKeyCodeFromKeySequence("\\119"));28 this.assertEquals(92, getKeyCodeFromKeySequence("\\"));29 this.assertEquals(92, getKeyCodeFromKeySequence("\\92"));30 this.assertEquals(55, getKeyCodeFromKeySequence("7"));31 this.assertEquals(55, getKeyCodeFromKeySequence("\\55"));32}33HtmlUtilTest.prototype.testgetKeyCodeFromKeySequenceShouldBackwardCompatibleFor2Or3DigitAsciiCodes = function() {34 this.assertEquals(119, getKeyCodeFromKeySequence("119"));35 this.assertEquals(92, getKeyCodeFromKeySequence("92"));36 this.assertEquals(55, getKeyCodeFromKeySequence("55"));37}38HtmlUtilTest.prototype.testgetKeyCodeFromKeySequenceShouldFailOnIncorrectInput = function() {39 this.checkKeySequence("");40 this.checkKeySequence("\\a");41 this.checkKeySequence("\\1234");42 this.checkKeySequence("ab");43}44HtmlUtilTest.prototype.testAbsolutify = function() {45 this.assertEquals("http://x/blah", absolutify("http://x/blah", "http://y"));46 47 this.assertEquals("http://y/blah", absolutify("blah", "http://y"));48 49 this.assertEquals("http://y/blah", absolutify("blah", "http://y/foo"));50 this.assertEquals("http://y/foo/blah", absolutify("blah", "http://y/foo/"));51 52 this.assertEquals("http://y/foo/blah", absolutify("blah", "http://y/foo/?bar=1"));53 this.assertEquals("http://y/foo/blah", absolutify("blah", "http://y/foo/?bar=1#baz=2"));54 this.assertEquals("http://y/foo/blah", absolutify("blah", "http://y/foo/#baz=2"));55 56 // windows file urls57 this.assertEquals("file:///c:/foo/blah", absolutify("blah", "c:\\foo\\"));58 this.assertEquals("file:///c:/blah", absolutify("blah", "c:\\foo"));59 this.assertEquals("file:///blah", absolutify("/blah", "c:\\foo\\bar"));60 61}62HtmlUtilTest.prototype.testParseAndReassembleUrl = function() {63 var tests = [64 "http://www.google.com"65 ,"file://localhost/c:/blah"66 ,"file:///c:/blah"67 ,"http://www.google.com/"68 ,"http://www.google.com/foo"69 ,"http://www.google.com/foo?blah=blah/blah"70 ,"http://www.google.com/foo?blah=blah/blah#barbar"71 ,"http://www.google.com/foo#bur?blah"72 ,"http://foo:bar@www.google.com"73 ,"http://foo@www.google.com"74 ,"http://foo:ba%20r@www.google.com"75 ];76 for (var i = 0; i < tests.length; i++) {77 this.assertEquals(tests[i], reassembleLocation(parseUrl(tests[i])));78 }79}80HtmlUtilTest.prototype.checkKeySequence = function(input) {81 try {82 getKeyCodeFromKeySequence(input);83 this.fail("exception expected");84 } catch (e) {85 this.assertTrue(e.isSeleniumError);86 this.assertEquals("invalid keySequence", e.message);87 }88}89HtmlUtilTest.prototype.testString_quoteForXPath = function() {90 this.assertEquals('\'foo\'', 'foo'.quoteForXPath());91 this.assertEquals('\'13" TV\'', '13" TV'.quoteForXPath());92 this.assertEquals("\"'chief' and 'best'\"",93 "'chief' and 'best'".quoteForXPath());94 // the string to quote is '"'foo"'95 this.assertEquals('concat("\'", \'"\', "\'foo", \'"\', "\'")',96 '\'"\'foo"\''.quoteForXPath());97}98 99// assert on absolute equality for simple literals, but content equality only100// for complex values; the object references should be different. Functions101// are copied by reference only (not a true copy).102HtmlUtilTest.prototype.test_clone = function()103{104 var orig, copy;105 orig = 2;106 this.assertEquals(orig, clone(orig));107 orig = 'dolly';108 this.assertEquals(orig, clone(orig));109 110 orig = [2, 6, 0, -439, 10539];111 copy = clone(orig);112 this.assertNotSame(orig, copy);113 this.assertTrue(are_equal(orig, copy));114 orig = {a: 1, b: 'man', 'cd': ['minty', 'fresh'], e: {'taste': [3, 2, 1]}};115 copy = clone(orig);116 this.assertNotSame(orig, copy);117 this.assertTrue(are_equal(orig, copy));118 orig = {};119 copy = clone(orig);120 this.assertNotSame(orig, copy);121 this.assertTrue(are_equal(orig, copy));122 123 orig = function(x) { return x * x; };124 copy = clone(orig);125 this.assertEquals(orig, copy);126}127HtmlUtilTest.prototype.test_keys = function()128{129 var dict = {130 'doe': 'a deer',131 1: 'female deer',132 '_ray': [1, 'drop of golden sun']133 };134 this.assertArrayEqualsIgnoreOrder(['doe', '1', '_ray'], keys(dict));135 this.assertTrue(are_equal([], keys({})));136}137HtmlUtilTest.prototype.test_range = function()138{139 this.assertTrue(are_equal([0, 1, 2, 3, 4] , range( 5)));140 this.assertTrue(are_equal([0, -1, -2, -3, -4] , range(-5)));141 this.assertTrue(are_equal([0, 1, 2, 3, 4] , range( 0, 5)));142 this.assertTrue(are_equal([5, 4, 3, 2, 1] , range( 5, 0)));143 this.assertTrue(are_equal([2, 3, 4] , range( 2, 5)));144 this.assertTrue(are_equal([] , range( 2, 2)));145 this.assertTrue(are_equal([5, 4, 3] , range( 5, 2)));146 this.assertTrue(are_equal([0, -1, -2, -3, -4] , range( 0, -5)));147 this.assertTrue(are_equal([-5, -4, -3, -2, -1], range(-5, 0)));148 this.assertTrue(are_equal([-2, -3, -4] , range(-2, -5)));149 this.assertTrue(are_equal([] , range(-2, -2)));150 this.assertTrue(are_equal([-5, -4, -3] , range(-5, -2)));151 this.assertTrue(are_equal([2, 1, 0, -1] , range( 2, -2)));152 this.assertTrue(are_equal([-2, -1, 0, 1] , range(-2, 2)));153}154HtmlUtilTest.prototype.test_parse_kwargs = function()155{156 this.assertTrue(are_equal({k1: 'v1'}, parse_kwargs('k1=v1')));157 this.assertTrue(are_equal({k1: 'v1', k2: 'v2'}, parse_kwargs('k1=v1, k2=v2')));158 this.assertTrue(are_equal({k1: 'v 1', 'k 2': 'v 2'}, parse_kwargs(' k1 = v 1 , k 2 =v 2 ')));159 this.assertTrue(are_equal({k1: 'v1=v1.1', k2: 'v2=v2.2'}, parse_kwargs('k1=v1=v1.1, k2=v2=v2.2')));160 this.assertTrue(are_equal({k1: 'v1, v1.1', k2: 'v2'}, parse_kwargs('k1=v1, v1.1, k2=v2')));161 162 // destructive - should be handled gracefully163 this.assertTrue(are_equal({k1: 'v1,,'}, parse_kwargs('k1=v1,,')));164 this.assertTrue(are_equal({k1: ''}, parse_kwargs('k1=')));165 this.assertTrue(are_equal({k1: ','}, parse_kwargs('k1=,')));166 this.assertTrue(are_equal({k2: 'v2'}, parse_kwargs(',k2=v2')));167 this.assertTrue(are_equal({'': ''}, parse_kwargs('=')));168 this.assertTrue(are_equal({}, parse_kwargs(',')));169}170HtmlUtilTest.prototype.test_to_kwargs = function()171{172 // round-tripping the unique test_parse_kwargs() cases173 var inputs = [174 {k1: 'v1'},175 {k1: 'v1', k2: 'v2'},176 {k1: 'v 1', 'k 2': 'v 2'},177 {k1: 'v1=v1.1', k2: 'v2=v2.2'},178 {k1: ''},179 {'': ''},180 {}181 ];182 for (var i = 0; i < inputs.length; ++i) {183 this.assertTrue(are_equal(inputs[i], parse_kwargs(to_kwargs(inputs[i]))));184 }185 186 // test the default sorting187 var kwargs1 = {aleph: 'foo', booster: 'kick', tamarind: 42, z: '5'};188 var kwargs2 = {z: '5', aleph: 'foo', tamarind: 42, booster: 'kick'};189 this.assertTrue(are_equal(to_kwargs(kwargs1), to_kwargs(kwargs2)));190 191 // test the explicit sorting192 var argsOrder = [ 'tamarind', 'booster', 'aleph', 'z' ];193 var re = /tamarind.+booster.+aleph.+z/;194 this.assertTrue(re.test(to_kwargs(kwargs1, argsOrder)));195 196 // test the case where an argument in the sort list is missing197 delete(kwargs1['booster']);198 re = /tamarind.+aleph.+z/;199 var result = to_kwargs(kwargs1, argsOrder);200 this.assertTrue(re.test(result));201 this.assertTrue(result.indexOf('booster') == -1);202}203HtmlUtilTest.prototype.assertArrayEquals = function(arr1, arr2) {204 this.assertEquals(arr1.length, arr2.length);205 for (var i = 0; i < arr1.length; i++) {206 this.assertEquals(arr1[i], arr2[i]);207 }208}209HtmlUtilTest.prototype.assertArrayEqualsIgnoreOrder = function(arr1, arr2) {210 this.assertEquals(arr1.length, arr2.length);211 for (var i = 0; i < arr1.length; i++) {212 this.assertArrayContains(arr2, arr1[i]);213 }214}215HtmlUtilTest.prototype.assertArrayContains = function(arr, val) {216 for (var i = 0; i < arr.length; i++) {217 if (arr[i] == val) return;218 }219 this.fail(val);...

Full Screen

Full Screen

class_util___test_test.js

Source:class_util___test_test.js Github

copy

Full Screen

1var class_util___test_test =2[3 [ "getLinesToBeCoveredProvider", "class_util___test_test.html#adf9a53edbbd091afab4f8730ea0629ba", null ],4 [ "methodForTestParseAnnotation", "class_util___test_test.html#a1112af8e17acda40014140dcbef0b0ef", null ],5 [ "methodForTestParseAnnotationThatIsOnlyOneLine", "class_util___test_test.html#a7771fb65b6afc32bd239dd5542c4ec98", null ],6 [ "missingRequirementsProvider", "class_util___test_test.html#af842bf9c0e6248668d5c4775d8814db8", null ],7 [ "requirementsProvider", "class_util___test_test.html#a9072c44e3e8a50196e7410ca9e2e96d2", null ],8 [ "testFunctionParenthesesAreAllowed", "class_util___test_test.html#a7d8b907165e36f5ce52f216e5c13a255", null ],9 [ "testFunctionParenthesesAreAllowedWithWhitespace", "class_util___test_test.html#ab1687c69a017aa600b6c53ac4e1b8f88", null ],10 [ "testGetExpectedException", "class_util___test_test.html#a320a0e49f3b9ec62e59cd2fc37b9fae3", null ],11 [ "testGetExpectedRegExp", "class_util___test_test.html#a28ca45b75d1c97105de6d257d98c3356", null ],12 [ "testGetLinesToBeCovered", "class_util___test_test.html#a4ad98bffd7f7b9ed254ba179fae900a0", null ],13 [ "testGetLinesToBeCovered2", "class_util___test_test.html#ad9a9a8d6ea2071eca4ded40a331d88c6", null ],14 [ "testGetLinesToBeCovered3", "class_util___test_test.html#a93876c16c0bcff06b2a64547df22f9a5", null ],15 [ "testGetLinesToBeCovered4", "class_util___test_test.html#a71cddb671efbce2319bc87bc29138823", null ],16 [ "testGetLinesToBeCoveredSkipsNonExistentMethods", "class_util___test_test.html#acb3e12d61661a0943e2fd3c7081709aa", null ],17 [ "testGetMissingRequirements", "class_util___test_test.html#ac718df477b9fbf20d0d938564c1c9416", null ],18 [ "testGetProvidedDataRegEx", "class_util___test_test.html#ad6e884a3be0e19f95f541dbe1f3119c5", null ],19 [ "testGetRequirements", "class_util___test_test.html#a54ee59b4a21e55206f788755363f2cec", null ],20 [ "testGetRequirementsMergesClassAndMethodDocBlocks", "class_util___test_test.html#ad44a1754603a697e8d3bc60f7e19b3eb", null ],21 [ "testMethodParenthesesAreAllowed", "class_util___test_test.html#a86609abccc13d775736a1444d379cefb", null ],22 [ "testMethodParenthesesAreAllowedWithWhitespace", "class_util___test_test.html#a5eaec32e011272cd50efa8d20d08b0d9", null ],23 [ "testParseAnnotation", "class_util___test_test.html#ae4d1633c1531d814194d8718e790e4d0", null ],24 [ "testParseAnnotationThatIsOnlyOneLine", "class_util___test_test.html#a8dd8ebba0f0dd43ec0d6365ccf58383f", null ],25 [ "testTwoCoversDefaultClassAnnoationsAreNotAllowed", "class_util___test_test.html#a3dbbee3d4a70c20779525bbf522b0f7f", null ]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var util = require('util');2var events = require('events');3function MyEmitter() {4 events.EventEmitter.call(this);5}6util.inherits(MyEmitter, events.EventEmitter);7var myEmitter = new MyEmitter();8myEmitter.on('test', function(a, b) {9 console.log('test event occurred', a, b, this);10});11myEmitter.emit('test', 'a', 'b');12var util = require('util');13var events = require('events');14function MyEmitter() {15 events.EventEmitter.call(this);16}17util.inherits(MyEmitter, events.EventEmitter);18var myEmitter = new MyEmitter();19myEmitter.on('test', function(a, b) {20 console.log('test event occurred', a, b, this);21});22myEmitter.emit('test', 'a', 'b');23var util = require('util');24var events = require('events');25function MyEmitter() {26 events.EventEmitter.call(this);27}28util.inherits(MyEmitter, events.EventEmitter);29var myEmitter = new MyEmitter();30myEmitter.on('test', function(a, b) {31 console.log('test event occurred', a, b, this);32});33myEmitter.emit('test', 'a', 'b');34var util = require('util');35var events = require('events');36function MyEmitter() {37 events.EventEmitter.call(this);38}39util.inherits(MyEmitter, events.EventEmitter);40var myEmitter = new MyEmitter();41myEmitter.on('test', function(a, b) {42 console.log('test event occurred', a, b, this);43});44myEmitter.emit('test', 'a', 'b');45var util = require('util');46var events = require('events');47function MyEmitter() {48 events.EventEmitter.call(this);49}50util.inherits(MyEmitter, events.EventEmitter);51var myEmitter = new MyEmitter();52myEmitter.on('test', function(a, b) {53 console.log('test event occurred', a, b, this);54});55myEmitter.emit('test', 'a', 'b');

Full Screen

Using AI Code Generation

copy

Full Screen

1var util = require('./util.js');2util.test()3 .test()4 .test()5 .test()6 .test();

Full Screen

Using AI Code Generation

copy

Full Screen

1const util = require('./util');2util.test('a').test('b').test('c').test('d').test('e');3const test = (str) => {4 console.log(str);5 return this;6};7module.exports = {8};9const util = require('util');10util.types.isArgumentsObject(function () {11 return arguments;12util.types.isTypedArray(new Int8Array());

Full Screen

Using AI Code Generation

copy

Full Screen

1function test(args, callback) {2 console.log("test function")3 var response = {}4 console.log("chaincodeName: " + chaincodeName)5 console.log("fcn: " + fcn)6 console.log("args: " + args)7 var message = util.test(chaincodeName, fcn, args, callback);8 response.message = message;9}10function queryChaincode(args, callback) {11 console.log("queryChaincode function")12 var response = {}13 console.log("chaincodeName: " + chaincodeName)14 console.log("fcn: " + fcn)15 console.log("args: " + args)16 var message = util.queryChaincode(chaincodeName, fcn, args, callback);17 response.message = message;18}19function invokeChaincode(args, callback) {20 console.log("invokeChaincode function")21 var response = {}22 console.log("chaincodeName: " + chaincodeName)23 console.log("fcn: " + fcn)24 console.log("args: " + args)25 var message = util.invokeChaincode(chaincodeName, fcn, args, callback);26 response.message = message;27}28function getHistory(args, callback) {29 console.log("getHistory function")30 var response = {}31 console.log("key: " + key)32 var message = util.getHistory(key, callback);33 response.message = message;34}35function getQueryResult(args, callback) {36 console.log("getQueryResult function")37 var response = {}38 console.log("query: " + query)

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 chai 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