Skip to content

Instantly share code, notes, and snippets.

@D7Torres
D7Torres / yarn test:jest output
Created December 6, 2019 14:52
Endpoint Refactor - Test result
$ jest src/config/__tests__/endpoint.test.js
PASS src/config/__tests__/endpoint.test.js
endpoint.js
when the service is "webclient"
and being in the server side
✓ an http address with the corresponding ENV, SERVICE and DOMAIN is returned (3ms)
and not being in the server side
and the environment is production
✓ an https address with "www" and without the service, but with the DOMAIN is returned
and the environment is not production
@D7Torres
D7Torres / endpoint.test.js
Last active December 6, 2019 14:42
Endpoint Refactor - Add 100% Test coverage (collapsed)
import endpoint from 'config/endpoint'
describe('endpoint.js', () => {
global.__DOMAIN__ = 'gousto.local'
let service
describe('when the service is "webclient"', () => {
beforeEach(() => {
service = 'webclient'
})
@D7Torres
D7Torres / endpoint.js
Last active December 6, 2019 12:10
Endpoint Refactor - Original
function endpoint(service, version = '') {
let protocol
let domain
if (service === 'webclient') {
protocol = __CLIENT_PROTOCOL__
domain = `${__ENV__}-${service}.${__DOMAIN__}`
if (__SERVER__) {
protocol = 'http'
} else if (__ENV__ === 'production') {
@D7Torres
D7Torres / init.js
Created June 24, 2014 15:52
Creation of two tables witH CQL3
// This is in the init.js of our custom module. I checked that this function is being called.
// There isn't any error. But the tables are not created.
var ensureSchema = function(callback) {
Cassandra.createColumnFamilies({
'PersonalJob': 'CREATE TABLE "PersonalJob" ("revisionId" text PRIMARY KEY, "contentId" text, "jobId" text, "userId" text, "caseName" text, "xmlName" text, "fileName" text, "status" text, "units" int, "maxDuration" int, "result" text, "cost" text)',
'PersonalJobRevision': 'CREATE TABLE "PersonalJobRevision" ("jobId" text PRIMARY KEY, "revisionId" text)'
}, callback);
};