How to use firstRequest method in wpt

Best JavaScript code snippet using wpt

service.js

Source:service.js Github

copy

Full Screen

1import axios from "axios";2async function studentget(){3 let student= {4 StudentID:'',5 Name:'',6 Surname:'',7 StudentNO:'',8 DepartmantID:'' };9 const apiURL ='http://localhost:62540/api/student';10 await axios.get(apiURL)11 .then(response => (student=response.data[ 0 // Buraya hangi öğrenci ise 12]13 ));14 //console.log(student.Name +" "+ student.Surname);15}16export default studentget;17// GET18// DEPARTMANT GET19/*20import axios from "axios";21async function FirstRequest(){22 let departmant= {23 DepartmantID:'',24 Name:'',25 Student:''};26 const apiURL ='http://localhost:62540/api/departmant';27 await axios.get(apiURL)28 .then(response => (departmant=response.data[ 0 // Buraya hangi departman ise 29]30 ));31 console.log(departmant.Name);32}33export default FirstRequest;34*/35// INSPECTİON GET36/*37import axios from "axios";38async function FirstRequest(){39 let inspection= {40 InspectionID: '',41 LectureID: '',42 StudentID: '',43 Statu: '',44 Lecture: '',45 Student: ''46};47 const apiURL ='http://localhost:62540/api/inspection';48 await axios.get(apiURL)49 .then(response => (inspection=response.data[ 0 // Buraya hangi inspection ise 50]51 ));52 console.log(inspection.StudentID);53}54export default FirstRequest;55*/56// LECTURE GET57/*58import axios from "axios";59async function FirstRequest(){60 let lecture= {61 LectureID: '',62 SubjectID: '',63 Date: '',64 TeacherID: '',65 ClassroomID: '',66 Classroom: '',67 Inspection: '',68 Subject: '',69 Teacher: ''70 };71 const apiURL ='http://localhost:62540/api/lecture';72 await axios.get(apiURL)73 .then(response => (lecture=response.data[ 0 // Buraya hangi lecture ise 74]75 ));76 console.log(lecture.SubjectID);77}78export default FirstRequest;79*/80// STUDENT GET81/*82import axios from "axios";83async function FirstRequest(){84 let student= {85 StudentID:'',86 Name:'',87 Surname:'',88 StudentNO:'',89 DepartmantID:'' };90 const apiURL ='http://localhost:62540/api/student';91 await axios.get(apiURL)92 .then(response => (student=response.data[ 0 // Buraya hangi öğrenci ise 93]94 ));95 console.log(student.Name +" "+ student.Surname);96}97export default FirstRequest;98*/99// STUDENTPASSWORD GET100/*101import axios from "axios";102async function FirstRequest(){103 let studentpassword= {104 StudentPasswordID: '',105 StudentID: '',106 Password: '',107 Student: ''108 };109 const apiURL ='http://localhost:62540/api/studentpassword';110 await axios.get(apiURL)111 .then(response => (studentpassword=response.data[ 0 // Buraya hangi öğrenci ise 112]113 ));114 console.log(studentpassword.Password);115}116export default FirstRequest;117*/118// SUBJECT GET119/*120import axios from "axios";121async function FirstRequest(){122 let subject= {123 SubjectID: '',124 Name: '',125 Lecture: ''126 };127 const apiURL ='http://localhost:62540/api/subject';128 await axios.get(apiURL)129 .then(response => (subject=response.data[ 0 // Buraya hangi departman ise 130] ));131 console.log(subject.Name);132}133export default FirstRequest;134*/135// CLASSROOM GET136/*137import axios from "axios";138async function FirstRequest(){139 let classroom= {140 ClassroomID: '',141 ClassNO: '',142 Lecture: ''143 };144 const apiURL ='http://localhost:62540/api/classroom';145 await axios.get(apiURL)146 .then(response => (classroom=response.data[ 0 // Buraya hangi departman ise 147] ));148 console.log(classroom.ClassNO);149}150export default FirstRequest;151*/152// TEACHER GET153/*154import axios from "axios";155async function FirstRequest(){156 let teacher= {157 TeacherID: '',158 Name: '',159 Surname: '',160 Lecture: '',161 TeacherPassword: ''162};163 const apiURL ='http://localhost:62540/api/teacher';164 await axios.get(apiURL)165 .then(response => (teacher=response.data[ 0 // Buraya hangi departman ise 166] ));167 console.log(teacher.Name);168}169export default FirstRequest;170*/171// GETID172// DEPARTMANT GETID173/*174import axios from "axios";175async function FirstRequest(){176 let departmantid=1; // burası dışarıdan değer alacak177 let departmant= {178 DepartmantID:'',179 Name:'',180 Student:''};181 const apiURL ='http://localhost:62540/api/departmant/'+departmantid;182 await axios.get(apiURL)183 .then(response => (departmant=response.data[0]));184 console.log(departmant);185}186export default FirstRequest;187*/188// INSPECTİON GETID189/*190import axios from "axios";191async function FirstRequest(){192 let inspectionid=4; // burası dışarıdan değer alacak193 let inspection= {194 InspectionID: '',195 LectureID: '',196 StudentID: '',197 Statu: '',198 Lecture: '',199 Student: ''200};201 const apiURL ='http://localhost:62540/api/inspection/'+inspectionid;202 await axios.get(apiURL)203 .then(response => (inspection=response.data[0]204 ));205 console.log(inspection.StudentID);206}207export default FirstRequest;208*/209// LECTURE GETID210/*211import axios from "axios";212async function FirstRequest(){213 let lectureid=1; // burası dışarıdan değer alacak214 let lecture= {215 LectureID: '',216 SubjectID: '',217 Date: '',218 TeacherID: '',219 ClassroomID: '',220 Classroom: '',221 Inspection: '',222 Subject: '',223 Teacher: ''224 };225 const apiURL ='http://localhost:62540/api/lecture/'+lectureid;226 await axios.get(apiURL)227 .then(response => (lecture=response.data[0] ));228 console.log(lecture.SubjectID);229}230export default FirstRequest;231*/232// STUDENT GETID233/*234import axios from "axios";235async function FirstRequest(){236 let studentid=5; // burası dışarıdan değer alacak237 238 let student= {239 StudentID:'',240 Name:'',241 Surname:'',242 StudentNO:'',243 DepartmantID:'' };244 const apiURL ='http://localhost:62540/api/student/'+studentid;245 await axios.get(apiURL)246 .then(response => (student=response.data[0]));247 248 console.log(student.Name +" "+ student.Surname);249}250export default FirstRequest;251*/252// STUDENTPASSWORD GETID253/*254import axios from "axios";255async function FirstRequest(){256 let studentpasswordid=2; // burası dışarıdan değer alacak257 let studentpassword= {258 StudentPasswordID: '',259 StudentID: '',260 Password: '',261 Student: ''262 };263 const apiURL ='http://localhost:62540/api/studentpassword/'+studentpasswordid;264 await axios.get(apiURL)265 .then(response => (studentpassword=response.data[0] ));266 console.log(studentpassword.Password);267}268export default FirstRequest;269*/270// SUBJECT GETID271/*272import axios from "axios";273async function FirstRequest(){274 let subjectid=1; // burası dışarıdan değer alacak275 let subject= {276 SubjectID: '',277 Name: '',278 Lecture: ''279 };280 const apiURL ='http://localhost:62540/api/subject/'+subjectid;281 await axios.get(apiURL)282 .then(response => (subject=response.data[0] ));283 console.log(subject.Name);284}285export default FirstRequest;286*/287// CLASSROOM GETID288/*289import axios from "axios";290async function FirstRequest(){291 let classroomid=1; // burası dışarıdan değer alacak292 let classroom= {293 ClassroomID: '',294 ClassNO: '',295 Lecture: ''296 };297 const apiURL ='http://localhost:62540/api/classroom/'+classroomid;298 await axios.get(apiURL)299 .then(response => (classroom=response.data[0] ));300 console.log(classroom.ClassNO);301}302export default FirstRequest;303*/304// TEACHER GETID305/*306import axios from "axios";307async function FirstRequest(){308 let teacherid=1;309 let teacher= {310 TeacherID: '',311 Name: '',312 Surname: '',313 Lecture: '',314 TeacherPassword: ''315};316 const apiURL ='http://localhost:62540/api/teacher/'+teacherid;317 await axios.get(apiURL)318 .then(response => (teacher=response.data[0] ));319 console.log(teacher.Name);320}321export default FirstRequest;322*/323// PUT324// DEPARTMANT PUT325/*326import axios from "axios";327async function FirstRequest(){328 let departmantid=1; // burası dışarıdan değer alacak329 let departmant= {330 DepartmantID:departmantid,331 Name:'Biyo Mühendisliği',332 Student:5};333 const apiURL ='http://localhost:62540/api/departmantupdate/'+departmantid;334 await axios.put(apiURL,departmant)335 .then(response => console.log(response.data.updatedAt));336}337export default FirstRequest;338*/339// INSPECTİON PUT OLMUYOR340/***/341// LECTURE PUT342/*343import axios from "axios"; 344async function FirstRequest(){345 let lectureid=1; // burası dışarıdan değer alacak346 let lecture= {347 LectureID: lectureid,348 SubjectID: '1',349 Date: '2008-11-11T00:00:00',350 TeacherID: '1',351 ClassroomID: '2',352 Classroom: '',353 Inspection: '',354 Subject: '',355 Teacher: ''356 };357 const apiURL ='http://localhost:62540/api/lectureupdate/'+lectureid;358 await axios.put(apiURL,lecture)359 .then(response => console.log(response.data.updatedAt));360}361export default FirstRequest;362*/363// STUDENT PUT364/*365import axios from "axios";366async function FirstRequest(){367 let studentid=2007; // burası dışarıdan değer alacak368 369 let student= {370 Name: 'Harun',371 Surname: 'Near',372 StudentNo: 87,373 DepartmantID: 1 };374 const apiURL ='http://localhost:62540/api/studentupdate/'+studentid;375 await axios.put(apiURL, student)376 .then(response => console.log(response.data.updatedAt));377}378export default FirstRequest;379*/380// STUDENTPASSWORD PUT381/*382import axios from "axios";383async function FirstRequest(){384 let studentpasswordid=1;385 let studentpassword= {386 StudentPasswordID: studentpasswordid,387 StudentID: '5',388 Password: '987654',389 Student: ''390 };391 const apiURL ='http://localhost:62540/api/studentpasswordupdate/'+studentpasswordid;392 await axios.put(apiURL,studentpassword)393 .then(response => console.log(response.data.updatedAt));394}395export default FirstRequest;396*/397// SUBJECT PUT398/*399import axios from "axios";400async function FirstRequest(){401 let subjectid=1;402 let subject= {403 SubjectID: subjectid,404 Name: 'BM GIRIS',405 Lecture: ''406 };407 const apiURL ='http://localhost:62540/api/subjectupdate/'+subjectid;408 await axios.put(apiURL,subject)409 .then(response => console.log(response.data.updatedAt));410}411export default FirstRequest;412*/413// CLASSROOM PUT414/*415import axios from "axios";416async function FirstRequest(){417 let classroomid=1; // burası dışarıdan değer alacak418 let classroom= {419 ClassroomID: '1',420 ClassNO: 'BM399',421 Lecture: ''422 };423 const apiURL ='http://localhost:62540/api/classroomupdate/'+classroomid;424 await axios.put(apiURL,classroom)425 .then(response => console.log(response.data.updatedAt));426}427export default FirstRequest;428*/429// TEACHER PUT !!!!!!!!!!!!!!---- OLSA BÖYLE OLMASI GEREK AMA YOK ----!!!!!!!!!!!!!!!!!430/*431import axios from "axios";432async function FirstRequest(){433 let teacherid=1;434 let teacher= {435 TeacherID: '2',436 Name: 'Harun',437 Surname: 'NAR',438 Lecture: '',439 TeacherPassword: ''440};441 const apiURL ='http://localhost:62540/api/teacherupdate/'+teacherid;442 await axios.put(apiURL,teacher)443 .then(response => console.log(response.data.updatedAt));444}445export default FirstRequest;446*/447// POST // İDLER OTOMATİK ATIYO GENELİNDE448// DEPARTMANT POST449/*450import axios from "axios";451async function FirstRequest(){452 let departmant= {453 DepartmantID:'1005', //departmanid yi kendi belirliyo454 Name:'Biyomedikal Mühendisliği',455 Student:''};456 const apiURL ='http://localhost:62540/api/departmantinsert/';457 await axios.post(apiURL,departmant)458 .then(response => console.log(response.data.updatedAt));459}460export default FirstRequest;461*/462// INSPECTİON POST // POST api yazılmamış...463/*464import axios from "axios";465async function FirstRequest(){466 let inspection= {467 InspectionID: '1',468 LectureID: '1',469 StudentID: '1',470 Statu: '',471 Lecture: '',472 Student: ''473};474 const apiURL ='http://localhost:62540/api/inspectioninsert/';475 await axios.post(apiURL,inspection)476 .then(response => console.log(response.data.updatedAt));477}478export default FirstRequest;479*/480// LECTURE POST481/*482import axios from "axios"; 483async function FirstRequest(){484 let lecture= {485 LectureID: '4',486 SubjectID: '1',487 Date: '2008-11-11T00:00:00',488 TeacherID: '1',489 ClassroomID: '2',490 Classroom: '',491 Inspection: '',492 Subject: '',493 Teacher: ''494 };495 const apiURL ='http://localhost:62540/api/lectureinsert';496 await axios.post(apiURL,lecture)497 .then(response => console.log(response.data.updatedAt));498}499export default FirstRequest;500*/501// STUDENT POST502/*503import axios from "axios";504async function FirstRequest(){505 506 let student= {507 Name: 'Harun',508 Surname: 'Near',509 StudentNo: 77,510 DepartmantID: 1 };511 const apiURL ='http://localhost:62540/api/studentinsert';512 await axios.post(apiURL, student)513 //.then(response => console.log(response.data.updatedAt));514}515export default FirstRequest;516*/517// STUDENTPASSWORD POST518/*519import axios from "axios";520async function FirstRequest(){521 let studentpassword= {522 StudentPasswordID: '6',523 StudentID: '5',524 Password: '987654',525 Student: ''526 };527 const apiURL ='http://localhost:62540/api/studentpasswordinsert';528 await axios.post(apiURL,studentpassword)529 .then(response => console.log(response.data.updatedAt));530}531export default FirstRequest;532*/533// SUBJECT POST YOK534/**/535// CLASSROOM POST !!!!!!!!!!!!!!---- OLSA BÖYLE OLMASI GEREK AMA YOK ----!!!!!!!!!!!!!!!!!536/*537import axios from "axios";538async function FirstRequest(){539 let classroom= {540 ClassroomID: '3',541 ClassNO: 'BM400',542 Lecture: ''543 };544 const apiURL ='http://localhost:62540/api/classroominstert';545 await axios.post(apiURL,classroom)546 .then(response => console.log(response.data.updatedAt));547}548export default FirstRequest;549*/550// TEACHER POST !!!!!!!!!!!!!!---- OLSA BÖYLE OLMASI GEREK AMA YOK ----!!!!!!!!!!!!!!!!!551/*552import axios from "axios";553async function FirstRequest(){554 let teacher= {555 TeacherID: '3',556 Name: 'Harun',557 Surname: 'NAR',558 Lecture: '',559 TeacherPassword: '123'560};561 const apiURL ='http://localhost:62540/api/teacherinsert';562 await axios.post(apiURL,teacher)563 .then(response => console.log(response.data.updatedAt));564}565export default FirstRequest;566*/567// DELETE568// DEPARTMANT DELETE569/*570import axios from "axios";571async function FirstRequest(){572 let departmantid=1014; // burası dışarıdan değer alacak573 const apiURL ='http://localhost:62540/api/departmantdelete/'+departmantid;574 await axios.delete(apiURL)575 .then(() => console.log = 'Delete successful');576}577export default FirstRequest;578*/579// INSPECTİON DELETE580/*581import axios from "axios";582async function FirstRequest(){583 let inspectionid=6; // burası dışarıdan değer alacak584 const apiURL ='http://localhost:62540/api/inspectiondelete/'+inspectionid;585 await axios.delete(apiURL)586 .then(() => console.log = 'Delete successful');587}588export default FirstRequest;589*/590// LECTURE DELETE591/*592import axios from "axios"; 593async function FirstRequest(){594 let lectureid=6;595 const apiURL ='http://localhost:62540/api/lecturedelete/'+lectureid;596 await axios.delete(apiURL)597 .then(() => console.log = 'Delete successful');598}599export default FirstRequest;600*/601// STUDENT DELETE602/*603import axios from "axios";604async function FirstRequest(){605 let studentid=2004; // burası dışarıdan değer alacak606 607 const apiURL ='http://localhost:62540/api/studentdelete/'+ studentid ;608 await axios.delete(apiURL)609 .then(() => console.log = 'Delete successful');610}611export default FirstRequest;612*/613// STUDENTPASSWORD DELETE614/*615import axios from "axios";616async function FirstRequest(){617 let studentpasswordid=1004;618 const apiURL ='http://localhost:62540/api/studentpassworddelete/'+studentpasswordid;619 await axios.delete(apiURL)620 .then(() => console.log = 'Delete successful');621}622export default FirstRequest;623*/624// SUBJECT DELETE625/*626import axios from "axios";627async function FirstRequest(){628 let subjectid=4;629 const apiURL ='http://localhost:62540/api/subjectdelete/'+subjectid;630 await axios.delete(apiURL)631 .then(() => console.log = 'Delete successful');632}633export default FirstRequest;634*/635// CLASSROOM DELETE636/*637import axios from "axios";638async function FirstRequest(){639 let classroomid=3;640 const apiURL ='http://localhost:62540/api/classroomdelete/'+classroomid;641 await axios.delete(apiURL)642 .then(() => console.log = 'Delete successful');643}644export default FirstRequest;645*/646// TEACHER DELETE !!!!!!!!!!!!!!---- OLSA BÖYLE OLMASI GEREK AMA YOK ----!!!!!!!!!!!!!!!!!647/*648import axios from "axios";649async function FirstRequest(){650 let teacherid=3;651 const apiURL ='http://localhost:62540/api/teacherdelete/'+teacherid;652 await axios.delete(apiURL)653 .then(() => console.log = 'Delete successful');654}655export default FirstRequest;...

Full Screen

Full Screen

transaction-data.service.spec.ts

Source:transaction-data.service.spec.ts Github

copy

Full Screen

1import { inject, TestBed } from "@angular/core/testing";2import { of } from "rxjs";3import { TestConfigModule } from "../../../test/test-config.module";4import { BankAccountService } from "../bank-accounts/bank-account.service";5import { BudgetService } from "../budgets/budget.service";6import { SinkFundAllocationData } from "../sink-funds/sink-fund-allocation-data.model";7import { AllocationData } from "./allocation-data.model";8import { TransactionData } from "./transaction-data.model";9import { TransactionDataService } from "./transaction-data.service";10import { TransactionSearchParams } from "./transaction-search-form/transaction-search-params.model";11import { TransactionService } from "./transaction.service";12describe("TransactionDataService", () => {13 let transactionDataService: TransactionDataService;14 let transactionService: TransactionService;15 let budgetService: BudgetService;16 let bankAccountService: BankAccountService;17 beforeEach(() => {18 TestBed.configureTestingModule({19 imports: [TestConfigModule],20 providers: [21 TransactionDataService,22 TransactionService,23 BankAccountService,24 BudgetService25 ]26 });27 });28 beforeEach(() => {29 transactionDataService = TestBed.inject(TransactionDataService);30 transactionService = TestBed.inject(TransactionService);31 budgetService = TestBed.inject(BudgetService);32 bankAccountService = TestBed.inject(BankAccountService);33 });34 it("should be created", inject(35 [TransactionDataService],36 (service: TransactionDataService) => {37 expect(service).toBeTruthy();38 }39 ));40 describe("#refreshData", () => {41 let firstRequest: TransactionSearchParams = {42 bank_account_id: 10,43 budget_id: 2044 };45 let differentRequest: TransactionSearchParams = {46 bank_account_id: 100,47 budget_id: 20048 };49 let budgetSpy;50 let bankAccountSpy;51 let transactionSpy;52 let sampleTransactions: TransactionData[] = [53 { id: 1, description: "First Transaction" },54 { id: 2, description: "Second Transaction" }55 ];56 let sampleAllocations: AllocationData[] = [57 { id: 10, name: "First Allocation" },58 { id: 20, name: "Second Allocation" }59 ];60 let sampleSinkFundAllocations: SinkFundAllocationData[] = [61 { id: 111, name: "First Sink Fund Allocation" },62 { id: 211, name: "Second Sink Fund Allocation" }63 ];64 beforeEach(() => {65 transactionSpy = spyOn(66 transactionService,67 "getTransactions"68 ).and.returnValue(of(sampleTransactions));69 bankAccountSpy = spyOn(70 bankAccountService,71 "getSinkFundAllocations"72 ).and.returnValue(of(sampleSinkFundAllocations));73 budgetSpy = spyOn(budgetService, "getAllocations").and.returnValue(74 of(sampleAllocations)75 );76 });77 it("requests new transactions", () => {78 transactionDataService79 .allData$()80 .subscribe(([transactions, allocations, sinkFundAllocations]) => {81 expect(transactions).toEqual(sampleTransactions);82 });83 transactionDataService.refresh(firstRequest);84 expect(transactionSpy.calls.count()).toBe(1);85 expect(transactionSpy.calls.mostRecent().args[0]).toEqual(firstRequest);86 });87 it("requests new allocations", () => {88 transactionDataService89 .allData$()90 .subscribe(([transactions, allocations, sinkFundAllocations]) => {91 expect(allocations).toEqual(sampleAllocations);92 });93 transactionDataService.refresh(firstRequest);94 expect(budgetSpy.calls.count()).toBe(1);95 expect(budgetSpy.calls.mostRecent().args[0]).toEqual(96 firstRequest.budget_id97 );98 });99 it("requests new sink fund allocations", () => {100 transactionDataService101 .allData$()102 .subscribe(([transactions, allocations, sinkFundAllocations]) => {103 expect(sinkFundAllocations).toEqual(sampleSinkFundAllocations);104 });105 transactionDataService.refresh(firstRequest);106 expect(bankAccountSpy.calls.count()).toBe(1);107 expect(bankAccountSpy.calls.mostRecent().args[0]).toEqual(108 firstRequest.bank_account_id109 );110 });111 it("requests new transactions again if called with same data", () => {112 transactionDataService.allData$().subscribe();113 transactionDataService.refresh(firstRequest);114 transactionDataService.refresh(firstRequest);115 expect(transactionSpy.calls.count()).toBe(2);116 transactionDataService.refresh({117 bank_account_id: firstRequest.bank_account_id118 });119 expect(transactionSpy.calls.count()).toBe(3);120 });121 it("requests new transactions again if called with different data", () => {122 transactionDataService.allData$().subscribe();123 transactionDataService.refresh(firstRequest);124 transactionDataService.refresh(differentRequest);125 expect(transactionSpy.calls.count()).toBe(2);126 });127 it("requests new allocations again if called with different data", () => {128 transactionDataService.allData$().subscribe();129 transactionDataService.refresh(firstRequest);130 transactionDataService.refresh(differentRequest);131 expect(budgetSpy.calls.count()).toBe(2);132 });133 it("requests new allocations again if called with same data", () => {134 transactionDataService.allData$().subscribe();135 transactionDataService.refresh(firstRequest);136 transactionDataService.refresh(firstRequest);137 expect(budgetSpy.calls.count()).toBe(2);138 });139 it("requests new again if called with different bank_account_id but same budget id", () => {140 transactionDataService.allData$().subscribe();141 transactionDataService.refresh(firstRequest);142 transactionDataService.refresh({143 budget_id: firstRequest.budget_id,144 bank_account_id: 555145 });146 expect(budgetSpy.calls.count()).toBe(2);147 });148 it("requests new sinkFundAllocations again if called with different data", () => {149 transactionDataService.allData$().subscribe();150 transactionDataService.refresh(firstRequest);151 transactionDataService.refresh(differentRequest);152 expect(bankAccountSpy.calls.count()).toBe(2);153 });154 it("doesn't request sinkFundAllocations again if called with same data", () => {155 transactionDataService.allData$().subscribe();156 transactionDataService.refresh(firstRequest);157 transactionDataService.refresh(firstRequest);158 expect(bankAccountSpy.calls.count()).toBe(1);159 });160 it("doesn't request sinkFundAllocations again if called with different object but same data", () => {161 transactionDataService.allData$().subscribe();162 transactionDataService.refresh(firstRequest);163 transactionDataService.refresh({164 bank_account_id: firstRequest.bank_account_id165 });166 expect(bankAccountSpy.calls.count()).toBe(1);167 });168 it("doesn't request sinkFundAllocations again if called with different bank_account_id but same budget id", () => {169 transactionDataService.allData$().subscribe();170 transactionDataService.refresh(firstRequest);171 transactionDataService.refresh({172 budget_id: 5665,173 bank_account_id: firstRequest.bank_account_id174 });175 expect(bankAccountSpy.calls.count()).toBe(1);176 });177 });...

Full Screen

Full Screen

authrequest_basic.js

Source:authrequest_basic.js Github

copy

Full Screen

1%# Note that this file is not a valid *.js file!2%# It is intended to be a bottlepy - style template3%# used for the scripting part of TheOnionBox!4// This code is based on the great work of5// Jamie Perkins' "Digest Auth Request"6// https://github.com/inorganik/digest-auth-request7// adapted to suit our needs!8<%9 base_path = get('virtual_basepath', '') + '/'10 session_id = get('session_id')11 proceed_to = get('proceed_to', 'index.html')12%>13function authRequest(username, password) {14 var self = this;15 this.method = 'GET';16 this.url = '{{base_path}}' + username + '/login.html';17 this.scheme = null; // we just echo the scheme, to allow for 'basic', 'X-basic', 'Jbasic' etc18 this.response = null; // hashed response to server challenge19 // settings20 this.timeout = 10000; // timeout21 // this might be old-fashion yet safe! Isn't it... ?22 this.ajaxRequest = function()23 {24 try { var request = new XMLHttpRequest(); }25 catch(e1)26 {27 try { request = new ActiveXObject("Msxml2.XMLHTTP"); }28 catch(e2)29 {30 try { request = new ActiveXObject ("Microsoft.XMLHTTP"); }31 catch(e3)32 {33 request = false;34 }35 }36 }37 return request;38 };39 // start here40 this.request = function() {41 self.firstRequest = new self.ajaxRequest();42 self.firstRequest.open(self.method, self.url, true);43 self.firstRequest.timeout = self.timeout;44 self.firstRequest.onreadystatechange = function() {45 // 2: received headers, 3: loading, 4: done46 if (self.firstRequest.readyState === 2) { 47 var responseHeaders = self.firstRequest.getAllResponseHeaders();48 responseHeaders = responseHeaders.split('\n');49 // get authenticate header50 var basicHeaders;51 for(var i = 0; i < responseHeaders.length; i++) {52 if (responseHeaders[i].match(/www-authenticate/i) != null) {53 basicHeaders = responseHeaders[i];54 }55 }56 57 if (basicHeaders != null) {58 // parse auth header and get basic auth keys59 basicHeaders = basicHeaders.split(':')[1];60 basicHeaders = basicHeaders.split(',');61 self.scheme = basicHeaders[0].split(/\s/)[1];62 for (var j = 0; j < basicHeaders.length; j++) {63 var equalIndex = basicHeaders[j].indexOf('='),64 key = basicHeaders[j].substring(0, equalIndex),65 val = basicHeaders[j].substring(equalIndex + 1);66 // find realm67 if (key.match(/realm/i) != null) {68 self.realm = val;69 }70 }71 // now we can make an authenticated request72 self.makeAuthenticatedRequest();73 }74 }75 if (self.firstRequest.readyState === 4) {76 // if (!(self.firstRequest.status >= 200 && self.firstRequest.status < 400)){77 if (self.firstRequest.status !== 401) {78 // console.log('self.firstRequest.readyState');79 document.location = '{{base_path}}{{session_id}}/failed.html';80 }81 }82 };83 // handle error84 self.firstRequest.onerror = function() {85 if (self.firstRequest.status !== 401) {86 // console.log('self.firstRequest.onerror');87 document.location = '{{base_path}}{{session_id}}/failed.html';88 }89 };90 // send91 self.firstRequest.send();92 };93 this.makeAuthenticatedRequest = function() {94 // btoa will fail on IE<10; to be fixed when someone complains ;) !95 self.response = btoa(username+':'+password);96 self.authenticatedRequest = self.ajaxRequest();97 self.authenticatedRequest.open(self.method, self.url, true);98 self.authenticatedRequest.timeout = self.timeout;99 var basicAuthHeader = self.scheme + ' ' + self.response;100 self.authenticatedRequest.setRequestHeader('Authorization', basicAuthHeader);101 self.authenticatedRequest.onload = function() {102 var redirect_location = '{{base_path}}{{session_id}}/failed.html';103 // success104 if (self.authenticatedRequest.status >= 200 && self.authenticatedRequest.status < 400) {105 if (self.authenticatedRequest.responseText !== 'undefined') {106 if (self.authenticatedRequest.responseText.length > 0) {107 var location_id = self.authenticatedRequest.responseText;108 redirect_location = '{{base_path}}' + location_id + '/{{proceed_to}}';109 }110 }111 }112 // console.log('self.authenticatedRequest.onload');113 document.location = redirect_location;114 };115 // handle errors116 self.authenticatedRequest.onerror = function() { 117 // console.log('self.authenticatedRequest.onerror');118 document.location = '{{base_path}}{{session_id}}/failed.html';119 };120 self.authenticatedRequest.send();121 };122 this.abort = function() {123 if (self.firstRequest != null) {124 if (self.firstRequest.readyState != 4) self.firstRequest.abort();125 }126 if (self.authenticatedRequest != null) {127 if (self.authenticatedRequest.readyState != 4) self.authenticatedRequest.abort();128 }129 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8var wpt = require('wpt');9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14});15var wpt = require('wpt');16 if (err) {17 console.log(err);18 } else {19 console.log(data);20 }21});22var wpt = require('wpt');23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28});29var wpt = require('wpt');30wpt.getLocations(function(err, data) {31 if (err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37var wpt = require('wpt');38wpt.getTesters(function(err, data) {39 if (err) {40 console.log(err);41 } else {42 console.log(data);43 }44});45var wpt = require('wpt');46 if (err) {47 console.log(err);48 } else {49 console.log(data);50 }51});52var wpt = require('wpt');53 if (err) {54 console.log(err);55 } else {56 console.log(data);57 }58});59var wpt = require('wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status:', data.statusText);5 console.log('Test ID:', data.data.testId);6 console.log('Test URL:', data.data.summary);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log('First View:', data.data.runs[1].firstView);10 console.log('Repeat View:', data.data.runs[1].repeatView);11 });12});13 if (err) return callback(err);14 at IncomingMessage.res.on (C:\Users\user\Desktop\wpt\node_modules\webpagetest\lib\webpagetest.js:131:5)15 at emitNone (events.js:91:20)16 at IncomingMessage.emit (events.js:185:7)17 at endReadableNT (_stream_readable.js:974:12)18 at _combinedTickCallback (internal/process/next_tick.js:80:11)19 at process._tickCallback (internal/process/next_tick.js:104:9)20var wpt = require('webpagetest');21var wpt = new WebPageTest('www.webpagetest.org');22 if (err) return console.error(err);23 console.log('Test status:', data.statusText);24 console.log('Test ID:', data.data.testId);25 console.log('Test URL:', data.data.summary);

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('wpt');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8const wpt = require('wpt');9 if (err) {10 console.log(err);11 } else {12 console.log(data);13 }14});15const wpt = require('wpt');16wpt.getLocations(function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data);21 }22});23const wpt = require('wpt');24wpt.getTesters(function(err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data);29 }30});31const wpt = require('wpt');32wpt.getTest(12345678, function(err, data) {33 if (err) {34 console.log(err);35 } else {36 console.log(data);37 }38});39const wpt = require('wpt');40wpt.getTestStatus(12345678, function(err, data) {41 if (err) {42 console.log(err);43 } else {44 console.log(data);45 }46});47const wpt = require('wpt');48wpt.getTestResults(12345678, function(err, data) {49 if (err) {50 console.log(err);51 } else {52 console.log(data);53 }54});55const wpt = require('wpt');56wpt.getTestHar(12345678, function(err, data) {57 if (err) {58 console.log(err);59 } else {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log('Error: ' + err);5 }6 else {7 console.log(data);8 }9});10var WebPageTest = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12module.exports = wpt;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 console.log(data);4});5var WebPageTest = require('webpagetest');6var wpt = new WebPageTest('www.webpagetest.org');7 console.log(data);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if(err) {3 console.log('error', err);4 } else {5 console.log('data', data);6 }7});8 if(err) {9 console.log('error', err);10 } else {11 console.log('data', data);12 }13});14 if(err) {15 console.log('error', err);16 } else {17 console.log('data', data);18 }19});20 if(err) {21 console.log('error', err);22 } else {23 console.log('data', data);24 }25});26wpt.getLocations(function(err, data) {27 if(err) {28 console.log('error', err);29 } else {30 console.log('data', data);31 }32});33wpt.getTesters(function(err, data) {34 if(err) {35 console.log('error', err);36 } else {37 console.log('data', data);38 }39});40 if(err) {41 console.log('error', err);42 } else {43 console.log('data', data);44 }45});46 if(err) {47 console.log('error', err);48 } else {49 console.log('data', data);50 }51});52 if(err) {53 console.log('error', err);54 } else {55 console.log('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wpt = new WPT('API_KEY');3wpt.firstView('URL', function (data) {4 console.log(data);5});6var request = require('request');7var WPT = function (apiKey) {8 this.apiKey = apiKey;9};10WPT.prototype.firstView = function (url, callback) {11 var options = {12 };13 request(options, function (err, res, body) {14 if (!err && res.statusCode == 200) {15 callback(body);16 }17 });18};19{20 "cars": {21 }22}23I tried using JSON.parse() but it is giving me error. How do I get the value of car2?24{25 {26 {27 },28 {29 }30 },31 {32 {33 },34 {35 }36 }37}38var data = require('./

Full Screen

Using AI Code Generation

copy

Full Screen

1 console.log(result);2});3 console.log(result);4});5 console.log(result);6});7}).then(function (result) {8 console.log(result);9});10wpt.getTestResults('150823_1Q_2e7a0f6f2a6b7e6d8b6f7a6c7e6f7a6d').then(function (result) {11 console.log(result);12});13wpt.getTestStatus('150823_1Q_2e7a0f6f2a6

Full Screen

Using AI Code Generation

copy

Full Screen

1I am trying to make a simple node.js app that will send a request to a web page, and then send the response to a client. I am using the request module to make the request, and it works fine. However, I am not sure how to send the response to the client. I have tried using res.send(body) and res.send(request.body) but neither of these work. Here is my code:2var request = require('request');3var express = require('express');4var app = express();5app.get('/', function(req, res) {6 if (!error && response.statusCode == 200) {7 res.send(body);8 }9 });10});11app.listen(3000);12var express = require('express');13var app = express();14var request = require('request');15app.get('/', function(req, res) {16 if (!error && response.statusCode == 200) {17 res.send(body);18 }19 });20});21app.listen(3000);

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