Best JavaScript code snippet using jest
routes.js
Source:routes.js
1module.exports.routes = {2 //====================================================3 // Home4 //====================================================5 '/': {6 assets: 'index.html'7 },8 '/admin': {9 assets: 'admin.html'10 },11 //====================================================12 // Product13 //====================================================14 'GET /product/find': 'ProductController.find',15 'GET /product/findOne': 'ProductController.findOne',16 'GET /product/withQuestionnaires': 'ProductController.withQuestionnaires',17 'GET /product/hasQuestionnaireAnswer': 'ProductController.hasQuestionnaireAnswer',18 'GET /product/findWithAverage': 'ProductController.findWithAverage',19 'GET /product/findOneWithAverage': 'ProductController.findOneWithAverage',20 'PUT /product/updatePhoto': 'ProductController.updatePhoto',21 'PUT /product/updateThumbnail': 'ProductController.updateThumbnail',22 'DELETE /product/destroy': 'ProductController.destroy',23 'POST /product/create': 'ProductController.create',24 'POST /product/createProduct': 'ProductController.createProduct',25 'PUT /product/updateProduct': 'ProductController.updateProduct',26 'PUT /product/update': 'ProductController.update',27 // One off28 'GET /product/getCategories': 'ProductController.getCategories',29 //====================================================30 // Like31 //====================================================32 'GET /like/finOne': 'LikeController.findOne',33 'POST /like/create': 'LikeController.create',34 'DELETE /like/destroy': 'LikeController.destroy',35 'DELETE /like/destroyLikes': 'LikeController.destroyLikes',36 //====================================================37 // QuestionAnswer38 //====================================================39 'GET /questionAnswer/findQuestionAnswer': 'QuestionAnswerController.findQuestionAnswer',40 'POST /questionAnswer/createAnswers': 'QuestionAnswerController.createAnswers',41 'POST /questionAnswer/createScreenshot': 'QuestionAnswerController.createScreenshot',42 'PUT /questionAnswer/updateAnswers': 'QuestionAnswerController.updateAnswers',43 //====================================================44 // Note45 //====================================================46 'GET /note/find': 'NoteController.find',47 'GET /note/findOne': 'NoteController.findOne',48 'GET /note/getMaxScoreNote': 'NoteController.getMaxScoreNote',49 'GET /note/myHandicap': 'NoteController.myHandicap',50 //====================================================51 // User52 //====================================================53 'GET /user/findOne': 'UserController.findOne',54 'PUT /user/update': 'UserController.update',55 'POST /user/login': 'AuthController.login',56 'POST /user/register': 'AuthController.register',57 'PUT /user/updatePassword': 'AuthController.changePassword',58 'GET /user/find': 'UserController.find',59 //====================================================60 // Post61 //====================================================62 'GET /post/find': 'PostController.find',63 'GET /post/findLatest': 'PostController.findLatest',64 'GET /post/findOne': 'PostController.findOne',65 'POST /post/create': 'PostController.create',66 'PUT /post/update': 'PostController.update',67 //====================================================68 // Comment69 //====================================================70 'GET /comment/find': 'CommentController.find',71 'POST /comment/create': 'CommentController.create',72 'DELETE /comment/destroy': 'CommentController.destroy',73 //====================================================74 // Poll75 //====================================================76 'GET /poll/findLatest': 'PollController.findLatest',77 'POST /poll/create': 'PollController.create',78 //====================================================79 // Poll80 //====================================================81 'POST /pollComment/create': 'PollCommentController.create',82 'GET /pollComment/find': 'PollCommentController.find',83 'DELETE /pollComment/destroy': 'PollCommentController.destroy',84 //====================================================85 // PollAnswer86 //====================================================87 'GET /pollAnswer/hasPollAnswer': 'PollAnswerController.hasPollAnswer',88 'GET /pollAnswer/find': 'PollAnswerController.find',89 'POST /pollAnswer/create': 'PollAnswerController.create',90 //====================================================91 // GolfRecord92 //====================================================93 'POST /golfRecord/create': 'GolfRecordController.create',94 'GET /golfRecord/find': 'GolfRecordController.find',95 'GET /golfRecord/findOne': 'GolfRecordController.findOne',96 'GET /golfRecord/findByKeyword': 'GolfRecordController.findByKeyword',97 'PUT /golfRecord/update': 'GolfRecordController.update',98 'DELETE /golfRecord/destroy': 'GolfRecordController.destroy',99 'GET /golfRecord/getMaxScoreRecord': 'GolfRecordController.getMaxScoreRecord',100 'GET /golfRecord/myHandicap': 'GolfRecordController.myHandicap',101 //====================================================102 // Photo103 //====================================================104 'POST /photo/createPhotos': 'PhotoController.createPhotos',105 'PUT /photo/updatePhotos': 'PhotoController.updatePhotos',106 //====================================================107 // Contact Admin108 //====================================================109 'POST /contact/admin': 'UserController.contactFromWeb',110 //====================================================111 // NOT USED112 //====================================================113 /**************************************114 * LIKE115 *************************************/116 'GET /like/find': 'LikeController.find',117 /**************************************118 * Post119 *************************************/120 'GET /post/findNative': 'PostController.findNative',121 'DELETE /post/destroy': 'PostController.destroy',122 'POST /post/like': 'LikeController.postLike',123 'DELETE /post/unlike': 'LikeController.postUnlike',124 /**************************************125 * Comment126 *************************************/127 'GET /comment/findNative': 'CommentController.findNative',128 'GET /comment/findOne': 'CommentController.findOne',129 'PUT /comment/update': 'CommentController.update',130 'POST /comment/like': 'LikeController.commentLike',131 'DELETE /comment/unlike': 'LikeController.commentUnlike',132 /**************************************133 * Place134 *************************************/135 'GET /place/find': 'PlaceController.find',136 'GET /place/findNative': 'PlaceController.findNative',137 'GET /place/findOne': 'PlaceController.findOne',138 'POST /place/create': 'PlaceController.create',139 'PUT /place/update': 'PlaceController.update',140 'DELETE /place/destroy': 'PlaceController.destroy',141 'POST /place/like': 'LikeController.placeLike',142 'DELETE /place/unlike': 'LikeController.placeUnlike',143 /**************************************144 * Product145 *************************************/146 'GET /product/findNative': 'ProductController.findNative',147 'POST /product/like': 'LikeController.productLike',148 'DELETE /product/unlike': 'LikeController.productUnlike',149 /**************************************150 * Booking151 *************************************/152 'GET /booking/find': 'BookingController.find',153 'GET /booking/findNative': 'BookingController.findNative',154 'GET /booking/findOne': 'BookingController.findOne',155 'POST /booking/create': 'BookingController.create',156 'PUT /booking/update': 'BookingController.update',157 'DELETE /booking/destroy': 'BookingController.destroy',158 /**************************************159 * RoyaltyPoint160 *************************************/161 'GET /royalty/find': 'RoyaltyPointController.find',162 'GET /royalty/findNative': 'RoyaltyPointController.findNative',163 'GET /royalty/findOne': 'RoyaltyPointController.findOne',164 'POST /royalty/create': 'RoyaltyPointController.create',165 'PUT /royalty/update': 'RoyaltyPointController.update',166 'DELETE /royalty/destroy': 'RoyaltyPointController.destroy',167 /**************************************168 * Review169 *************************************/170 'GET /review/find': 'ReviewController.find',171 'GET /review/findNative': 'ReviewController.findNative',172 'GET /review/findOne': 'ReviewController.findOne',173 'POST /review/create': 'ReviewController.create',174 'PUT /review/update': 'ReviewController.update',175 'DELETE /review/destroy': 'ReviewController.destroy',176 /**************************************177 * Photo178 *************************************/179 'GET /photo/find': 'PhotoController.find',180 'GET /photo/findNative': 'PhotoController.findNative',181 'GET /photo/findOne': 'PhotoController.findOne',182 'POST /photo/create': 'PhotoController.create',183 'PUT /photo/update': 'PhotoController.update',184 'DELETE /photo/destroy': 'PhotoController.destroy',185 /**************************************186 * Auth187 *************************************/188 // OAuth189 'GET /user/checkNickname': 'AuthController.checkNickname',190 'GET /user/checkUsername': 'AuthController.checkUsername',191 'GET /user/checkEmail': 'AuthController.checkEmail',192 // 'POST /user/login': 'AuthController.login',193 'GET /user/logout': 'AuthController.logout',194 'POST /user/loginWithOauth': 'AuthController.registerPassport',195 'POST /forgotpassword': 'AuthController.forgotPasswordStart',196 'POST /forgotpassword/check': 'AuthController.forgotPasswordCheck',197 'PUT /forgotpassword/complete': 'AuthController.forgotPasswordComplete',198 'PUT /auth/changePassword': 'AuthController.changePassword',199 /**************************************200 * User201 *************************************/202 'GET /me': 'UserController.getMyUserInfo',203 'PUT /me': 'UserController.updateMyInfo',204 // User authentication service205 'GET /user/findNative': 'UserController.findNative',206 'POST /user/create': 'UserController.create',207 // 'PUT /user/update': 'UserController.update',208 'DELETE /user/destroy': 'UserController.destroy',209 'POST /email/admin': 'UserController.contactAdmin',210 /**************************************211 * Device212 *************************************/213 'GET /device/push': 'DeviceController.pushAll',214 'POST /device/register': 'DeviceController.register',215 'PUT /device/update': 'DeviceController.update',216 /**************************************217 * Role218 *************************************/219 'GET /role/myrole': 'RoleController.getMyRole',220 'GET /role/find': 'RoleController.find',221 'GET /role/findNative': 'RoleController.findNative',222 'GET /role/findOne': 'RoleController.findOne',223 'POST /role/create': 'RoleController.create',224 'PUT /role/update': 'RoleController.update',225 'DELETE /role/destroy': 'RoleController.destroy',226 /**************************************227 * Socket228 *************************************/229 'GET /subscribeToRoom/:roomName': 'SocketController.subscribeToRoom',230 /**************************************231 * Data232 *************************************/233 'POST /data/import': 'DataController.importCollection',234 'GET /data/export': 'DataController.exportCollection'...
ReviewController.js
Source:ReviewController.js
...40 message: "ì¥ì ë¡ë©ì ì¤í¨ íìµëë¤. ìë²ìë¬ code: 001"41 });42 });43}44function findNative(req, res) {45 var queryWrapper = QueryService.buildQuery(req);46 sails.log("----------- queryWrapper: Review.findNative -------------");47 sails.log(queryWrapper);48 return Promise.resolve(QueryService.executeNative(Review, queryWrapper))49 .spread(function(reviews, more, count) {50 return res.ok({51 reviews: reviews,52 more: more,53 total: count54 });55 })56 .catch(function() {57 return res.send(500, {58 message: "ì¥ì ë¡ë©ì ì¤í¨ íìµëë¤. ìë²ìë¬ code: 001"...
ProductController.js
Source:ProductController.js
...132 .catch((err) => {133 return res.negotiate(err);134 });135}136// function findNative(req, res) {137// var queryWrapper = QueryService.buildQuery(req);138// sails.log("----------- queryWrapper: Product.findNative -------------");139// sails.log(queryWrapper);140// return Promise.resolve(QueryService.executeNative(Product, queryWrapper))141// .spread((products, more, count) => {142// res.ok({143// products: products,144// more: more,145// total: count146// });147// })148// .catch((err) => {149// sails.log.error(err);150// res.send(500, {...
node.js
Source:node.js
...52 });53 }54 roots.forEach(search);55}56function findNative(57roots,58extensions,59ignore,60callback)61{62 const args = [].concat(roots);63 args.push('-type', 'f');64 if (extensions.length) {65 args.push('\(');66 }67 extensions.forEach((ext, index) => {68 if (index) {69 args.push('-o');70 }71 args.push('-iname');72 args.push('*.' + ext);73 });74 if (extensions.length) {75 args.push('\)');76 }77 const child = spawn('find', args);78 let stdout = '';79 child.stdout.setEncoding('utf-8');80 child.stdout.on('data', data => stdout += data);81 child.stdout.on('close', () => {82 const lines = stdout.trim().split('\n').filter(x => !ignore(x));83 const result = [];84 let count = lines.length;85 if (!count) {86 callback([]);87 } else {88 lines.forEach(path => {89 fs.stat(path, (err, stat) => {90 if (!err && stat) {91 result.push([path, stat.mtime.getTime()]);92 }93 if (--count === 0) {94 callback(result);95 }96 });97 });98 }99 });100}101module.exports = function nodeCrawl(102options)103{const104 data = options.data,extensions = options.extensions,forceNodeFilesystemAPI = options.forceNodeFilesystemAPI,ignore = options.ignore,roots = options.roots;105 return new Promise(resolve => {106 const callback = list => {107 const files = Object.create(null);108 list.forEach(fileData => {109 const name = fileData[0];110 const mtime = fileData[1];111 const existingFile = data.files[name];112 if (existingFile && existingFile[H.MTIME] === mtime) {113 files[name] = existingFile;114 } else {115 // See ../constants.js116 files[name] = ['', mtime, 0, []];117 }118 });119 data.files = files;120 resolve(data);121 };122 if (forceNodeFilesystemAPI || process.platform === 'win32') {123 find(roots, extensions, ignore, callback);124 } else {125 findNative(roots, extensions, ignore, callback);126 }127 });...
Places.js
Source:Places.js
1(function(angular) {2 'use strict';3 angular.module('app')4 .factory('Places', Places);5 Places.$inject = [6 '$resource',7 'SERVER_URL'8 ];9 function Places(10 $resource,11 SERVER_URL12 ) {13 var placeUrl = SERVER_URL + '/place' +14 '/:find' +15 '/:findLikedPlaces' +16 '/:findOne' +17 '/:create' +18 '/:update' +19 '/:destroy' +20 '/:like' +21 '/:findNative' +22 '/:contactOwner';23 var params = {24 find: '@find',25 findLikedPlaces: '@findLikedPlaces',26 findOne: '@findOne',27 create: '@create',28 update: '@update',29 destroy: '@destroy',30 like: '@like',31 findNative: '@findNative',32 contactOwner: '@contactOwner'33 };34 var actions = {35 find: {36 method: 'GET',37 params: {38 find: 'find'39 }40 },41 findLikedPlaces: {42 method: 'GET',43 params: {44 findLikedPlaces: 'findLikedPlaces'45 }46 },47 findOne: {48 method: 'GET',49 params: {50 findOne: 'findOne'51 }52 },53 create: {54 method: 'POST',55 params: {56 create: 'create'57 }58 },59 update: {60 method: 'PUT',61 params: {62 update: 'update'63 }64 },65 destroy: {66 method: 'DELETE',67 params: {68 destroy: 'destroy'69 }70 },71 like: {72 method: 'POST',73 params: {74 like: 'like'75 }76 },77 // longitude, latitude, distance78 findNative: {79 method: 'GET',80 params: {81 findNative: 'findNative'82 }83 },84 contactOwner: {85 method: 'POST',86 params: {87 contactOwner: 'contactOwner'88 }89 }90 };91 var service = $resource(placeUrl, params, actions);92 return service;93 }...
policies.js
Source:policies.js
1module.exports.policies = {2 //'*': true3 '*': [4 'basicAuth',5 'bearerAuth',6 'passportBearerAuth',7 'passport',8 'sessionAuth',9 'ModelPolicy',10 'AuditPolicy',11 'OwnerPolicy',12 'PermissionPolicy',13 'RolePolicy', // empty14 'CriteriaPolicy'15 ],16 AuthController: {17 '*': ['passport'],18 'checknickname': true,19 'checkemail': true,20 'contactAdmin': true,21 'changePassword': [22 'bearerAuth',23 'sessionAuth'24 ]25 },26 UserController: {27 'create': ['passport'],28 'checknickname': true,29 'checkemail': true,30 'contactAdmin': true,31 'contactFromWeb': true32 //'*': true33 },34 DeviceController: {35 pushAll: [36 'basicAuth',37 'bearerAuth',38 'passport',39 'sessionAuth',40 'ModelPolicy',41 'AuditPolicy',42 'OwnerPolicy',43 'PermissionPolicy',44 'RolePolicy',45 'CriteriaPolicy'46 ],47 register: true,48 update: true49 },50 //SocketController: [51 // 'basicAuth',52 // 'bearerAuth',53 // 'passport',54 // 'sessionAuth'55 //],56 // DataController: [57 // 'BearerAdmin',58 // 'sessionAuth'59 // ],60 // PostController: {61 // find: true,62 // findNative: true,63 // findOne: true,64 // },65 // PlaceController: {66 // find: true,67 // findNative: true,68 // findOne: true,69 // },70 // ProductController: {71 // find: true,72 // findNative: true,73 // findOne: true,74 // },75 /**************************************76 * For dev only77 *************************************/78 //CommentController: true...
functions_5.js
Source:functions_5.js
1var searchData=2[3 ['findnative',['FindNative',['../group__interop.html#gae59535616ba1b982b5fba460922514a2',1,'sampgdk']]],4 ['forceclassselection',['ForceClassSelection',['../group__natives.html#gab457fbf5f4057c6f2a8a6a69fd4c668e',1,'a_players.h']]]...
all_5.js
Source:all_5.js
1var searchData=2[3 ['findnative',['FindNative',['../group__interop.html#gae59535616ba1b982b5fba460922514a2',1,'sampgdk']]],4 ['forceclassselection',['ForceClassSelection',['../group__natives.html#gab457fbf5f4057c6f2a8a6a69fd4c668e',1,'a_players.h']]]...
LambdaTest’s Jest Testing Tutorial covers step-by-step guides around Jest with code examples to help you be proficient with the Jest framework. The Jest tutorial has chapters to help you learn right from the basics of Jest framework to code-based tutorials around testing react apps with Jest, perform snapshot testing, import ES modules and more.
|<p>it('check_object_of_Car', () => {</p><p>
expect(newCar()).toBeInstanceOf(Car);</p><p>
});</p>|
| :- |
Get 100 minutes of automation test minutes FREE!!