Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

simple js framework to run unit tests/behaviors

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .nuget
Octocat-spinner-32 jMoney
Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.markdown
Octocat-spinner-32 jmoney.tests.html
Octocat-spinner-32 minme.bat
README.markdown

Note: tests render in console. Best used with FF3+

API

  • toBe(value)

  • toBeTrue()

  • toBeNull()

  • toBeUndefined()

  • toMatch(regex)

  • toBeNumeric()

.not() can be prepended to any matcher.

.not().toBeTrue()

Simple usage

when.('Using numbers', function() {
    spec('7 should be numberic').expect(7).toBeNumeric();
});

var returnSeven = function() {
    return 7;
};

when.('Using returnSeven', function() {
    spec('Should return 7').expect(returnSeven()).toBe(7);
    spec('Should return numeric value').expect(returnSeven()).toBeNumeric();
});

when('Using anonymous functions', function() {
    spec('Should return the number 7').expect(function() {
        return 7;
    }).toBe(7);
}):

printSummary();

Creating your own matcher (predicate)

jn.Predicates.fn.toBeFoo = function(expected) {
    //expected can either be passed in as an argument i.e toBeFoo('this is the expected value');
    //Or can be explicitly set like so:
    this.expected = 'foo';
    return this.expected === this.actual; //this.actual is the returned value from the expect function
};

Using it

when('Using toBeFoo', function() {
    spec('Should be success when function returns foo').expect(function() {
        return 'foo';
    }).toBeFoo();
}):
Something went wrong with that request. Please try again.