Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const chai = require("chai")
- const request = require('superagent')
- describe("test-aws-lambda", function() {
- it("should return results in correct format", function(done){
- request
- .post('https://census-toy.nceng.net/prod/toy-census?top=-1')
- .send({ actionType: 'CountByGender',
- users: [
- {
- "gender": "female",
- "name": {
- "title": "miss",
- "first": "ronja",
- "last": "saarinen"
- },
- "location": {
- "street": "1505 mannerheimintie",
- "city": "lemi",
- "state": "central finland",
- "postcode": 24382
- },
- "email": "ronja.saarinen@example.com",
- "login": {
- "username": "heavytiger900",
- "password": "wibble",
- "salt": "u7y0THoZ",
- "md5": "b86cd36b377202147942266f768420cd",
- "sha1": "564961ace0b11b2da8e669b1bb29b1d2d8dc0f44",
- "sha256": "976e981e22c4216f67c675842a5b9555f5e11360050fcc2ee5aff1a869dd97a4"
- },
- "dob": "1984-04-14 06:57:26",
- "registered": "2009-11-27 19:33:36",
- "phone": "03-249-015",
- "cell": "040-071-55-88",
- "id": {
- "name": "HETU",
- "value": "984-652Y"
- },
- "picture": {
- "large": "https://randomuser.me/api/portraits/women/61.jpg",
- "medium": "https://randomuser.me/api/portraits/med/women/61.jpg",
- "thumbnail": "https://randomuser.me/api/portraits/thumb/women/61.jpg"
- },
- "nat": "FI"
- },
- {
- "gender": "female",
- "name": {
- "title": "mrs",
- "first": "ellie",
- "last": "hughes"
- },
- "location": {
- "street": "7060 bay view road",
- "city": "taupo",
- "state": "west coast",
- "postcode": 17628
- },
- "email": "ellie.hughes@example.com",
- "login": {
- "username": "redleopard375",
- "password": "camero",
- "salt": "i36Z5XzG",
- "md5": "0fe338231d860285d4a4a6f194d7d317",
- "sha1": "c1053334b0742c4d726918da7680de78753062ec",
- "sha256": "4c4964e952863bf5aefcb93e7d652f174ffa86077bd9fbd8c6b8aff75c105949"
- },
- "dob": "1954-03-04 03:22:15",
- "registered": "2004-06-12 23:28:34",
- "phone": "(953)-707-6029",
- "cell": "(193)-604-2253",
- "id": {
- "name": "",
- "value": null
- },
- "picture": {
- "large": "https://randomuser.me/api/portraits/women/33.jpg",
- "medium": "https://randomuser.me/api/portraits/med/women/33.jpg",
- "thumbnail": "https://randomuser.me/api/portraits/thumb/women/33.jpg"
- },
- "nat": "NZ"
- },
- {
- "gender": "female",
- "name": {
- "title": "mrs",
- "first": "ilona",
- "last": "geilen"
- },
- "location": {
- "street": "4511 hoefsmederijstraat",
- "city": "koggenland",
- "state": "limburg",
- "postcode": 97448
- },
- "email": "ilona.geilen@example.com",
- "login": {
- "username": "yellowgoose939",
- "password": "stick",
- "salt": "SMyWzS10",
- "md5": "5d127c7060ac872658e0879ed86f9af0",
- "sha1": "67c81741e4f0affc670a44fa4d58d1778d0bf1ae",
- "sha256": "1ef4dd5f7f84bb65ddef35995ae064a8b30eeb2aaf101bfc7e74cb82b3e5bdbe"
- },
- "dob": "1950-06-24 04:54:11",
- "registered": "2011-01-02 02:27:41",
- "phone": "(998)-114-7736",
- "cell": "(493)-378-8667",
- "id": {
- "name": "BSN",
- "value": "83572496"
- },
- "picture": {
- "large": "https://randomuser.me/api/portraits/women/89.jpg",
- "medium": "https://randomuser.me/api/portraits/med/women/89.jpg",
- "thumbnail": "https://randomuser.me/api/portraits/thumb/women/89.jpg"
- },
- "nat": "NL"
- }]})
- .end((err, res) => {
- console.log(res.body);
- chai.expect(res.body).to.be.an('array');
- chai.expect(res.body[0].value).to.equal(3);
- chai.expect(res.body[0].name).to.equal("female");
- done()
- });
- })
- })
- describe("test-aws-lambda", function() {
- it("should return results in correct format", function(done){
- request
- .post('https://census-toy.nceng.net/prod/toy-census')
- .send({ actionType: 'CountPasswordComplexity',
- users: [
- {
- "gender": "male",
- "name": {
- "title": "mr",
- "first": "esat",
- "last": "körmükçü"
- },
- "location": {
- "street": "9679 vatan cd",
- "city": "adıyaman",
- "state": "mersin",
- "postcode": 15373
- },
- "email": "esat.körmükçü@example.com",
- "login": {
- "username": "tinypanda568",
- "password": "colombia!",
- "salt": "mFBwIrE9",
- "md5": "d9ec8f0945fda9a4b360e0b3e1f77663",
- "sha1": "5efba9ac45ebabcbe60328ff6d57714ecafc5038",
- "sha256": "5c6c83f8daa39a11ab395e8de60c5b7b7d826601cedb0479f7a01c9e5b68a7d0"
- },
- "dob": "1955-09-01 06:12:29",
- "registered": "2003-07-01 04:59:49",
- "phone": "(221)-821-5631",
- "cell": "(288)-834-8078",
- "id": {
- "name": "",
- "value": null
- },
- "picture": {
- "large": "https://randomuser.me/api/portraits/men/7.jpg",
- "medium": "https://randomuser.me/api/portraits/med/men/7.jpg",
- "thumbnail": "https://randomuser.me/api/portraits/thumb/men/7.jpg"
- },
- "nat": "TR"
- },
- {
- "gender": "male",
- "name": {
- "title": "monsieur",
- "first": "lucas",
- "last": "blanc"
- },
- "location": {
- "street": "6361 rue barrème",
- "city": "st-barthélemy vd",
- "state": "valais",
- "postcode": 5909
- },
- "email": "lucas.blanc@example.com",
- "login": {
- "username": "beautifulbutterfly504",
- "password": "server",
- "salt": "qu962MwJ",
- "md5": "3fc739751892db30574e769e6d5bfe8d",
- "sha1": "d3bdceb63e2dd258f02eebd9e2c088a5dc34696e",
- "sha256": "13270e598c5e68a73146107c9d5f7b15fcb108010dabae0b710e34615adcf266"
- },
- "dob": "1958-07-29 09:00:57",
- "registered": "2012-12-20 04:33:43",
- "phone": "(230)-955-1785",
- "cell": "(737)-618-1829",
- "id": {
- "name": "AVS",
- "value": "756.COYC.KWSQ.77"
- },
- "picture": {
- "large": "https://randomuser.me/api/portraits/men/95.jpg",
- "medium": "https://randomuser.me/api/portraits/med/men/95.jpg",
- "thumbnail": "https://randomuser.me/api/portraits/thumb/men/95.jpg"
- },
- "nat": "CH"
- },
- {
- "gender": "male",
- "name": {
- "title": "mr",
- "first": "aitor",
- "last": "nuñez"
- },
- "location": {
- "street": "6249 calle de pedro bosch",
- "city": "santander",
- "state": "la rioja",
- "postcode": 73424
- },
- "email": "aitor.nuñez@example.com",
- "login": {
- "username": "whitebear826",
- "password": "goblue@",
- "salt": "MYaHbwm3",
- "md5": "c0981a85ce8ce215b7e7a033aac56280",
- "sha1": "e880971cab792c4482b5f6f3ef073b02b82aea17",
- "sha256": "3af01d3153ed24cb03d25ce1986cbb44fab5f3c2b0784cce5bc6d4ff0d82229e"
- },
- "dob": "1978-02-12 11:45:36",
- "registered": "2010-05-15 22:02:57",
- "phone": "941-896-607",
- "cell": "668-466-874",
- "id": {
- "name": "DNI",
- "value": "70950695-D"
- },
- "picture": {
- "large": "https://randomuser.me/api/portraits/men/78.jpg",
- "medium": "https://randomuser.me/api/portraits/med/men/78.jpg",
- "thumbnail": "https://randomuser.me/api/portraits/thumb/men/78.jpg"
- },
- "nat": "ES"
- }]})
- .end((err, res) => {
- console.log(res.body);
- res.body.map(function(a){return a.password.length});
- chai.expect(res.body).to.be.an('array');
- chai.expect(res.body[0].value).to.equal(3);
- chai.expect(res.body[0].name).to.equal("");
- done()
- });
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement