How to use Environment method in qawolf

Best JavaScript code snippet using qawolf

AudioPlayer.js

Source:AudioPlayer.js Github

copy

Full Screen

1import { AudioPlayer } from "../lib/AudioPlayer.js";2import { Color } from "../lib/Color.js";3class ColorToneEventListenerStub {4 constructor() {5 this.notifiedThatToneSeriesEnded_ = false;6 this.notifiedThatRedToneStarted_ = false;7 this.notifiedThatRedToneEnded_ = false;8 this.notifiedThatYellowToneStarted_ = false;9 this.notifiedThatYellowToneEnded_ = false;10 this.notifiedThatGreenToneStarted_ = false;11 this.notifiedThatGreenToneEnded_ = false;12 this.notifiedThatBlueToneStarted_ = false;13 this.notifiedThatBlueToneEnded_ = false;14 this.notifiedThatCorrectBlueToneStarted_ = false;15 this.notifiedThatCorrectBlueToneEnded_ = false;16 this.notifiedThatIncorrectBlueToneStarted_ = false;17 this.notifiedThatIncorrectBlueToneEnded_ = false;18 }19 notifiedThatIncorrectBlueToneEnded() {20 return this.notifiedThatIncorrectBlueToneEnded_;21 }22 notifyThatIncorrectBlueToneEnded() {23 this.notifiedThatIncorrectBlueToneEnded_ = true;24 }25 notifiedThatIncorrectBlueToneStarted() {26 return this.notifiedThatIncorrectBlueToneStarted_;27 }28 notifyThatIncorrectBlueToneStarted() {29 this.notifiedThatIncorrectBlueToneStarted_ = true;30 }31 notifiedThatCorrectBlueToneEnded() {32 return this.notifiedThatCorrectBlueToneEnded_;33 }34 notifyThatCorrectBlueToneEnded() {35 this.notifiedThatCorrectBlueToneEnded_ = true;36 }37 notifiedThatCorrectBlueToneStarted() {38 return this.notifiedThatCorrectBlueToneStarted_;39 }40 notifyThatCorrectBlueToneStarted() {41 this.notifiedThatCorrectBlueToneStarted_ = true;42 }43 notifiedThatRedToneStarted() {44 return this.notifiedThatRedToneStarted_;45 }46 notifyThatRedToneStarted() {47 this.notifiedThatRedToneStarted_ = true;48 }49 notifiedThatRedToneEnded() {50 return this.notifiedThatRedToneEnded_;51 }52 notifyThatRedToneEnded() {53 this.notifiedThatRedToneEnded_ = true;54 }55 notifiedThatBlueToneStarted() {56 return this.notifiedThatBlueToneStarted_;57 }58 notifyThatBlueToneStarted() {59 this.notifiedThatBlueToneStarted_ = true;60 }61 notifiedThatBlueToneEnded() {62 return this.notifiedThatBlueToneEnded_;63 }64 notifyThatBlueToneEnded() {65 this.notifiedThatBlueToneEnded_ = true;66 }67 notifiedThatGreenToneStarted() {68 return this.notifiedThatGreenToneStarted_;69 }70 notifyThatGreenToneStarted() {71 this.notifiedThatGreenToneStarted_ = true;72 }73 notifiedThatGreenToneEnded() {74 return this.notifiedThatGreenToneEnded_;75 }76 notifyThatGreenToneEnded() {77 this.notifiedThatGreenToneEnded_ = true;78 }79 notifiedThatYellowToneStarted() {80 return this.notifiedThatYellowToneStarted_;81 }82 notifyThatYellowToneStarted() {83 this.notifiedThatYellowToneStarted_ = true;84 }85 notifiedThatYellowToneEnded() {86 return this.notifiedThatYellowToneEnded_;87 }88 notifyThatYellowToneEnded() {89 this.notifiedThatYellowToneEnded_ = true;90 }91 notifiedThatToneSeriesEnded() {92 return this.notifiedThatToneSeriesEnded_;93 }94 notifyThatToneSeriesEnded() {95 this.notifiedThatToneSeriesEnded_ = true;96 }97}98function scheduledTone(startTimeSeconds, stopTimeSeconds, frequencyHz) {99 return {100 startTimeSeconds,101 stopTimeSeconds,102 frequencyHz,103 };104}105class AudioEnvironmentStub {106 constructor() {107 this.scheduledTones_ = [];108 this.scheduledToneOnEnds = [];109 }110 setCurrentTimeSeconds(x) {111 this.currentTimeSeconds_ = x;112 }113 currentTimeSeconds() {114 return this.currentTimeSeconds_;115 }116 scheduleTone(startTimeSeconds, stopTimeSeconds, frequencyHz, onEnd) {117 this.scheduledTones_.push(118 scheduledTone(startTimeSeconds, stopTimeSeconds, frequencyHz)119 );120 this.scheduledToneOnEnds.push(onEnd);121 }122 scheduledTones() {123 return this.scheduledTones_;124 }125 endNextTone() {126 const onEnd = this.scheduledToneOnEnds.shift();127 onEnd();128 }129}130function play(131 player,132 toneColors,133 toneDurationMilliseconds,134 toneOffsetToNextOnsetDurationMilliseconds135) {136 player.play(137 toneColors,138 toneDurationMilliseconds,139 toneOffsetToNextOnsetDurationMilliseconds140 );141}142function playCorrectRedTone(player, toneDurationMilliseconds) {143 player.playCorrectRedTone(toneDurationMilliseconds);144}145function playCorrectBlueTone(player, toneDurationMilliseconds) {146 player.playCorrectBlueTone(toneDurationMilliseconds);147}148function playCorrectGreenTone(player, toneDurationMilliseconds) {149 player.playCorrectGreenTone(toneDurationMilliseconds);150}151function playCorrectYellowTone(player, toneDurationMilliseconds) {152 player.playCorrectYellowTone(toneDurationMilliseconds);153}154function playIncorrectBlueTone(player, toneDurationMilliseconds) {155 player.playIncorrectBlueTone(toneDurationMilliseconds);156}157function setPlayDelaySeconds(player, x) {158 player.setPlayDelaySeconds(x);159}160function setToneSeriesDelaySeconds(player, x) {161 player.setToneSeriesDelaySeconds(x);162}163function setCurrentTimeSeconds(audioEnvironment, x) {164 audioEnvironment.setCurrentTimeSeconds(x);165}166function scheduledTones(audioEnvironment) {167 return audioEnvironment.scheduledTones();168}169function endNextTone(audioEnvironment) {170 audioEnvironment.endNextTone();171}172function notifiedThatRedToneStarted(listener) {173 return listener.notifiedThatRedToneStarted();174}175function notifiedThatRedToneEnded(listener) {176 return listener.notifiedThatRedToneEnded();177}178function notifiedThatGreenToneStarted(listener) {179 return listener.notifiedThatGreenToneStarted();180}181function notifiedThatGreenToneEnded(listener) {182 return listener.notifiedThatGreenToneEnded();183}184function notifiedThatYellowToneStarted(listener) {185 return listener.notifiedThatYellowToneStarted();186}187function notifiedThatYellowToneEnded(listener) {188 return listener.notifiedThatYellowToneEnded();189}190function notifiedThatBlueToneStarted(listener) {191 return listener.notifiedThatBlueToneStarted();192}193function notifiedThatBlueToneEnded(listener) {194 return listener.notifiedThatBlueToneEnded();195}196function notifiedThatToneSeriesEnded(listener) {197 return listener.notifiedThatToneSeriesEnded();198}199function notifiedThatCorrectBlueToneStarted(listener) {200 return listener.notifiedThatCorrectBlueToneStarted();201}202function notifiedThatCorrectBlueToneEnded(listener) {203 return listener.notifiedThatCorrectBlueToneEnded();204}205function notifiedThatIncorrectBlueToneStarted(listener) {206 return listener.notifiedThatIncorrectBlueToneStarted();207}208function notifiedThatIncorrectBlueToneEnded(listener) {209 return listener.notifiedThatIncorrectBlueToneEnded();210}211function playing(player) {212 return player.playing();213}214function expectTrue(b) {215 expect(b).toBeTrue();216}217function expectFalse(b) {218 expect(b).toBeFalse();219}220function expectScheduledTonesContains(221 audioEnvironment,222 startTimeSeconds,223 stopTimeSeconds,224 frequencyHz225) {226 expect(scheduledTones(audioEnvironment)).toContain(227 scheduledTone(startTimeSeconds, stopTimeSeconds, frequencyHz)228 );229}230describe("AudioPlayer", () => {231 beforeEach(function () {232 this.audioEnvironment = new AudioEnvironmentStub();233 this.audioEnvironment = new AudioEnvironmentStub();234 this.player = new AudioPlayer(235 this.audioEnvironment,236 new Map([237 [Color.blue, 1],238 [Color.red, 2],239 [Color.yellow, 3],240 [Color.green, 4],241 ]),242 9243 );244 });245 it("should schedule silent tone before playing correct red tone", function () {246 setPlayDelaySeconds(this.player, 5);247 setCurrentTimeSeconds(this.audioEnvironment, 6);248 playCorrectRedTone(this.player, 7000);249 expectScheduledTonesContains(this.audioEnvironment, 6, 5 + 6, 0);250 });251 it("should schedule correct red tone", function () {252 setPlayDelaySeconds(this.player, 5);253 setCurrentTimeSeconds(this.audioEnvironment, 6);254 playCorrectRedTone(this.player, 7000);255 expectScheduledTonesContains(this.audioEnvironment, 5 + 6, 5 + 6 + 7, 2);256 });257 it("should schedule silent tone before playing correct yellow tone", function () {258 setPlayDelaySeconds(this.player, 5);259 setCurrentTimeSeconds(this.audioEnvironment, 6);260 playCorrectYellowTone(this.player, 7000);261 expectScheduledTonesContains(this.audioEnvironment, 6, 5 + 6, 0);262 });263 it("should schedule correct yellow tone", function () {264 setPlayDelaySeconds(this.player, 5);265 setCurrentTimeSeconds(this.audioEnvironment, 6);266 playCorrectYellowTone(this.player, 7000);267 expectScheduledTonesContains(this.audioEnvironment, 5 + 6, 5 + 6 + 7, 3);268 });269 it("should schedule silent tone before playing correct green tone", function () {270 setPlayDelaySeconds(this.player, 5);271 setCurrentTimeSeconds(this.audioEnvironment, 6);272 playCorrectGreenTone(this.player, 7000);273 expectScheduledTonesContains(this.audioEnvironment, 6, 5 + 6, 0);274 });275 it("should schedule correct green tone", function () {276 setPlayDelaySeconds(this.player, 5);277 setCurrentTimeSeconds(this.audioEnvironment, 6);278 playCorrectGreenTone(this.player, 7000);279 expectScheduledTonesContains(this.audioEnvironment, 5 + 6, 5 + 6 + 7, 4);280 });281 it("should schedule silent tone before playing correct blue tone", function () {282 setPlayDelaySeconds(this.player, 5);283 setCurrentTimeSeconds(this.audioEnvironment, 6);284 playCorrectBlueTone(this.player, 7000);285 expectScheduledTonesContains(this.audioEnvironment, 6, 5 + 6, 0);286 });287 it("should schedule correct blue tone", function () {288 setPlayDelaySeconds(this.player, 5);289 setCurrentTimeSeconds(this.audioEnvironment, 6);290 playCorrectBlueTone(this.player, 7000);291 expectScheduledTonesContains(this.audioEnvironment, 5 + 6, 5 + 6 + 7, 1);292 });293 it("should schedule silent tone before playing incorrect blue tone", function () {294 setPlayDelaySeconds(this.player, 5);295 setCurrentTimeSeconds(this.audioEnvironment, 6);296 playIncorrectBlueTone(this.player, 7000);297 expectScheduledTonesContains(this.audioEnvironment, 6, 5 + 6, 0);298 });299 it("should schedule incorrect blue tone", function () {300 setPlayDelaySeconds(this.player, 5);301 setCurrentTimeSeconds(this.audioEnvironment, 6);302 playIncorrectBlueTone(this.player, 7000);303 expectScheduledTonesContains(this.audioEnvironment, 5 + 6, 5 + 6 + 7, 9);304 });305 it("should schedule silent tone before first color tone on play", function () {306 setPlayDelaySeconds(this.player, 5);307 setCurrentTimeSeconds(this.audioEnvironment, 6);308 setToneSeriesDelaySeconds(this.player, 9);309 play(310 this.player,311 [Color.red, Color.green, Color.blue, Color.yellow],312 7000,313 8000314 );315 expectScheduledTonesContains(this.audioEnvironment, 6, 5 + 6 + 9, 0);316 });317 it("should schedule first color tone on play", function () {318 setPlayDelaySeconds(this.player, 5);319 setCurrentTimeSeconds(this.audioEnvironment, 6);320 play(321 this.player,322 [Color.red, Color.green, Color.blue, Color.yellow],323 7000,324 8000325 );326 expectScheduledTonesContains(this.audioEnvironment, 5 + 6, 5 + 6 + 7, 2);327 });328 it("should schedule second silent tone after first completes", function () {329 setPlayDelaySeconds(this.player, 5);330 setCurrentTimeSeconds(this.audioEnvironment, 6);331 play(332 this.player,333 [Color.red, Color.green, Color.blue, Color.yellow],334 7000,335 8000336 );337 endNextTone(this.audioEnvironment);338 expectScheduledTonesContains(339 this.audioEnvironment,340 5 + 6 + 7,341 5 + 6 + 7 + 8,342 0343 );344 });345 it("should schedule second color tone after first completes", function () {346 setPlayDelaySeconds(this.player, 5);347 setCurrentTimeSeconds(this.audioEnvironment, 6);348 play(349 this.player,350 [Color.red, Color.green, Color.blue, Color.yellow],351 7000,352 8000353 );354 endNextTone(this.audioEnvironment);355 endNextTone(this.audioEnvironment);356 expectScheduledTonesContains(357 this.audioEnvironment,358 5 + 6 + 7 + 8,359 5 + 6 + 7 + 8 + 7,360 4361 );362 });363 it("should not schedule additional color tone after last completes", function () {364 setPlayDelaySeconds(this.player, 5);365 setCurrentTimeSeconds(this.audioEnvironment, 6);366 play(367 this.player,368 [Color.red, Color.green, Color.blue, Color.yellow],369 7000,370 8000371 );372 endNextTone(this.audioEnvironment);373 endNextTone(this.audioEnvironment);374 endNextTone(this.audioEnvironment);375 endNextTone(this.audioEnvironment);376 endNextTone(this.audioEnvironment);377 endNextTone(this.audioEnvironment);378 endNextTone(this.audioEnvironment);379 endNextTone(this.audioEnvironment);380 expect(scheduledTones(this.audioEnvironment).length).toEqual(9);381 });382 it("should not schedule additional silent tone after last completes", function () {383 setPlayDelaySeconds(this.player, 5);384 setCurrentTimeSeconds(this.audioEnvironment, 6);385 play(386 this.player,387 [Color.red, Color.green, Color.blue, Color.yellow],388 7000,389 8000390 );391 endNextTone(this.audioEnvironment);392 endNextTone(this.audioEnvironment);393 endNextTone(this.audioEnvironment);394 endNextTone(this.audioEnvironment);395 endNextTone(this.audioEnvironment);396 endNextTone(this.audioEnvironment);397 endNextTone(this.audioEnvironment);398 endNextTone(this.audioEnvironment);399 endNextTone(this.audioEnvironment);400 expect(scheduledTones(this.audioEnvironment).length).toEqual(9);401 });402 it("should notify when first color tone starts", function () {403 const listener = new ColorToneEventListenerStub();404 this.player.subscribe(listener);405 setPlayDelaySeconds(this.player, 5);406 setCurrentTimeSeconds(this.audioEnvironment, 6);407 play(408 this.player,409 [Color.red, Color.green, Color.blue, Color.yellow],410 7000,411 8000412 );413 expectFalse(notifiedThatRedToneStarted(listener));414 endNextTone(this.audioEnvironment);415 expectTrue(notifiedThatRedToneStarted(listener));416 });417 it("should notify when second color tone starts", function () {418 const listener = new ColorToneEventListenerStub();419 this.player.subscribe(listener);420 setPlayDelaySeconds(this.player, 5);421 setCurrentTimeSeconds(this.audioEnvironment, 6);422 play(423 this.player,424 [Color.red, Color.green, Color.blue, Color.yellow],425 7000,426 8000427 );428 endNextTone(this.audioEnvironment);429 endNextTone(this.audioEnvironment);430 expectFalse(notifiedThatGreenToneStarted(listener));431 endNextTone(this.audioEnvironment);432 expectTrue(notifiedThatGreenToneStarted(listener));433 });434 it("should notify when third color tone starts", function () {435 const listener = new ColorToneEventListenerStub();436 this.player.subscribe(listener);437 setPlayDelaySeconds(this.player, 5);438 setCurrentTimeSeconds(this.audioEnvironment, 6);439 play(440 this.player,441 [Color.red, Color.green, Color.blue, Color.yellow],442 7000,443 8000444 );445 endNextTone(this.audioEnvironment);446 endNextTone(this.audioEnvironment);447 endNextTone(this.audioEnvironment);448 endNextTone(this.audioEnvironment);449 expectFalse(notifiedThatBlueToneStarted(listener));450 endNextTone(this.audioEnvironment);451 expectTrue(notifiedThatBlueToneStarted(listener));452 });453 it("should notify when fourth color tone starts", function () {454 const listener = new ColorToneEventListenerStub();455 this.player.subscribe(listener);456 setPlayDelaySeconds(this.player, 5);457 setCurrentTimeSeconds(this.audioEnvironment, 6);458 play(459 this.player,460 [Color.red, Color.green, Color.blue, Color.yellow],461 7000,462 8000463 );464 endNextTone(this.audioEnvironment);465 endNextTone(this.audioEnvironment);466 endNextTone(this.audioEnvironment);467 endNextTone(this.audioEnvironment);468 endNextTone(this.audioEnvironment);469 endNextTone(this.audioEnvironment);470 expectFalse(notifiedThatYellowToneStarted(listener));471 endNextTone(this.audioEnvironment);472 expectTrue(notifiedThatYellowToneStarted(listener));473 });474 it("should notify when first color tone ends", function () {475 const listener = new ColorToneEventListenerStub();476 this.player.subscribe(listener);477 setPlayDelaySeconds(this.player, 5);478 setCurrentTimeSeconds(this.audioEnvironment, 6);479 play(480 this.player,481 [Color.red, Color.green, Color.blue, Color.yellow],482 7000,483 8000484 );485 endNextTone(this.audioEnvironment);486 expectFalse(notifiedThatRedToneEnded(listener));487 endNextTone(this.audioEnvironment);488 expectTrue(notifiedThatRedToneEnded(listener));489 });490 it("should notify when second color tone ends", function () {491 const listener = new ColorToneEventListenerStub();492 this.player.subscribe(listener);493 setPlayDelaySeconds(this.player, 5);494 setCurrentTimeSeconds(this.audioEnvironment, 6);495 play(496 this.player,497 [Color.red, Color.green, Color.blue, Color.yellow],498 7000,499 8000500 );501 endNextTone(this.audioEnvironment);502 endNextTone(this.audioEnvironment);503 endNextTone(this.audioEnvironment);504 expectFalse(notifiedThatGreenToneEnded(listener));505 endNextTone(this.audioEnvironment);506 expectTrue(notifiedThatGreenToneEnded(listener));507 });508 it("should notify when third color tone ends", function () {509 const listener = new ColorToneEventListenerStub();510 this.player.subscribe(listener);511 setPlayDelaySeconds(this.player, 5);512 setCurrentTimeSeconds(this.audioEnvironment, 6);513 play(514 this.player,515 [Color.red, Color.green, Color.blue, Color.yellow],516 7000,517 8000518 );519 endNextTone(this.audioEnvironment);520 endNextTone(this.audioEnvironment);521 endNextTone(this.audioEnvironment);522 endNextTone(this.audioEnvironment);523 endNextTone(this.audioEnvironment);524 expectFalse(notifiedThatBlueToneEnded(listener));525 endNextTone(this.audioEnvironment);526 expectTrue(notifiedThatBlueToneEnded(listener));527 });528 it("should notify when fourth color tone ends", function () {529 const listener = new ColorToneEventListenerStub();530 this.player.subscribe(listener);531 setPlayDelaySeconds(this.player, 5);532 setCurrentTimeSeconds(this.audioEnvironment, 6);533 play(534 this.player,535 [Color.red, Color.green, Color.blue, Color.yellow],536 7000,537 8000538 );539 endNextTone(this.audioEnvironment);540 endNextTone(this.audioEnvironment);541 endNextTone(this.audioEnvironment);542 endNextTone(this.audioEnvironment);543 endNextTone(this.audioEnvironment);544 endNextTone(this.audioEnvironment);545 endNextTone(this.audioEnvironment);546 expectFalse(notifiedThatYellowToneEnded(listener));547 endNextTone(this.audioEnvironment);548 expectTrue(notifiedThatYellowToneEnded(listener));549 });550 it("should notify when playing ends", function () {551 const listener = new ColorToneEventListenerStub();552 this.player.subscribe(listener);553 setPlayDelaySeconds(this.player, 5);554 setCurrentTimeSeconds(this.audioEnvironment, 6);555 play(556 this.player,557 [Color.red, Color.green, Color.blue, Color.yellow],558 7000,559 8000560 );561 endNextTone(this.audioEnvironment);562 endNextTone(this.audioEnvironment);563 endNextTone(this.audioEnvironment);564 endNextTone(this.audioEnvironment);565 endNextTone(this.audioEnvironment);566 endNextTone(this.audioEnvironment);567 endNextTone(this.audioEnvironment);568 endNextTone(this.audioEnvironment);569 expectFalse(notifiedThatToneSeriesEnded(listener));570 endNextTone(this.audioEnvironment);571 expectTrue(notifiedThatToneSeriesEnded(listener));572 });573 it("is playing until playing ends", function () {574 expectFalse(playing(this.player));575 play(576 this.player,577 [Color.red, Color.green, Color.blue, Color.yellow],578 7000,579 8000580 );581 expectTrue(playing(this.player));582 endNextTone(this.audioEnvironment);583 endNextTone(this.audioEnvironment);584 endNextTone(this.audioEnvironment);585 endNextTone(this.audioEnvironment);586 endNextTone(this.audioEnvironment);587 endNextTone(this.audioEnvironment);588 endNextTone(this.audioEnvironment);589 endNextTone(this.audioEnvironment);590 expectTrue(playing(this.player));591 endNextTone(this.audioEnvironment);592 expectFalse(playing(this.player));593 });594 it("should notify when correct color tone starts", function () {595 const listener = new ColorToneEventListenerStub();596 this.player.subscribe(listener);597 playCorrectBlueTone(this.player, 7000);598 expectFalse(notifiedThatCorrectBlueToneStarted(listener));599 endNextTone(this.audioEnvironment);600 expectTrue(notifiedThatCorrectBlueToneStarted(listener));601 });602 it("should notify when correct color tone ends", function () {603 const listener = new ColorToneEventListenerStub();604 this.player.subscribe(listener);605 playCorrectBlueTone(this.player, 7000);606 endNextTone(this.audioEnvironment);607 expectFalse(notifiedThatCorrectBlueToneEnded(listener));608 endNextTone(this.audioEnvironment);609 expectTrue(notifiedThatCorrectBlueToneEnded(listener));610 });611 it("should notify when incorrect color tone starts", function () {612 const listener = new ColorToneEventListenerStub();613 this.player.subscribe(listener);614 playIncorrectBlueTone(this.player, 7000);615 expectFalse(notifiedThatIncorrectBlueToneStarted(listener));616 endNextTone(this.audioEnvironment);617 expectTrue(notifiedThatIncorrectBlueToneStarted(listener));618 });619 it("should notify when incorrect color tone ends", function () {620 const listener = new ColorToneEventListenerStub();621 this.player.subscribe(listener);622 playIncorrectBlueTone(this.player, 7000);623 endNextTone(this.audioEnvironment);624 expectFalse(notifiedThatIncorrectBlueToneEnded(listener));625 endNextTone(this.audioEnvironment);626 expectTrue(notifiedThatIncorrectBlueToneEnded(listener));627 });...

Full Screen

Full Screen

environmentVariableCollection.test.ts

Source:environmentVariableCollection.test.ts Github

copy

Full Screen

...88 A: 'foo',89 B: 'bar',90 C: 'baz'91 };92 merged.applyToProcessEnvironment(env);93 deepStrictEqual(env, {94 A: 'a',95 B: 'barb',96 C: 'cbaz'97 });98 });99 test('should apply the collection to environment entries with no values', () => {100 const merged = new MergedEnvironmentVariableCollection(new Map([101 ['ext', {102 map: deserializeEnvironmentVariableCollection([103 ['A', { value: 'a', type: EnvironmentVariableMutatorType.Replace }],104 ['B', { value: 'b', type: EnvironmentVariableMutatorType.Append }],105 ['C', { value: 'c', type: EnvironmentVariableMutatorType.Prepend }]106 ])107 }]108 ]));109 const env: IProcessEnvironment = {};110 merged.applyToProcessEnvironment(env);111 deepStrictEqual(env, {112 A: 'a',113 B: 'b',114 C: 'c'115 });116 });117 test('should apply to variable case insensitively on Windows only', () => {118 const merged = new MergedEnvironmentVariableCollection(new Map([119 ['ext', {120 map: deserializeEnvironmentVariableCollection([121 ['a', { value: 'a', type: EnvironmentVariableMutatorType.Replace }],122 ['b', { value: 'b', type: EnvironmentVariableMutatorType.Append }],123 ['c', { value: 'c', type: EnvironmentVariableMutatorType.Prepend }]124 ])125 }]126 ]));127 const env: IProcessEnvironment = {128 A: 'A',129 B: 'B',130 C: 'C'131 };132 merged.applyToProcessEnvironment(env);133 if (isWindows) {134 deepStrictEqual(env, {135 A: 'a',136 B: 'Bb',137 C: 'cC'138 });139 } else {140 deepStrictEqual(env, {141 a: 'a',142 A: 'A',143 b: 'b',144 B: 'B',145 c: 'c',146 C: 'C'...

Full Screen

Full Screen

environmentVariableService.test.ts

Source:environmentVariableService.test.ts Github

copy

Full Screen

...96 ]]97 ]);98 // Verify the entries get applied to the environment as expected99 const env: IProcessEnvironment = { A: 'foo' };100 environmentVariableService.mergedCollection.applyToProcessEnvironment(env);101 deepStrictEqual(env, { A: 'a2:a3:a1' });102 });103 });...

Full Screen

Full Screen

environment.test.ts

Source:environment.test.ts Github

copy

Full Screen

...47 db.Environment.push(subEnvironment);48 db.Environment.push(dummySubEnv);49 jest.clearAllMocks();50 });51 describe('promptEnvironment()', () => {52 it('should return null if ci', () => {53 expect(promptEnvironment(db, true, workspace._id)).resolves.toBeNull();54 });55 it('should return null if no environments exist', () => {56 db.Environment = [];57 expect(promptEnvironment(db, false, workspace._id)).resolves.toBeNull();58 });59 it('should throw error if base env for workspace not found', () => {60 expect(promptEnvironment(db, false, 'workspace-not-found')).rejects.toThrowError();61 });62 it('should throw error if multiple base env for workspace found', () => {63 db.Environment.push({ ...environment });64 expect(promptEnvironment(db, false, workspace._id)).rejects.toThrowError();65 });66 it('should load sub environment after prompt result', async () => {67 enquirer.__mockPromptRun('environment - env_env_123456');68 expect(promptEnvironment(db, false, workspace._id)).resolves.toBe(subEnvironment);69 });70 it('should match snapshot of autocomplete config', async () => {71 await promptEnvironment(db, false, workspace._id);72 expect(enquirer.__constructorMock.mock.calls[0][0]).toMatchSnapshot();73 });74 });75 describe('loadEnvironment()', () => {76 it('should return null if no environments exist', () => {77 db.Environment = [];78 expect(loadEnvironment(db, workspace._id, environment._id)).toBeNull();79 });80 it('should throw error if base env for workspace not found', () => {81 expect(() => loadEnvironment(db, 'workspace-not-found', environment._id)).toThrowError();82 });83 it('should throw error if multiple base env for workspace found', () => {84 db.Environment.push({ ...environment });85 expect(() => loadEnvironment(db, workspace._id, environment._id)).toThrowError();86 });87 it.each([generateIdIsh(subEnvironment), subEnvironment._id, subEnvironment.name])(88 'should return the sub environment if matched with id: %s',89 () => {90 expect(loadEnvironment(db, workspace._id, subEnvironment._id)).toBe(subEnvironment);91 },92 );93 it('should return the base environment if env id not specified', () => {94 expect(loadEnvironment(db, workspace._id)).toBe(environment);95 });96 it('should return the base environment if no sub envs exist', () => {97 db.Environment = [environment];98 expect(loadEnvironment(db, workspace._id)).toBe(environment);99 });100 it('should throw error sub env not found', () => {101 db.Environment = [environment];102 expect(() => loadEnvironment(db, workspace._id, subEnvironment._id)).toThrowError();103 });104 });...

Full Screen

Full Screen

getRuntimeEnvironment.test.js

Source:getRuntimeEnvironment.test.js Github

copy

Full Screen

...42 // eslint-disable-next-line mocha/no-setup-in-describe43 environmentProperties = config.get('unitTests.cliOutputValidationAttributes.getEnvironment');44 it('returns a valid runtimeEnvironment object definition via the CLI', function () {45 // Retrieve the runtime environment mimicking the CLI46 runtimeEnvironmentDef = getRuntimeEnvironment(commandObj.opts());47 // Validate that the runtime environment returned a valid object48 assert.isTrue(typeof runtimeEnvironmentDef === 'object' && runtimeEnvironmentDef !== null, `-- expected a not-null object and encountered a ${typeof runtimeEnvironmentDef}`);49 });50 it('contains the expected collection of environment properties via the CLI', function () {51 // Retrieve the runtime environment mimicking the CLI52 runtimeEnvironmentDef = getRuntimeEnvironment(commandObj.opts());53 // Loop over the collection of expected properties and validate they exist54 assert.hasAnyKeys(runtimeEnvironmentDef, environmentProperties);55 });56 it('returns a valid runtimeEnvironment object definition via the API', function () {57 // Retrieve the runtime environment mimicking the API58 runtimeEnvironmentDef = getRuntimeEnvironment();59 // Validate that the runtime environment returned a valid object60 assert.isTrue(typeof runtimeEnvironmentDef === 'object' && runtimeEnvironmentDef !== null, `-- expected a not-null object and encountered a ${typeof runtimeEnvironmentDef}`);61 });62 it('contains the expected collection of environment properties via the API', function () {63 // Retrieve the runtime environment mimicking the API64 runtimeEnvironmentDef = getRuntimeEnvironment();65 // Loop over the collection of expected properties and validate they exist66 _propertyValidator(runtimeEnvironmentDef, environmentProperties);67 });...

Full Screen

Full Screen

createRuntimeEnvironment.test.js

Source:createRuntimeEnvironment.test.js Github

copy

Full Screen

...14 it('returns an environment configuration informed by the baseline environment', function () {15 // Initialize local variables16 let output;17 // Capture the expected test result18 output = createRuntimeEnvironment(baselineEnvironment);19 // Validate that the generated environment is returned as an object20 assert.isTrue(validate.isObject(output), `-- testing ${JSON.stringify(output)} is an object `);21 });22 it('includes all baseline environment properties that map to CLI options', function () {23 // Initialize local variables24 let output,25 cliOptions,26 cliOptionProperties,27 environmentProperties,28 thisCliOption,29 thisEnvironmentProperty,30 cliOptionCount,31 environmentPropertyCount;32 // Retrieve the collection of cliOptions33 cliOptions = config.util.toObject(config.get('cliOptions'));34 // Default the counts used to validate our test35 cliOptionCount = 0;36 environmentPropertyCount = 0;37 // Capture the expected test result38 output = createRuntimeEnvironment(baselineEnvironment);39 // Build out the key-lists used to validate environment counts40 cliOptionProperties = Object.keys(cliOptions);41 environmentProperties = Object.keys(output);42 // Count the number of cliOption properties found in the generated environment43 for (let propIndex = 0; propIndex < cliOptionProperties.length; propIndex++) {44 // Create a reference to the current CLI property45 thisCliOption = cliOptionProperties[propIndex];46 // Validate that the current environment property was found in the baseline environment47 if (output.hasOwnProperty(cliOptions[thisCliOption].envProperty)) { cliOptionCount += 1; }48 }49 // Count the number of environments properties found in the CLI option definition50 for (let envPropIndex = 0; envPropIndex < environmentProperties.length; envPropIndex++) {51 // Create a reference to the current environment property52 thisEnvironmentProperty = environmentProperties[envPropIndex];...

Full Screen

Full Screen

controller.ts

Source:controller.ts Github

copy

Full Screen

...19 return this.environmentService.getEnvironmentsList(projectId);20 }21 @Authorized()22 @Post("/projects/:project_id/environments/actions/create")23 async createEnvironment(24 @CurrentUser({ required: true }) userInfo,25 @Param("project_id") projectId: number,26 @Body() body: Omit<ICreateEnvironmentPayload, "projectId" | "userId">,27 ) {28 const environmentInsertRecord = await this.environmentService.createEnvironment({29 ...body,30 projectId,31 userId: userInfo.user_id,32 });33 const environmentRecord = await this.environmentService.getEnvironment(environmentInsertRecord.insertId);34 return {35 status: "Successful",36 ...environmentRecord,37 };38 }39 @Authorized()40 @Post("/projects/:project_id/environments/:environment_id/actions/delete")41 async deleteEnvironment(@Param("environment_id") environmentId: number) {42 if (!environmentId) throw new BadRequestError("Invalid environment id provided");43 await this.monitoringService.deleteAllMonitoringsOfEnvironment(environmentId);44 await this.environmentService.deleteEnvironment(environmentId);45 return {46 status: "Successful",47 };48 }49 @Authorized()50 @Post("/projects/:project_id/environments/:environment_id/actions/update")51 async updateEnvironment(@Param("environment_id") environmentId: number, @Body() payload: IUpdateEnvironmentPayload) {52 if (!environmentId) throw new BadRequestError("Invalid environment id provided");53 await this.environmentService.updateEnvironment(payload, environmentId);54 const environmentRecord = await this.environmentService.getEnvironment(environmentId);55 return {56 status: "Successful",57 ...environmentRecord,58 };59 }60}...

Full Screen

Full Screen

api.constant.ts

Source:api.constant.ts Github

copy

Full Screen

1import { environment } from '@env/environment';2export const API_URL = {3 RETAILER_PROFILES_URL:4 environment.api.ROOT +5 environment.api.OPERATION_ROOT +6 environment.api.RETAILER_PROFILES_ROOT,7 API_RETAILER_INVENTORY_URL:8 environment.api.ROOT +9 environment.api.OPERATION_ROOT +10 'RetailerInventories/',11 API_RETAILER_ORDERS_URL:12 environment.api.ROOT + environment.api.OPERATION_ROOT + 'Orders/',13 PROFILE_CREATION_URL:14 environment.api.ROOT +15 environment.api.OPERATION_ROOT +16 'CreationProfiles/',17 API_RETAILER_SELLOUT_URL: environment.api.ROOT + 'SelloutHistories/',18 // LOCATION19 PROVINCES_URL: environment.api.ROOT + 'provinces',20 DISTRICTS_URL: environment.api.ROOT + 'districts',21 WARDS_URL: environment.api.ROOT + 'wards',22 API_ACCOUNT_URL:23 environment.api.ROOT + environment.api.OPERATION_ROOT + 'Users/',24 API_ACCOUNTTYPE_FILTER_URL:25 environment.api.ROOT +26 environment.api.OPERATION_ROOT +27 'UserTypes/OperationPortal/UserTypes',28 // TREE29 TREEDATA_BY_MANU_URL:30 environment.api.ROOT +31 environment.api.OPERATION_ROOT +32 'Hierarchies/Manufacturers',33 TREEDATA_MANU_URL:34 environment.api.ROOT +35 environment.api.OPERATION_ROOT +36 'Hierarchies/',37 //38 TREEDATA_BY_PH_URL:39 environment.api.ROOT +40 environment.api.OPERATION_ROOT +41 'HierarchiesPH/ph1',42 TREEDATA_PH_URL:43 environment.api.ROOT +44 environment.api.OPERATION_ROOT +45 'HierarchiesPH/',46 PRODUCT_IMAGEDATA_URL:47 environment.api.ROOT +48 environment.api.OPERATION_ROOT +49 'ProductFiles/',50 MANU_IMAGEDATA_URL:51 environment.api.ROOT +52 environment.api.OPERATION_ROOT +53 'ManufacturerImages/',54 BRAND_IMAGEDATA_URL:55 environment.api.ROOT +56 environment.api.OPERATION_ROOT +57 'BrandImages/',58 SALESHUB_IMAGEDATA_URL:59 environment.api.ROOT + environment.api.OPERATION_ROOT + 'PHImages/',60 BANNER_IMAGEDATA_URL:61 environment.api.ROOT + environment.api.OPERATION_ROOT + 'Banners/',62 // OPERATION DISTRIBUTOR63 OPERATION_DISTRIBUTOR_URL:64 environment.api.ROOT +65 environment.api.OPERATION_ROOT +66 'DistributorProfiles/',67 //68 OPERATION_MANUFACTURER_URL:69 environment.api.ROOT +70 environment.api.OPERATION_ROOT +71 'ManufacturerProfiles/',72 OPERATION_MANUFACTURER_FILTER_URL:73 environment.api.ROOT +74 environment.api.OPERATION_ROOT +75 'Manufacturers/',76 OPERATION_SEARCH_ORDER_URL:77 environment.api.ROOT +78 environment.api.OPERATION_ROOT +79 environment.api.ORDERS_ROOT +80 'OrderNumber/',81 OPERATION_ORDER_STATUS_URL:82 environment.api.ROOT +83 environment.api.OPERATION_ROOT +84 environment.api.ORDERS_ROOT +85 'OrderStatus'...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Environment } = require("qawolf");2const env = new Environment();3const browser = await env.launch();4const context = await browser.newContext();5const page = await context.newPage();6await page.click("input[name=q]");7await page.fill("input[name=q]", "qawolf");8await page.press("input[name=q]", "Enter");9await page.click("text=QAWolf: QA Automation for Web Apps");10await page.close();11await context.close();12await browser.close();13await env.stop();14const { launch } = require("qawolf");15const browser = await launch();16const context = await browser.newContext();17const page = await context.newPage();18await page.click("input[name=q]");19await page.fill("input[name=q]", "qawolf");20await page.press("input[name=q]", "Enter");21await page.click("text=QAWolf: QA Automation for Web Apps");22await page.close();23await context.close();24await browser.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Environment } = require("qawolf");2const env = new Environment();3const browser = await env.launchBrowser();4const context = await env.newContext(browser);5const page = await env.newPage(context);6await page.fill("#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input", "qawolf");7await page.click("#tsf > div:nth-child(2) > div > div.FPdoLc.VlcLAe > center > input[type='submit']:nth-child(1)");8await page.waitForNavigation();9await page.screenshot({ path: `screenshot.png` });10await browser.close();11await context.setExtraHTTPHeaders({ "Accept-Language": "en-GB" });

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Environment } = require('qawolf');2const qawolf = require('qawolf');3const { Browser, Page } = require('qawolf');4const puppeteer = require('puppeteer');5const chai = require('chai');6const chaiAsPromised = require('chai-as-promised');7const mocha = require('mocha');8const fs = require('fs');9const path = require('path');10const process = require('process');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Environment } = require("qawolf");2const env = await Environment.start({3 launchOptions: {4 },5});6const browser = env.browser();7const page = env.page();8await page.click("input[name='q']");9await page.type("input[name='q']", "qawolf");10await page.press("input[name='q']", "Enter");11await env.close();12await env.stop();13const browser = await launch();14const page = await browser.newPage();15await page.click("input[name='q']");16await page.type("input[name='q']", "qawolf");17await page.press("input[name='q']", "Enter");18await browser.close();19const browser = await launch();20const page = await browser.newPage();21await page.click("input[name='q']");22await page.type("input[name='q']", "qawolf");23await page.press("input[name='q']", "Enter");24await browser.close();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Environment } = require('qawolf');2const env = new Environment();3env.set('name', 'John');4env.set('age', 30);5env.set('isEmployed', true);6env.set('skills', ['JavaScript', 'Python', 'Java']);7env.set('address', {8});9const { Environment } = require('qawolf');10const env = new Environment();11const name = env.get('name');12const age = env.get('age');13const isEmployed = env.get('isEmployed');14const skills = env.get('skills');15const address = env.get('address');16const { Environment } = require('qawolf');17const env = new Environment();18const name = env.get('name');19const age = env.get('age');20const isEmployed = env.get('isEmployed');21const skills = env.get('skills');22const address = env.get('address');23const { Environment } = require('qawolf');24const env = new Environment();25const name = env.get('name');26const age = env.get('age');27const isEmployed = env.get('isEmployed');28const skills = env.get('skills');29const address = env.get('address');30const { Environment } = require('qawolf');31const env = new Environment();32const name = env.get('name');33const age = env.get('age');34const isEmployed = env.get('isEmployed');35const skills = env.get('skills');36const address = env.get('address');37const { Environment } = require('qawolf');38const env = new Environment();39const name = env.get('name');40const age = env.get('age');41const isEmployed = env.get('isEmployed');42const skills = env.get('skills');43const address = env.get('address');44const { Environment } = require('qawolf

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