View usingcabundle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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