Best JavaScript code snippet using stryker-parent
index.spec.js
Source:index.spec.js
...72 });73 });74 context('isLocalhost', () => {75 it('reports on localhost', () => {76 expect(isLocalhost('localhost:27019')).to.be.true;77 });78 it('reports on localhost of type 127.0.0.1', () => {79 expect(isLocalhost('127.0.0.1:27019')).to.be.true;80 });81 it('works as url', () => {82 expect(isLocalhost('mongodb://127.0.0.1:27019')).to.be.true;83 expect(isLocalhost('mongodb+srv://127.0.0.1')).to.be.true;84 expect(isLocalhost('mongodb://0.0.0.0:27019')).to.be.true;85 expect(isLocalhost('mongodb+srv://0.0.0.0')).to.be.true;86 expect(isLocalhost('mongodb://localhost')).to.be.true;87 expect(isLocalhost('mongodb://localhost:27019')).to.be.true;88 });89 it('works as hostname', () => {90 expect(isLocalhost('127.0.0.1')).to.be.true;91 expect(isLocalhost('0.0.0.0')).to.be.true;92 expect(isLocalhost('localhost')).to.be.true;93 });94 it('does not report if localhost or 127.0.0.1 is not the hostname', () => {95 expect(isLocalhost('127.0.0.2')).to.be.false;96 expect(isLocalhost('0.0.0.1')).to.be.false;97 expect(isLocalhost('remotehost')).to.be.false;98 expect(isLocalhost('mongodb://remotelocalhost')).to.be.false;99 });100 it('does not throw and returns with invalid argument', () => {101 expect(isLocalhost(123)).to.be.false;102 expect(isLocalhost('')).to.be.false;103 expect(isLocalhost({})).to.be.false;104 expect(isLocalhost(undefined)).to.be.false;105 expect(isLocalhost(null)).to.be.false;106 });107 });108 context('isDigitalOcean', () => {109 it('reports on digital ocean', () => {110 expect(isDigitalOcean('mongodb+srv://admin:catscatscats@dave-a1234321.mongo.ondigitalocean.com/test?authSource=admin&replicaSet=dave')).to.be.true;111 });112 it('works with hostname only', () => {113 expect(isDigitalOcean('dave-a1234321.mongo.ondigitalocean.com')).to.be.true;114 });115 it('works with host only', () => {116 expect(isDigitalOcean('dave-a1234321.mongo.ondigitalocean.com:27017')).to.be.true;117 });118 it('returns false if not digitalocean', () => {119 expect(isDigitalOcean('dave-a1234321.mongo.ondigitalocean.com2')).to.be.false;...
test-url-config-service.js
Source:test-url-config-service.js
...14 });15 describe('#isLocalhost', function () {16 it('should be overridable with literal value', function () {17 var url = new URLService({ isLocalhost: false });18 url.isLocalhost().should.equal(false);19 var url2 = new URLService({ isLocalhost: true });20 url2.isLocalhost().should.equal(true);21 });22 it('should be overridable with a function', function () {23 var url = new URLService({ isLocalhost: function () { return false; } });24 url.isLocalhost().should.equal(false);25 var url2 = new URLService({ isLocalhost: function () { return true; } });26 url2.isLocalhost().should.equal(true);27 });28 });29 describe('#baseURL', ()=> {30 it('should allow overriding as a string', ()=> {31 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj' });32 url.baseURL = 'proxy/';33 url.getAPIPath('run').should.equal('proxy/run/forioAccount/forioProj/');34 });35 it('should allow overriding as a function', ()=> {36 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj' });37 url.baseURL = ()=> 'proxy/';38 url.getAPIPath('run').should.equal('proxy/run/forioAccount/forioProj/');39 });40 it('should allow over-riding from the defaults', function () {41 URLService.defaults.baseURL = 'proxy/';42 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj', versionPath: '' });43 url.getAPIPath('run').should.equal('proxy/run/forioAccount/forioProj/');44 });45 });46 describe('#url', function () {47 it('should default to current hostname if not localhost', function () {48 var url = new URLService({ isLocalhost: false });49 url.host.should.equal(getHost());50 });51 it('should default to api.forio.com if localhost', function () {52 var url = new URLService({ isLocalhost: true });53 url.host.should.equal('api.forio.com');54 });55 it('should allow over-riding host even if localhost', function () {56 var url = new URLService({ isLocalhost: true, host: 'some.of.my.servers' });57 url.host.should.equal('some.of.my.servers');58 });59 });60 describe('#getAPIPath', function () {61 it('should allow over-riding host & protocol', function () {62 var url = new URLService({ host: 'myapi.forio.com', protocol: 'udp' });63 url.getAPIPath('abc').should.equal('udp://myapi.forio.com/' + version + 'abc/');64 });65 it('should allow setting account and project for file api', function () {66 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj' });67 url.getAPIPath('file').should.equal('https://' + url.host + '/' + version + 'file/forioAccount/forioProj/');68 });69 it('should allow setting account and project for run api', function () {70 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj' });71 url.getAPIPath('run').should.equal('https://' + url.host + '/' + version + 'run/forioAccount/forioProj/');72 });73 it('should allow setting account and project for data api', function () {74 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj' });75 url.getAPIPath('data').should.equal('https://' + url.host + '/' + version + 'data/forioAccount/forioProj/');76 });77 it('should allow over-riding the version', function () {78 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj', versionPath: '' });79 url.getAPIPath('data').should.equal('https://' + url.host + '/data/forioAccount/forioProj/');80 });81 it('should allow over-riding host and protocol globally', function () {82 var oldDefaults = $.extend({}, URLService.defaults);83 URLService.defaults = { protocol: 'htttps', host: 'funky.forio.com' };84 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj', versionPath: '' });85 url.getAPIPath('data').should.equal('htttps://funky.forio.com/data/forioAccount/forioProj/');86 URLService.defaults = oldDefaults;87 });88 it('should allow overloading with a function', ()=> {89 var oldDefaults = $.extend({}, URLService.defaults);90 URLService.defaults = { getAPIPath: sinon.spy((api)=> `foobar/${api}/`) };91 var url = new URLService({ accountPath: 'forioAccount', projectPath: 'forioProj', versionPath: '' });92 url.getAPIPath('data').should.equal('foobar/data/');93 URLService.defaults = oldDefaults;94 });95 it('should return true on local environments', function () {96 var url = new URLService({ pathname: '/index.html', host: 'local.forio.com:8080' });97 url.isLocalhost().should.be.true;98 });99 it('should return false on production environments', function () {100 var url = new URLService({ pathname: '/app/acme/hello_world', host: 'forio.com' });101 url.isLocalhost().should.be.false;102 });103 it('should return false on custom domain environments', function () {104 var url = new URLService({ pathname: 'oranges', host: 'apples.com' });105 url.isLocalhost().should.be.false;106 });107 });...
UrlMapping.js
Source:UrlMapping.js
1/*2 * Description: UrlMappingåå°æ¥å£3 * Author: chaoge4 * Date: 2018/05/235*/6export default class UrlMapping {7 constructor(){8 this.isLocalHost = window.location.host.toLowerCase() == 'localhost:8080';9// this.origin = window.location.origin;10 this.origin = 'http://47.105.121.106:3000';11// this.origin = 'http://localhost:3000';12 13 // ç¨æ·14 this.POST_USER_LOGIN = (this.isLocalHost?'/apis':this.origin)+'/wm/user/login'; // ç»å½ 15 this.POST_USER_REGISTER = (this.isLocalHost?'/apis':this.origin)+'/wm/user/register'; // 注å 16 this.POST_USER_LIKEUSERNAME = (this.isLocalHost?'/apis':this.origin)+'/wm/user/likeUserName'; // æç´¢ç¨æ·17 this.POST_USER_UPDATEUSER = (this.isLocalHost?'/apis':this.origin)+'/wm/user/updateUser'; // ä¿®æ¹ä¸ªäººä¿¡æ¯18 this.POST_USER_QUERYBYUSERID = (this.isLocalHost?'/apis':this.origin)+'/wm/user/queryByUserId'; // æ ¹æ®IDæ¥è¯¢ç¨æ·19 // ç¨æ·å
³æ³¨20 this.POST_USERATTENTION_FOLLOW = (this.isLocalHost?'/apis':this.origin)+'/wm/userAttention/follow'; // ç¨æ·å
³æ³¨21 this.POST_USERATTENTION_FANS = (this.isLocalHost?'/apis':this.origin)+'/wm/userAttention/fans'; // ç¨æ·ç²ä¸22 this.POST_USERATTENTION_INSERT = (this.isLocalHost?'/apis':this.origin)+'/wm/userAttention/insert'; // æå
¥å
³æ³¨23 this.POST_USERATTENTION_DELETE = (this.isLocalHost?'/apis':this.origin)+'/wm/userAttention/delete'; // å é¤å
³æ³¨24 this.POST_USERATTENTION_FOLLOWCOUNT = (this.isLocalHost?'/apis':this.origin)+'/wm/userAttention/followCount'; // æ¥è¯¢ç¨æ·å
³æ³¨æ»æ°25 this.POST_USERATTENTION_FANSCOUNT = (this.isLocalHost?'/apis':this.origin)+'/wm/userAttention/fansCount'; // æ¥è¯¢ç¨æ·ç²ä¸æ»æ°26 this.POST_USERATTENTION_QUERYBYID = (this.isLocalHost?'/apis':this.origin)+'/wm/userAttention/queryById'; // æ¥è¯¢æ¯å¦å
³æ³¨ç¨æ·27 28 // è´´å§29 this.POST_ARTICLESORT_FOLLOW = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSort/follow'; // å
³æ³¨çå§30 this.POST_ARTICLESORT_FOLLOWPAGE = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSort/followPage'; // å
³æ³¨çå§å页31 this.POST_ARTICLESORT_LATELYS = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSort/latelys'; // æè¿éçå§32 this.POST_ARTICLESORT_INDEX = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSort/articleSortIndex'; // æ ¹æ®IDæææç« 33 this.POST_ARTICLESORT_QUERYBYID = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSort/queryById'; // æ ¹æ®IDæ¥è¯¢34 this.POST_ARTICLESORT_LIKEARTSNAME = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSort/likeArtsName'; // æ索贴å§å35 36 // å¸å37 this.POST_ARTICLE_INSERT = (this.isLocalHost?'/apis':this.origin)+'/wm/article/insert'; // æå
¥38 this.POST_ARTICLE_DETAIL = (this.isLocalHost?'/apis':this.origin)+'/wm/article/detail'; // 详æ
39 this.POST_ARTICLE_INDEX = (this.isLocalHost?'/apis':this.origin)+'/wm/article/index'; // é¦é¡µ40 this.POST_ARTICLE_FOLLOWINDEX = (this.isLocalHost?'/apis':this.origin)+'/wm/article/followIndex'; // é¦é¡µ-å
³æ³¨41 42 this.POST_ARTICLE_UPDATECLICK = (this.isLocalHost?'/apis':this.origin)+'/wm/article/updateClickByArticleId'; // ä¿®æ¹æ¥ç人æ°43 this.POST_ARTICLE_LIKEARTNAME = (this.isLocalHost?'/apis':this.origin)+'/wm/article/likeArtName'; // æç´¢æç« 44 this.POST_ARTICLE_QUERYBYUSERID = (this.isLocalHost?'/apis':this.origin)+'/wm/article/queryArticleByUserId'; // å½åç¨æ·åå¸çå¸å45 this.POST_ARTICLE_ARTICLEPAGEBYUSERID = (this.isLocalHost?'/apis':this.origin)+'/wm/article/articlePageByUserId'; // å½åç¨æ·åå¸çå¸åå页46 this.POST_ARTICLE_QUERYCOUNTBYSORTID = (this.isLocalHost?'/apis':this.origin)+'/wm/article/queryCountBySortId'; // æ¥è¯¢è´´å§åå¸äºå¤å°å¸å47 48 // å¸åæµè§åå²49 this.POST_BROWSEHISTORY_INSERT = (this.isLocalHost?'/apis':this.origin)+'/wm/browseHistory/insert'; // æå
¥50 this.POST_BROWSEHISTORY_HISTORYPAGE = (this.isLocalHost?'/apis':this.origin)+'/wm/browseHistory/historyPage'; // å页51 this.POST_BROWSEHISTORY_EMPTY = (this.isLocalHost?'/apis':this.origin)+'/wm/browseHistory/empty'; // æ¸
空ç¨æ·æµè§52 53 // è¯è®º54 this.POST_STAYMESSAGE_INSERT = (this.isLocalHost?'/apis':this.origin)+'/wm/stayMessage/insert'; // æå
¥55 this.POST_STAYMESSAGE_QUERYFLOORALL = (this.isLocalHost?'/apis':this.origin)+'/wm/stayMessage/queryFloorAll'; // æ¥è¯¢è¯è®º56 this.POST_STAYMESSAGE_QUERYONEFLOOR = (this.isLocalHost?'/apis':this.origin)+'/wm/stayMessage/queryOneFloor'; // æ¥è¯¢å个楼å±57 this.POST_STAYMESSAGE_QUERYONEFLOORLIST = (this.isLocalHost?'/apis':this.origin)+'/wm/stayMessage/queryOneFloorList'; // æ¥çå个楼å±çåè¯è®º58 59 60 // ç¨æ·å
³æ³¨çå§61 this.POST_ARTICLESORTUSER_QUERYCOUNTBYSORTID = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSortUser/queryCountBySortId'; // æ¥è¯¢å¤å°äººå
³æ³¨äºå§62 this.POST_ARTICLESORTUSER_ISFOLLOW = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSortUser/isFollow'; // æ¥çç¨æ·æ¯å¦å
³æ³¨è´´å§63 this.POST_ARTICLESORTUSER_INSERT = (this.isLocalHost?'/apis':this.origin)+'/wm/articleSortUser/insert'; // æå
¥64 65 }66 ...
skynet-utils.js
Source:skynet-utils.js
1// Determine if we running on local machine.2import {genKeyPairFromSeed, SkynetClient} from "skynet-js";3import {ContentRecordDAC} from "@skynethq/content-record-library";4import {UserProfileDAC} from "@skynethub/userprofile-library";5export const isLocalhost = window.location.hostname === 'localhost';6console.debug(`Running on Localhost: ${isLocalhost}`);7// Comment this line out in order to get debug logs.8if (!isLocalhost) {9 console.debug = function () {10 }11}12// We'll define a portal to allow for developing on localhost.13// When hosted on a skynet portal, SkynetClient doesn't need any arguments.14export const skynetPortal = isLocalhost ? 'https://siasky.net/' : undefined;15export const skynetClient = new SkynetClient(skynetPortal);16// Global secret for generating seed.17export const SKAPP_SECRET = "sup3rs3cr3t";18export const SKAPP_PRIVATE_KEY = genKeyPairFromSeed(SKAPP_SECRET).privateKey;19export const SKAPP_PUBLIC_KEY = genKeyPairFromSeed(SKAPP_SECRET).publicKey;20export const SKAPP_DATA_KEY = isLocalhost ? "howabouts-dev-release-candidate-r42" : "howabouts-prod-beta-r42"21export const SKAPP_DATA_DOMAIN = isLocalhost ? "how-about-skapp-dev-release-candidate-r42" : "how-about-skapp-prod-beta-r42";22export const SKAPP_DATA_KEY_COMMENTS = isLocalhost ? "howabouts-dev-comment-release-candidate-r42" : "howabouts-prod-comments-beta-r42"23export const MYSKY_LIKES_FILE_PATH = SKAPP_DATA_DOMAIN + "/mysky-likes";24export const MYSKY_PROPOSALS_FILE_PATH = SKAPP_DATA_DOMAIN + "/mysky-proposals";25// Used to call method against the Content Record DAC's API.26export const contentRecord = new ContentRecordDAC();27// Used to call method against the User Profile DAC's API.28export const userProfile = new UserProfileDAC();...
main.js
Source:main.js
...28* @param {*} value - value to test29* @returns {boolean} boolean indicating whether value is a localhost hostname30*31* @example32* var bool = isLocalhost( 'localhost' );33* // returns true34*35* @example36* var bool = isLocalhost( '127.0.0.1' );37* // returns true38*39* @example40* var bool = isLocalhost( '[::1]' );41* // returns true42*43* @example44* var bool = isLocalhost( 'wikipedia.org' );45* // returns false46*47* @example48* var bool = isLocalhost( 'stdlib.io' );49* // returns false50*51* @example52* var bool = isLocalhost( null );53* // returns false54*/55function isLocalhost( value ) {56 if ( !isString( value ) ) {57 return false;58 }59 return (60 value === 'localhost' || value === 'LOCALHOST' ||61 // IPv6 localhost address:62 value === '[::1]' ||63 RE_LOCALHOST_IPV4.test( value )64 );65}66// EXPORTS //...
index.js
Source:index.js
...23*24* @example25* var isLocalhost = require( '@stdlib/assert-is-localhost' );26*27* var bool = isLocalhost( 'localhost' );28* // returns true29*30* bool = isLocalhost( '127.0.0.1' );31* // returns true32*33* bool = isLocalhost( '[::1]' );34* // returns true35*36* bool = isLocalhost( 'stdlib.io' );37* // returns false38*/39// MODULES //40var isLocalhost = require( './main.js' );41// EXPORTS //...
config.prod.js
Source:config.prod.js
1const islocalhost = false;2const httplink = islocalhost?'http://localhost:4901':'http://yc.i2u.top:8000/graphql'3const wslink = islocalhost?'http://localhost:4901':'ws://yc.i2u.top:8000/graphql'4const serverurl = islocalhost?'http://localhost:4901':'http://api.cloudclubonline.com';5const serverurlrestful = islocalhost?`${serverurl}/api`:`${serverurl}/api`;6const wspath = islocalhost?'/socket.io':'/socket.io';7let config = {8 httplink,9 wslink,10 issimulate:false,11 serverurlrestful,12 serverurl:`${serverurl}`,13 wspath:`${wspath}`,14 requesttimeout:5000,15 appversion:'1.0.1(build0903)',16 sendlocationinterval:20000,17 softmode:'app'18};...
config.dev.js
Source:config.dev.js
1const islocalhost = false;2const httplink = islocalhost?'http://localhost:4901':'http://yc.i2u.top:8000/graphql'3const wslink = islocalhost?'http://localhost:4901':'ws://yc.i2u.top:8000/graphql'4const serverurl = islocalhost?'http://localhost:4901':'http://api.cloudclubonline.com';5const serverurlrestful = islocalhost?`${serverurl}/api`:`${serverurl}/api`;6const wspath = islocalhost?'/socket.io':'/socket.io';7let config = {8 httplink,9 wslink,10 issimulate:false,11 serverurlrestful,12 serverurl:`${serverurl}`,13 wspath:`${wspath}`,14 requesttimeout:5000,15 appversion:'1.0.0(build0903)',16 sendlocationinterval:20000,17 softmode:'app'18}...
Using AI Code Generation
1const isLocalhost = require('stryker-parent/isLocalhost');2isLocalhost('localhost');3const isLocalhost = require('stryker-parent/isLocalhost');4isLocalhost('localhost');5const isLocalhost = require('stryker-parent/isLocalhost');6isLocalhost('localhost');7const isLocalhost = require('stryker-parent/isLocalhost');8isLocalhost('localhost');9const isLocalhost = require('stryker-parent/isLocalhost');10isLocalhost('localhost');11const isLocalhost = require('stryker-parent/isLocalhost');12isLocalhost('localhost');13const isLocalhost = require('stryker-parent/isLocalhost');14isLocalhost('localhost');15const isLocalhost = require('stryker-parent/isLocalhost');16isLocalhost('localhost');17const isLocalhost = require('stryker-parent/isLocalhost');18isLocalhost('localhost');19const isLocalhost = require('stryker-parent/isLocalhost');20isLocalhost('localhost');21const isLocalhost = require('stryker-parent/isLocalhost');22isLocalhost('localhost');23const isLocalhost = require('stryker-parent/isLocalhost');24isLocalhost('localhost');25const isLocalhost = require('stryker-parent/isLocalhost');26isLocalhost('localhost
Using AI Code Generation
1const isLocalhost = require('stryker-parent/isLocalhost');2const isLocalhost = require('stryker-parent').isLocalhost;3const isLocalhost = require('stryker-parent/isLocalhost');4const isLocalhost = require('stryker-parent').isLocalhost;5const isLocalhost = require('stryker-parent/isLocalhost');6const isLocalhost = require('stryker-parent').isLocalhost;7const isLocalhost = require('stryker-parent/isLocalhost');8const isLocalhost = require('stryker-parent').isLocalhost;9const isLocalhost = require('stryker-parent/isLocalhost');10const isLocalhost = require('stryker-parent').isLocalhost;11const isLocalhost = require('stryker-parent/isLocalhost');12const isLocalhost = require('stryker-parent').isLocalhost;13const isLocalhost = require('stryker-parent/isLocalhost');14const isLocalhost = require('stryker-parent').isLocalhost;15const isLocalhost = require('stryker-parent/isLocalhost');16const isLocalhost = require('stryker-parent').isLocalhost;17const isLocalhost = require('stryker-parent/isLocalhost');18const isLocalhost = require('stryker-parent').isLocalhost;19const isLocalhost = require('stryker-parent/isLocalhost');20const isLocalhost = require('stryker-parent').isLocalhost;21const isLocalhost = require('stryker
Using AI Code Generation
1var isLocalhost = require('stryker-parent').isLocalhost;2var isLocalhost = require('stryker-parent').isLocalhost;3var isLocalhost = require('stryker-parent').isLocalhost;4var isLocalhost = require('stryker-parent').isLocalhost;5var isLocalhost = require('stryker-parent').isLocalhost;6var isLocalhost = require('stryker-parent').isLocalhost;7var isLocalhost = require('stryker-parent').isLocalhost;8var isLocalhost = require('stryker-parent').isLocalhost;9var isLocalhost = require('stryker-parent').isLocalhost;10var isLocalhost = require('stryker-parent').isLocalhost;11var isLocalhost = require('stryker-parent').isLocalhost;12var isLocalhost = require('stryker-parent').isLocalhost;13var isLocalhost = require('stryker-parent').isLocalhost;14var isLocalhost = require('stryker-parent').isLocalhost;
Using AI Code Generation
1var Stryker = require('stryker-parent');2var isLocalhost = Stryker.isLocalhost;3var isLocalhost = require('stryker-parent').isLocalhost;4var isLocalhost = require('stryker-parent').isLocalhost;5var isLocalhost = require('stryker-parent').isLocalhost;6var isLocalhost = require('stryker-parent').isLocalhost;7var isLocalhost = require('stryker-parent').isLocalhost;8var isLocalhost = require('stryker-parent').isLocalhost;9var isLocalhost = require('stryker-parent').isLocalhost;10var isLocalhost = require('stryker-parent').isLocalhost;11var isLocalhost = require('stryker-parent').isLocalhost;12var isLocalhost = require('stryker-parent').isLocalhost;13var isLocalhost = require('stryker-parent').isLocalhost;14var isLocalhost = require('stryker-parent').isLocalhost;15var isLocalhost = require('stryker-parent').isLocalhost;16var isLocalhost = require('stryker-parent').isLocalhost;
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!