Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

test function that call a function javascrip

var _ = require('lodash');

var Foo = module.exports = function (config) {

  this.config = _.merge({
      role: 'user',
      x: '123',
      y: '321'
    },
    config);

  this.config.role = validateRole(this.config.role);
};

var validateRole = function (role) {
  var roles = [
    'user', 'editor', 'admin'
  ];

  if (_.contains(roles, role)) {
    return role;
  } else {
    return 'user'
  }
};
Comment

test function that call a function javascrip

var chai = require('chai');
var expect = chai.expect;
var Foo = require('../lib/foo');

describe('Foo', function () {

  it('should set role to 'user' if role is not valid', function () {

    var foo = new Foo({role: 'invalid'});
    expect(foo.config.role).to.equal('user');

  });

};
Comment

test function that call a function javascrip

var bar = require('./bar');

var Foo = module.exports = function () {
  this.bar();
  this.barModule();
};
Foo.prototype.bar = function () {};
Foo.prototype.barModule = bar; // setting here as barModule
Comment

test function that call a function javascrip

it('should call the module bar immediately', function () {
  var barSpy = expect.spyOn(Foo.prototype, 'barModule');

  new Foo();

  expect(barSpy).toHaveBeenCalled();    
});
Comment

PREVIOUS NEXT
Code Example
Java :: java Difference Array | Range update query in O(1) 
Java :: JAVA for-each Loop Sytnax 
Java :: java equivalent of pythons getattr 
Java :: How to Fix java.lang.UnsupportedClassVersionError 
Java :: spigot self cancelling scheduler 
Java :: custom class level annotation in spring 
Java :: how to extract value from payload in java 
Java :: how to have multiple extensions in one filter java 
Java :: libgdx load file 
Java :: java radom float 
Java :: how to add new nod in dynamic treeview using javascipt 
Java :: least significant bit java 
Java :: Txt to Json in java 
Java :: file with line numbers inserted java 
Java :: get variable from another class java 
Java :: java int data type 
Java :: trivers json node as node type 
Java :: AndroidManifest.xml file describes the fundamental characteristics of the app and defines each of its components 
Java :: Rotate array to left k cells python 
Java :: multipleQuastion.Java 
Java :: Java headSet(element, booleanValue) 
Java :: why is write replacing my text java 
Java :: linked list introduction 
Java :: also in java 
Java :: search for a string in byte array 
Java :: fibonacci for biginteger 
Java :: Rotate Left k cells java 
Java :: how to refresh activity intent in android 
Java :: ferrari class in java 
Java :: Armstrong Numbers Between Two Integers 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =