View usingcabundle.js
var https = require('https'); | |
var fs = require('fs'); | |
var options = { | |
hostname: 'encrypted.google.com', | |
port: 443, | |
path: '/', | |
method: 'GET', | |
key: fs.readFileSync('/yourapp/certs/privkey.pem'), | |
cert: fs.readFileSync('/yourapp/certs/bundle.pem'), // a PEM containing the SERVER and ALL INTERMEDIATES | |
rejectUnauthorized: true |
View usingcaccerts.js
var https = require('https'); | |
var fs = require('fs'); | |
var options = { | |
hostname: 'encrypted.google.com', | |
port: 443, | |
path: '/', | |
method: 'GET', | |
ca: [fs.readFileSync('/yourapp/certs/intCA1Cert.pem'), fs.readFileSync('/yourapp/certs/ rootCACert.pem')], | |
rejectUnauthorized: true | |
}; |
View usingcert.js
var https = require('https'); | |
var fs = require('fs'); | |
var options = { | |
hostname: 'encrypted.google.com', | |
port: 443, | |
path: '/', | |
method: 'GET', | |
key: fs.readFileSync('/ yourapp/certs/key.pem'), | |
cert: fs.readFileSync('/yourapp/certs/cert.pem'), | |
rejectUnauthorized: true |
View thewrongway.js
var https = require('https'); | |
var options = { | |
hostname: 'encrypted.google.com', | |
port: 443, | |
path: '/', | |
method: 'GET', | |
rejectUnauthorized: false | |
}; | |
var req = https.request(options, function(res) { |
View example1-test.js
describe("The selectAnimal function", function(){ | |
it("should return Cat"){ | |
expect(window.myLib.selectAnimal("c")).toBe("Cat"); | |
}; | |
it("should return Dog"){ | |
expect(window.myLib.selectAnimal("d")).toBe("Dog"); | |
}; | |
it("should return unknown"){ | |
expect(window.myLib.selectAnimal()).toBe("unknown"); | |
} |
View example5.js
(function(){ //opens the closure | |
//definition of private object Animal | |
var Animal= function(){ | |
this.name=""; | |
}; | |
Animal.prototype={ | |
getAnimal : function(code){ | |
var s = this; |
View example5-test.js
describe("The getAnimalCallBackFn function", function(){ | |
it("should set Animal name property"){ | |
window.myLib.initialize(); | |
window.myLib.selector.getAnimal (); | |
window.myLib.selector.getAnimalCallBackFn("dog"); | |
expect(window.myLib.selector.name).toBe("dog"); | |
}; | |
}); |
View example4.js
(function(){ //opens the closure | |
//definition of private object Animal | |
var Animal= function(){ | |
this.name=""; | |
}; | |
Animal.prototype={ | |
getAnimal : function(code){ | |
//AJAX call to get the description |
View example3.js
(function(){ //opens the closure | |
//definition of private object Animal | |
var Animal= function(){ | |
this.name=""; | |
}; | |
Animal.prototype={ | |
getAnimal : function(code){ | |
if(code=="c"){ |
View example3-test.js
describe("The getAnimal function", function(){ | |
beforeEach(function(){ | |
window.myLib.initialize(); | |
}); | |
it("should set Animal name property to Cat"){ | |
window.myLib.selector.getAnimal("c") | |
expect(window.myLib.selector.name).toBe("Cat"); | |
}; | |
it("should set Animal name property to Dog"){ | |
window.myLib.selector.getAnimal("d") |
NewerOlder