Skip to content

Instantly share code, notes, and snippets.

@Madhuka
Madhuka / Gruntfile.js
Created March 17, 2015 16:10
'Gruntfile.js' for couchdb-fauxton in windows
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
@Madhuka
Madhuka / convert-fe.js
Created December 12, 2013 07:34
Convert sample
function Convert(number, fromUnit) {
console.log('Starting....');
var conversions = {
distance: {
meters: 1,
cm: 0.01,
feet: 0.3048,
inches: 0.0254,
yards: 0.9144
},
@Madhuka
Madhuka / store-config-spec.js
Created December 9, 2013 10:57
WSO2 Enterprise Store -Test Spec - for jaggery test framework
//define store configuration test suites
describe('TestSuite-StoreConfig', function () {
var storConfig = require('../../config/store.json');
//configuration data for helping to test
var testConfig = {
"assetsUrlPrefix": "/assets",
"extensionsUrlPrefix": "/extensions",
@Madhuka
Madhuka / testframe-test-spec.js
Created December 9, 2013 06:35
Jaggery Test Frame Work testing Spec
//define test suites
describe('TestSuite-JaggeryTestFramework', function () {
it("is defined", function () {
var name = "Andrew";
expect(name).toBeDefined();
})
it("is not defined", function () {
var name;
@Madhuka
Madhuka / Bank.js
Created December 8, 2013 15:41
Jasmine with AJAX and spyon (Sample bank Version 2)
function Bank() {};
Bank.send = function (information){
$.ajax({
method: "POST",
url: "/data",
data: information
});
};
@Madhuka
Madhuka / Data.js
Created December 8, 2013 15:32
Jasmine with AJAX, spyon (Bank Sample versions One - Static Data )
function Bank() {};
Bank.send = function (information){
$.ajax({
method: "POST",
url: "/data",
data: information
});
};
@Madhuka
Madhuka / Car.js
Created December 8, 2013 08:42
Jasmine test with AJAX
function sendRequest(callbacks, configuration) {
$.ajax({
url: configuration.url,
dataType: "json",
success: function(data) {
callbacks.checkForInformation(data);
},
error: function(data) {
callbacks.displayErrorMessage();
},
@Madhuka
Madhuka / MySpec.js
Created November 20, 2013 17:37
Here I am explaining simple jasmine test flow I will be using jasmine 1.3.0 (Blog Post name :: Jasmine exciting structure and the flow @ http://madhukaudantha.blogspot.com/)
describe('Test Suite One', function() {
it('first Test', function() {
expect("Hello world!").toEqual("Hello world!");
});
it('second Test', function() {
expect(1).toBe(1);
});
});
@Madhuka
Madhuka / ConstructorPattern.js
Created November 16, 2013 08:38
Constructor Pattern sample with JS
function Car(config) {
this.name = config.name;
this.engineSize = config.engineSize;
this.toString = function () {
return this.name + " has engine of " + this.engineSize + "cc";
};
this.start = function () {
@Madhuka
Madhuka / ObjectTest.js
Created November 16, 2013 07:16
There are four ways in which keys and values can be assigned to an object: (1,2 are ECMAScript 3 compatible approaches and 3,4 are ECMAScript 5 only compatible approaches)
//1 way
//setter
newObject.someKey = "some value";
//getter
var key = newObject.someKey;
//2nd way
// Set properties
newObject["someKey"] = "some value";
// Get properties