0.1.0 • Published 13 years ago

suitest v0.1.0

Weekly downloads
43
License
-
Repository
github
Last release
13 years ago

Suitest

Suitest provides easy unit testing for JavaScript code

  • Very simple to use
  • Client-side and server-side (including NodeJS) support
  • One of the most lightweightest libraries for unit testing
  • Support for working with asynchronous code
  • Outline function callbacks!
  • Fluent interface support (chaining)

##Synopsis:

.test( name, callback, [, context ] );
.exec( x, [, y, context ] );
.done( [ name ] );
.text( description );
.stop();
.get();
.is();

Screenshot

Suitest

.test ( name, callback, , context );

var unit = new Suitest;

unit.test('test name', function(unit) {
	unit.exec(true, 1); // true
	unit.done();
});

.exec ( x, , y, context );

Using with one parameter:

unit.exec(true); // true

Using with two parameter:

unit.exec(true, 1); // true, because default operation is ==

Using with three parameters:

unit.exec(true, 1, '==='); // false, because true and 1 are not equivalent

.done ( name );

Simple using:

unit.done();

Testing asynchronous code:

unit.test('test name', function(unit) {
	setTimeout(function() {
		unit.exec(true, 1); // true
		unit.done();
	}, 2000);
});

.text ( description );

unit.text('Test description');

.stop ();

unit.stop();

.is ()

unit.exec(true, 1);
unit.is(); // true

.get ( name );

Outline function callback

var set = function() {
	return unit
		.get('test 6')
		.exec(true, 1)
		.done();
};

Simple using

unit.test('test', function(unit) {
	set(); // true
});

Using with asynchronous code

unit.test('test', function(unit) {
	setTimeout(set, 2000); // true
});

Function.prototype.bind / Function.prototype.call Also you can use it without \<get> method (but this not recommended):

var set = function() {
	return this
		.exec(true, 1)
		.done();
};

unit.test('test', function(unit) {
	set.call(this); // true
});

Chaining (Fluent interface)

var unit = new Suitest;

unit
.test('test 1', function(unit) {
	unit.exec(true, 1).done();
})

.test('test 2', function(unit) {
	unit.text('test description').exec(true, 1).done();
})

.test('test 2', function(unit) {
	if (!unit.exec(true, 1).is())
		unit.stop();
});

##.

  • License Suitest is licensed under the MIT (MIT_LICENSE.txt) license

  • Copyright (c) 2012 Alexander Guinness

0.1.0

13 years ago

0.0.9

13 years ago

0.0.8

13 years ago

0.0.7

13 years ago

0.0.6

13 years ago

0.0.5

13 years ago

0.0.4

13 years ago

0.0.3

13 years ago

0.0.2

13 years ago

0.0.1

13 years ago