How to use testBody method in storybook-root

Best JavaScript code snippet using storybook-root

search_resource.js

Source:search_resource.js Github

copy

Full Screen

1//点击搜索后跳转到资源list页面2function changeToSearchPage(){3 var resource_kind=$("#resource_choose").val();4 var search_content=$("#search_content").val();5 var container=$("#thead");6 container.empty();//清空7 container.append("<tr>");8 if(resource_kind == '线路'){9 window.location.href="linetransport?flag=0&resource_kind="+resource_kind+"&search_content="+search_content;10 //debugger;11 container.append("<td width=\"15\" class=\"td_main_list_head\"></td><td class=\"td_main_list_head\">线路名称</td><td width=\"100\" class=\"td_main_list_head\">参考价(元/kg)</td><td width=\"60\" class=\"td_main_list_head\">类型</td><td width=\"80\" class=\"td_main_list_head\">时限(小时)</td><td width=\"80\" class=\"td_main_list_head\">发布日期</td><td width=\"45\" class=\"td_main_list_head\">关注</td>");12 }else if(resource_kind == '配送'){13 window.location.href="cityline?flag=0&resource_kind="+resource_kind+"&search_content="+search_content;14 container.append("<td width=\"15\" class=\"td_main_list_head\"></td><td class=\"td_main_list_head\">网络名称</td><td class=\"td_main_list_head\" width=\"100\">参考价(元/kg)</td><td class=\"td_main_list_head\" width=\"80\">增值服务</td><td class=\"td_main_list_head\" width=\"80\">信用等级</td><td class=\"td_main_list_head\" width=\"80\">发布日期</td><td class=\"td_main_list_head\" width=\"45\">关注</td>");15 }else if(resource_kind == '车辆'){16 window.location.href="car?flag=0&resource_kind="+resource_kind+"&search_content="+search_content;17 container.append("<td width=\"15\" class=\"td_main_list_head\"></td><td class=\"td_main_list_head\">牌照号码</td><td class=\"td_main_list_head\" width=\"80\">用途</td><td class=\"td_main_list_head\" width=\"70\">状态</td><td class=\"td_main_list_head\" width=\"70\">车长(米)</td><td class=\"td_main_list_head\" width=\"70\">载重(吨)</td><td class=\"td_main_list_head\" width=\"100\">当前位置</td><td class=\"td_main_list_head\" width=\"80\">定位日期</td><td class=\"td_main_list_head\" width=\"45\">关注</td>");18 }else if(resource_kind == '仓库'){19 window.location.href="warehouse?flag=0&resource_kind="+resource_kind+"&search_content="+search_content;20 container.append("<td width=\"15\" class=\"td_main_list_head\"></td><td class=\"td_main_list_head\">仓库名称</td><td class=\"td_main_list_head\" width=\"70\">消防等级</td> <td class=\"td_main_list_head\" width=\"80\">类型</td><td class=\"td_main_list_head\" width=\"100\">面积(平方米)</td><td class=\"td_main_list_head\" width=\"80\">发布日期</td> <td class=\"td_main_list_head\" width=\"45\">关注</td>");21 }else if(resource_kind == '公司'){22 window.location.href="company?resource_kind="+resource_kind+"&search_content="+search_content;23 container.append("<td width=\"15\" class=\"td_main_list_head\"></td><td class=\"td_main_list_head\">公司名称</td><td class=\"td_main_list_head\" width=\"70\">资源级别</td><td class=\"td_main_list_head\" width=\"70\">公司性质</td><td class=\"td_main_list_head\" width=\"70\">信用等级</td><td class=\"td_main_list_head\" width=\"80\">发布日期</td><td class=\"td_main_list_head\" width=\"45\">关注</td>");24 }else if(resource_kind == '货物'){25 window.location.href="goodsform?flag=0&resource_kind="+resource_kind+"&search_content="+search_content;26 container.append("<td width=\"15\" class=\"td_main_list_head\"></td><td class=\"td_main_list_head\">货物名称</td><td class=\"td_main_list_head\" width=\"70\">运输类型</td><td class=\"td_main_list_head\" width=\"100\">有效期至</td><td class=\"td_main_list_head\" width=\"80\">重量(吨)</td><td class=\"td_main_list_head\" width=\"110\">发布日期</td><td class=\"td_main_list_head\" width=\"45\">关注</td>");27 }28 29}30//搜索种类31function searchKind(){32 var resource_kind=$("#resource_choose").val();33 var search_content=$("#search_content").val();34 if(resource_kind == '线路'){35 searchFunc_linetransport(search_content,resource_kind,10,1);36 //页码信息37// debugger;38 $.ajax({39 url:"searchResourceTotalRowsAjax",40 data:{41 resource_kind:resource_kind,42 search_content:search_content43 },44 dataType:"json",45 cache:false,46 success:function(data,status){47 $('#div_resource_list_head1').text("共"+data+"条记录");48 $('#count').val(data);49 $("#page_layout").empty();50 pageLayout(data);//页面布局51 }52 });53 }else if(resource_kind == '配送'){54 searchFunc_city(search_content,resource_kind,10,1);55 //页码信息56 $.ajax({57 url:"searchResourceTotalRowsAjax",58 data:{59 resource_kind:resource_kind,60 search_content:search_content61 },62 dataType:"json",63 cache:false,64 success:function(data,status){65 $('#div_resource_list_head1').text("共"+data+"条记录");66 $('#count').val(data);67 $("#page_layout").empty();68 pageLayout(data);//页面布局69 }70 });71 }else if(resource_kind == '车辆'){72 searchFunc_car(search_content,resource_kind,10,1);73 //页码信息74 $.ajax({75 url:"searchResourceTotalRowsAjax",76 data:{77 resource_kind:resource_kind,78 search_content:search_content79 },80 dataType:"json",81 cache:false,82 success:function(data,status){83 $('#div_resource_list_head1').text("共"+data+"条记录");84 $('#count').val(data);85 $("#page_layout").empty();86 pageLayout(data);//页面布局87 }88 });89 }else if(resource_kind == '仓库'){90 searchFunc_warehouse(search_content,resource_kind,10,1);91 //页码信息92 $.ajax({93 url:"searchResourceTotalRowsAjax",94 data:{95 resource_kind:resource_kind,96 search_content:search_content97 },98 dataType:"json",99 cache:false,100 success:function(data,status){101 $('#div_resource_list_head1').text("共"+data+"条记录");102 $('#count').val(data);103 $("#page_layout").empty();104 pageLayout(data);//页面布局105 }106 });107 }else if(resource_kind == '公司'){108 searchFunc_company(search_content,resource_kind,10,1);109 //页码信息110 $.ajax({111 url:"searchResourceTotalRowsAjax",112 data:{113 resource_kind:resource_kind,114 search_content:search_content115 },116 dataType:"json",117 cache:false,118 success:function(data,status){119 $('#div_resource_list_head1').text("共"+data+"条记录");120 $('#count').val(data);121 $("#page_layout").empty();122 pageLayout(data);//页面布局123 }124 });125 }else if(resource_kind == '货物'){126 searchFunc_cargo(search_content,resource_kind,10,1);127 //页码信息128 $.ajax({129 url:"searchResourceTotalRowsAjax",130 data:{131 resource_kind:resource_kind,132 search_content:search_content133 },134 dataType:"json",135 cache:false,136 success:function(data,status){137 $('#div_resource_list_head1').text("共"+data+"条记录");138 $('#count').val(data);139 $("#page_layout").empty();140 pageLayout(data);//页面布局141 }142 });143 }144}145////**************一下为搜索的具体函数****************146//搜索资源功能-干线147function searchFunc_linetransport(search_content,resource_kind,display,currentPage){148 //alert("clisk");149 var url="searchResourceAjax";150 $.ajax({url:url,151 type:"get",152 cache:false,153 data:{"resource_kind":resource_kind,154 "search_content":search_content,155 "display":display,156 "currentPage":currentPage},157 dataType:"json",158 success:function(data,status){159 $("#testbody").empty();//清空结果集160 for(var i=0;i<data.length;i++){161 $("#testbody").append("<tr>");162 $("#testbody").append("<td class=\"td_main_list_content\"></td>");163 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"linetransportdetail?linetransportid="+data[i].id+"&carrierId="+data[i].carrierId+"&linetransportId="+data[i].carrierid+"&flag=0\" hidefocus=\"true\">"+data[i].startPlace+"→"+data[i].endPlace+"</a><br /><a style=\"color:#717071;\" href=\"companyDetail?id="+data[i].carrierId+"\" hidefocus=\"true\">"+data[i].companyName+"<img src=\"images/btn_level1a.png\" /></a></td>");164 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].refPrice+"</td>");165 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].transportType+"</td>");166 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].onWayTime+"</td>");167 $("#testbody").append("<td class=\"td_main_list_content\">"+renderTime(data[i].relDate)+"</td>");168 if(data[i].status == "有效")169 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1b\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");170 else171 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1a\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");172 /* $("#testbody").append("</td>"); */173 $("#testbody").append("</tr>");174 }175 }176 });177 178 /*//查询总记录数179 $.ajax({180 url:"",181 dataType:"json",182 data:{183 "resource_kind":resource_kind,184 "search_content":search_content,185 "display":display,186 "currentPage":currentPage187 },188 cache:false,189 success:function(data,status){190 $('#div_resource_list_head1').text("共"+data+"条记录");191 $('#count').val(data);192 $("#page_layout").empty();193 pageLayout(data);//页面布局194 }195 196 })*/197}198//搜索资源功能-城市配送199function searchFunc_city(search_content,resource_kind,display,currentPage){200 //alert("clisk");201 var url="searchResourceAjax";202 $.ajax({url:url,203 type:"get",204 cache:false,205 data:{"resource_kind":resource_kind,206 "search_content":search_content,207 "display":display,208 "currentPage":currentPage},209 dataType:"json",210 success:function(data,status){211 $("#testbody").empty();//清空结果集212 for(var i=0;i<data.length;i++){213 $("#testbody").append("<tr>");214 $("#testbody").append("<td class=\"td_main_list_content\"></td>");215 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"citylinedetail?citylineId="+data[i].id+"&carrierId="+data[i].carrierId+"&flag=0\" hidefocus=\"true\">"+data[i].name+"</a> <br /> <a href=\"companyDetail?id="+data[i].carrierId+"\" style=\"color:#717071;\" hidefocus=\"true\"> "+data[i].companyName+" <img src=\"images/btn_level1a.png\" /></a></td>");216 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].refPrice+"</td>");217 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].vIPService+"</td>");218 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].creditRate+"</td>");219 $("#testbody").append("<td class=\"td_main_list_content\">"+renderTime(data[i].relDate)+"</td>");220 if(data[i].status == "有效")221 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1b\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");222 else223 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1a\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");224 $("#testbody").append("</tr>");225 }226 }227 });228}229//搜索资源功能-车辆230function searchFunc_car(search_content,resource_kind,display,currentPage){231 //alert("clisk");232// debugger;233 var url="searchResourceAjax";234 $.ajax({url:url,235 type:"get",236 cache:false,237 data:{"resource_kind":resource_kind,238 "search_content":search_content,239 "display":display,240 "currentPage":currentPage},241 dataType:"json",242 success: function(data,status){243 $("#testbody").empty();//清空结果集244 for(var i=0;i<data.length;i++){245 $("#testbody").append("<tr>");246 $("#testbody").append("<td class=\"td_main_list_content\"></td>");247 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"cardetail?carId="+data[i].id+"&carrierId="+data[i].carrierId+"&linetransportId=$"+data[i].linetransportId+"&flag=0\" hidefocus=\"true\">"+data[i].carNum+"</a><br /> <a href=\"companyDetail?id="+data[i].carrierId+" style=\"color:#717071;\" hidefocus=\"true\">"+data[i].companyName+"<img src=\"images/btn_level1a.png\" /></a></td>");248 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].carBase+"</td>");249 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].carState+"</td>");250 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].carLength+"</td>");251 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].carWeight+"</td>");252 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].carLocation+"</td>");253 $("#testbody").append("<td class=\"td_main_list_content\">"+renderTime(data[i].relDate)+"</td>");254 if(data[i].status == "有效")255 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1b\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");256 else257 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1a\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");258 $("#testbody").append("</tr>");259 }260 }261 });262}263//搜索资源功能-仓库264function searchFunc_warehouse(search_content,resource_kind,display,currentPage){265 //alert("clisk");266 var url="searchResourceAjax";267 $.ajax({url:url,268 type:"get",269 cache:false,270 data:{"resource_kind":resource_kind,271 "search_content":search_content,272 "display":display,273 "currentPage":currentPage},274 dataType:"json",275 success: function(data,status){276 $("#testbody").empty();//清空结果集277 for(var i=0;i<data.length;i++){278 $("#testbody").append("<tr>");279 $("#testbody").append("<td class=\"td_main_list_content\"></td>");280 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"warehousedetail?warehouseId="+data[i].id+"&carrierId="+data[i].carrierId+"&flag=0\" hidefocus=\"true\">"+data[i].name+"</a> <br /> <a href=\"companyDetail?id="+data[i].carrierId+" style=\"color:#717071;\" hidefocus=\"true\"> "+data[i].companyName+"<img src=\"images/btn_level1a.png\" /></a></td>");281 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].fireRate+"</td>");282 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].type+"</td>");283 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].houseArea+"</td>");284 $("#testbody").append("<td class=\"td_main_list_content\">"+renderTime(data[i].relDate)+"</td>");285 if(data[i].status == "有效")286 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1b\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");287 else288 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1a\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");289 $("#testbody").append("</tr>");290 }291 }292 });293}294//搜索资源功能-公司295function searchFunc_company(search_content,resource_kind,display,currentPage){296 //alert("clisk");297 var url="searchResourceAjax";298// debugger;299 $.ajax({url:url,300 type:"get",301 cache:false,302 data:{"resource_kind":resource_kind,303 "search_content":search_content,304 "display":display,305 "currentPage":currentPage},306 dataType:"json",307 success: function(data,status){308 $("#testbody").empty();//清空结果集309 for(var i=0;i<data.length;i++){310 $("#testbody").append("<tr>");311 $("#testbody").append("<td class=\"td_main_list_content\"></td>");312 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"companyDetail?id="+data[i].id+" hidefocus=\"true\">"+data[i].companyName+"<img src=\"images/btn_level1a.png\" /></a></td>");313 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].resourceRate+"</td>");314 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].companyKind+"</td>");315 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].creditRate+"</td>");316 $("#testbody").append("<td class=\"td_main_list_content\">"+renderTime(data[i].relDate)+"</td>");317 if(data[i].status == "有效")318 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1b\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");319 else320 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1a\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");321 $("#testbody").append("</tr>");322 }323 }324 });325}326//搜索资源功能-货物327function searchFunc_cargo(search_content,resource_kind,display,currentPage){328 //alert("clisk");329 var url="searchResourceAjax";330 $.ajax({url:url,331 type:"get",332 cache:false,333 data:{"resource_kind":resource_kind,334 "search_content":search_content,335 "display":display,336 "currentPage":currentPage},337 dataType:"json",338 success: function(data,status){339 $("#testbody").empty();//清空结果集340 for(var i=0;i<data.length;i++){341 $("#testbody").append("<tr>");342 $("#testbody").append("<td class=\"td_main_list_content\"></td>");343 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"goodsdetail?id="+data[i].id+"\" hidefocus=\"true\">"+data[i].name+"</a>");344 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].transportType+"</td>");345 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].limitDate+"</td>");346 $("#testbody").append("<td class=\"td_main_list_content\">"+data[i].weight+"</td>");347 $("#testbody").append("<td class=\"td_main_list_content\">"+renderTime(data[i].relDate)+"</td>");348 if(data[i].status == "有效")349 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1b\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");350 else351 $("#testbody").append("<td class=\"td_main_list_content\"><a href=\"javascript:;\" class=\"a_main_list_handle_icon1a\" hidefocus=\"true\" onclick=\"hide(this);loadXMLDoc('"+data[i].id+"')\"></a></td>");352 $("#testbody").append("</tr>");353 }354 355 }356 });...

Full Screen

Full Screen

app.test.ts

Source:app.test.ts Github

copy

Full Screen

1import app from '../src/app.js';2import supertest from 'supertest';3import { prisma } from "../src/database.js";4import userBodyFactory from "./factories/userBodyFactory.js";5import userFactory from "./factories/userFactory.js";6import testBodyFactory from "./factories/testBodyFactory.js";7describe("GET /tests", () => {8 beforeEach(truncateUsers);9 afterAll(disconnect);10 it("IT WILL EXECUTE JUST ONCE: given an invalid token or no token at all it should return 401", async () => {11 const result = await supertest(app).get("/tests/disciplines");12 const status = result.status;13 14 expect(status).toEqual(401);15 });16 17 it("given a valid token it should have tests property", async () => {18 const token = await tokenFactory();19 const response2 = await supertest(app).get("/tests/disciplines")20 .set({ 'Authorization': `Bearer ${token}` });21 22 expect(response2.body).toHaveProperty('tests');23 });24 25});26describe("GET /teachers", () => {27 beforeEach(truncateUsers);28 afterAll(disconnect);29 30 it("given a valid token but disciplineId othen than number or no disciplineId it should return 409", async () => {31 const token = await tokenFactory();32 const { status } = await supertest(app).get("/teachers?disciplineId=bananinha")33 .set({ 'Authorization': `Bearer ${token}` });34 35 expect(status).toBe(409);36 });37 it("given a valid token and number disciplineId it should have property teachers", async () => {38 const token = await tokenFactory();39 40 const response2 = await supertest(app).get("/teachers?disciplineId=9999")41 .set({ 'Authorization': `Bearer ${token}` });42 43 expect(response2.body).toHaveProperty('teachers');44 });45 46});47describe("GET /disciplines", () => {48 beforeEach(truncateUsers);49 afterAll(disconnect);50 it("given a valid token it should have property disciplines", async () => {51 const token = await tokenFactory();52 53 const response2 = await supertest(app).get("/disciplines")54 .set({ 'Authorization': `Bearer ${token}` });55 56 expect(response2.body).toHaveProperty('disciplines');57 });58 59});60describe("GET /categories", () => {61 beforeEach(truncateUsers);62 afterAll(disconnect);63 it("given a valid token it should have property categories", async () => {64 const token = await tokenFactory();65 66 const response2 = await supertest(app).get("/categories")67 .set({ 'Authorization': `Bearer ${token}` });68 69 expect(response2.body).toHaveProperty('categories');70 });71 72});73describe("POST /tests", () => {74 beforeEach(truncateUsers);75 beforeEach(truncateTests);76 afterAll(disconnect);77 it("given valid test credentials but duplicate name for test it should return 409", async () => {78 const token = await tokenFactory();79 80 const testBody = testBodyFactory();81 testBody.categoryId = 1;82 testBody.teacherId = 1;83 testBody.disciplineId = 1;84 const response2 = await supertest(app).post("/tests")85 .set({ 'Authorization': `Bearer ${token}` }).send(testBody);86 const { status } = await supertest(app).post("/tests")87 .set({ 'Authorization': `Bearer ${token}` }).send(testBody);88 89 expect(status).toBe(409);90 });91 it("given valid test credentials but non existent categoryId it should return 409", async () => {92 const token = await tokenFactory();93 94 const testBody = testBodyFactory();95 testBody.categoryId = 999;96 testBody.teacherId = 1;97 testBody.disciplineId = 1;98 const { status } = await supertest(app).post("/tests")99 .set({ 'Authorization': `Bearer ${token}` }).send(testBody);100 101 expect(status).toBe(409);102 });103 it("given valid test credentials but non existent disciplineId or teacherId it should return 409", async () => {104 const token = await tokenFactory();105 106 const testBody = testBodyFactory();107 testBody.categoryId = 3;108 testBody.teacherId = 999;109 testBody.disciplineId = 999;110 const { status } = await supertest(app).post("/tests")111 .set({ 'Authorization': `Bearer ${token}` }).send(testBody);112 113 expect(status).toBe(409);114 });115 it("given invalid test credentials it should return 422", async () => {116 const token = await tokenFactory();117 118 const testBody = testBodyFactory();119 testBody.categoryId = -1;120 testBody.teacherId = -1;121 testBody.disciplineId = -1;122 const { status } = await supertest(app).post("/tests")123 .set({ 'Authorization': `Bearer ${token}` }).send(testBody);124 125 expect(status).toBe(422);126 });127 it("given valid test credentials it should return 201", async () => {128 const token = await tokenFactory();129 130 const testBody = testBodyFactory();131 testBody.categoryId = 1;132 testBody.teacherId = 1;133 testBody.disciplineId = 1;134 const { status } = await supertest(app).post("/tests")135 .set({ 'Authorization': `Bearer ${token}` }).send(testBody);136 137 expect(status).toBe(201);138 });139 140});141describe("PUT /tests/:id", () => {142 beforeEach(truncateUsers);143 beforeEach(truncateTests);144 afterAll(disconnect);145 it("given invalid or no test id it should return 409", async () => {146 const token = await tokenFactory();147 const { status } = await supertest(app).put("/tests/bananinha")148 .set({ 'Authorization': `Bearer ${token}` });149 150 expect(status).toBe(409);151 });152 it("given non existent test id it should return 409", async () => {153 const token = await tokenFactory();154 const { status } = await supertest(app).put("/tests/1")155 .set({ 'Authorization': `Bearer ${token}` });156 157 expect(status).toBe(409);158 });159 it("given existent test id it should have views property", async () => {160 const token = await tokenFactory();161 162 const testBody = testBodyFactory();163 testBody.categoryId = 1;164 testBody.teacherId = 1;165 testBody.disciplineId = 1;166 await supertest(app).post("/tests")167 .set({ 'Authorization': `Bearer ${token}` }).send(testBody);168 const responseViews = await supertest(app).put("/tests/1")169 .set({ 'Authorization': `Bearer ${token}` });170 171 expect(responseViews.body).toHaveProperty('views');172 });173 174});175async function disconnect() {176 await prisma.$disconnect();177}178async function truncateUsers() {179 await prisma.$executeRaw`TRUNCATE TABLE users RESTART IDENTITY;`;180}181async function truncateTests() {182 await prisma.$executeRaw`TRUNCATE TABLE tests RESTART IDENTITY;`;183}184async function tokenFactory(){185 const body = userBodyFactory();186 await userFactory(body);187 const response1 = await supertest(app).post("/sign-in").send(body);188 const { token } = response1.body;189 return token;...

Full Screen

Full Screen

multisignatures.js

Source:multisignatures.js Github

copy

Full Screen

1// var node = require('../../node.js');2//3// var ZSchema = require('../../../helpers/z_schema.js');4// var schema = require('../../../schema/multisignatures.js');5// var expect = require('chai').expect;6//7// var validator = new ZSchema();8//9// describe('multisignatures', function () {10//11// // TODO: Add tests for other multisignature schemas12// describe('getAccounts', function () {13// it('tests for schema');14// });15//16// describe('pending', function () {17// it('tests for schema');18// });19//20// describe('sign', function () {21// it('tests for schema');22// });23//24// describe('addMultisignatures', function () {25// var testBody;26//27// beforeEach(function () {28// var secret = node.randomPassword();29// testBody = {30// secret: secret,31// publicKey: node.lisk.crypto.getKeys(secret).publicKey,32// min: 2,33// lifetime: 1,34// keysgroup: Array.apply(null, Array(4)).map(function () { return '+' + node.lisk.crypto.getKeys(node.randomPassword()).publicKey;})35// };36// });37//38// describe('min', function () {39//40// it('should return error when min is not an integer', function () {41// testBody.min = '';42// validator.validate(testBody, schema.addMultisignature);43// expect(validator.getLastErrors().map(function (e) {44// return e.message;45// })).to.eql(['Expected type integer but found type string']);46// });47//48// it('should return error when min value is less than acceptable value', function () {49// testBody.min = 0;50// validator.validate(testBody, schema.addMultisignature);51// expect(validator.getLastErrors().map(function (e) {52// return e.message;53// })).to.eql(['Value 0 is less than minimum 1']);54// });55//56// it('should return error when min value is greater than acceptable value', function () {57// testBody.min = 16;58// validator.validate(testBody, schema.addMultisignature);59// expect(validator.getLastErrors().map(function (e) {60// return e.message;61// })).to.eql(['Value 16 is greater than maximum 15']);62// });63// });64//65// describe('keysgroup', function () {66//67// it('should return error when keysgroup is not an array', function () {68// testBody.keysgroup = '';69// validator.validate(testBody, schema.addMultisignature);70// expect(validator.getLastErrors().map(function (e) {71// return e.message;72// })).to.eql(['Expected type array but found type string']);73// });74//75// it('should return error when keysgroup length is less than minimum acceptable length', function () {76// testBody.keysgroup = [];77// validator.validate(testBody, schema.addMultisignature);78// expect(validator.getLastErrors().map(function (e) {79// return e.message;80// })).to.eql(['Array is too short (0), minimum 1']);81// });82//83// it('should return error when keysgroup length is greater than maximum acceptable length', function () {84// testBody.keysgroup = Array.apply(null, Array(16)).map(function () { return node.lisk.crypto.getKeys(node.randomPassword()).publicKey; });85// validator.validate(testBody, schema.addMultisignature);86// expect(validator.getLastErrors().map(function (e) {87// return e.message;88// })).to.eql(['Array is too long (16), maximum 15']);89// });90// });91//92// it('should be ok when params field length valid', function () {93// validator.validate(testBody, schema.addMultisignature);94// expect(validator.getLastErrors()).to.not.exist;95// });96// });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { testBody } from 'storybook-root';2testBody();3import { testBody } from 'storybook-root';4testBody();5import { testBody } from 'storybook-root';6testBody();7import { testBody } from 'storybook-root';8testBody();9import { testBody } from 'storybook-root';10testBody();11import { testBody } from 'storybook-root';12testBody();13import { testBody } from 'storybook-root';14testBody();15import { testBody } from 'storybook-root';16testBody();17import { testBody } from 'storybook-root';18testBody();19import { testBody } from 'storybook-root';20testBody();21import { testBody } from 'storybook-root';22testBody();23import { testBody } from 'storybook-root';24testBody();25import { testBody } from 'storybook-root';26testBody();27import { testBody } from 'storybook-root';28testBody();29import { testBody } from 'storybook-root';30testBody();31import { testBody } from 'storybook-root';32testBody();33import { testBody } from 'storybook-root';34testBody();35import { testBody } from 'storybook-root';36testBody();37import { testBody } from 'storybook-root';38testBody();39import { testBody } from 'storybook-root';40testBody();41import { testBody } from 'storybook-root';42testBody();43import { testBody } from 'storybook-root';44testBody();45import { testBody } from 'storybook-root';46testBody();47import { testBody } from 'storybook-root';48testBody();49import { testBody } from 'storybook-root';50testBody();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { testBody } from 'storybook-root';2testBody();3import { storiesOf } from '@storybook/react';4export function testBody() {5 storiesOf('test', module)6 .add('test', () => <div>test</div>);7}8import { configure } from '@storybook/react';9configure(() => {10 require('../test');11}, module);12require('../storybook-root');13module.exports = {14 module: {15 {16 use: {17 options: {18 require.resolve('babel-plugin-module-resolver'),19 },20 },21 },22 },23};24{25 "scripts": {26 },27 "dependencies": {28 }29}30{31 {32 }33}34I am using the module resolver plugin to allow me to use absolute paths in my project. I am also using storybook. I have a root file that I want to import in my config file so that I can add stories to the storybook. The following code works when I run storybook:35import { storiesOf } from '@storybook/react';36storiesOf('test', module)37 .add('test', () => <div>test</div>);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { testBody } from 'storybook-root/test';2import { testBody } from 'storybook-root/test';3import { testBody } from 'storybook-root/test';4import { testBody } from 'storybook-root/test';5import { testBody } from 'storybook-root/test';6import { testBody } from 'storybook-root/test';7import { testBody } from 'storybook-root/test';8import { testBody } from 'storybook-root/test';9import { testBody } from 'storybook-root/test';10import { testBody } from 'storybook-root/test';11import { testBody } from 'storybook-root/test';12import { testBody } from 'storybook-root/test';13import { testBody } from 'storybook-root/test';14import { testBody } from 'storybook-root/test';15import { testBody } from 'storybook-root/test';16import { testBody } from 'storybook-root/test';17import { testBody } from 'storybook-root/test';18import { testBody } from 'storybook-root/test';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { testBody } from 'storybook-root';2testBody();3import { testBody } from 'storybook-root';4export { testBody };5import { expect } from 'chai';6export const testBody = () => {7 it('should have a body', () => {8 expect(document.body).to.exist;9 });10};

Full Screen

Using AI Code Generation

copy

Full Screen

1import { testBody } from 'storybook-root';2testBody();3import { testBody } from 'storybook-root';4testBody();5import { testBody } from 'storybook-root';6testBody();7import { testBody } from 'storybook-root';8testBody();9import { testBody } from 'storybook-root';10testBody();11import { testBody } from 'storybook-root';12testBody();13import { testBody } from 'storybook-root';14testBody();15import { testBody } from 'storybook-root';16testBody();17import { testBody } from 'storybook-root';18testBody();19import { testBody } from 'storybook-root';20testBody();21import { testBody } from 'storybook-root';22testBody();23import { testBody } from 'storybook-root';24testBody();25import { testBody } from 'storybook-root';26testBody();27import { testBody } from 'storybook-root';28testBody();29import { testBody } from '

Full Screen

Using AI Code Generation

copy

Full Screen

1import testBody from 'storybook-root';2testBody();3I am trying to import a function from a module (storybook-root) which is located in my root folder. I am using the following code:But I am getting the following error:How can I import the function from the module in my root folder?4import testBody from './storybook-root';5testBody();6× Email codedump link for How to import a function from a module in root folder

Full Screen

Using AI Code Generation

copy

Full Screen

1import {testBody} from 'storybook-root';2testBody("test");3export function testBody(body) {4 console.log("test body", body);5}6import {testBody} from 'storybook-root';7testBody("test");8module.exports = async ({ config }) => {9 config.resolve.alias = {10 'storybook-root': path.resolve(__dirname, '../storybook-root.js'),11 };12 return config;13};

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 storybook-root 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