Skip to content

Commit

Permalink
split up test file
Browse files Browse the repository at this point in the history
  • Loading branch information
svozza committed Apr 20, 2016
1 parent fb92d05 commit e2e944f
Show file tree
Hide file tree
Showing 67 changed files with 5,244 additions and 4,922 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ README.md: index.js

.PHONY: lint
lint:
$(JSHINT) -- index.js test/index.js
$(JSCS) -- index.js test/index.js
$(JSHINT) -- index.js test/**/*.js
$(JSCS) -- index.js test/**/*.js
@echo 'Checking for missing link definitions...'
grep -o '\[[^]]*\]\[[^]]*\]' index.js \
| sort -u \
Expand Down
23 changes: 23 additions & 0 deletions test/A.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
var eq = require('./shared/utils').eq;
var R = require('ramda');
var S = require('..');

describe('A', function() {

it('is a binary function', function() {
eq(typeof S.A, 'function');
eq(S.A.length, 2);
});

it('A(f, x) is equivalent to f(x)', function() {
eq(S.A(S.inc, 1), 2);
eq(R.map(S.A(R.__, 100), [S.inc, Math.sqrt]), [101, 10]);
});

it('is curried', function() {
eq(S.A(S.inc).length, 1);
eq(S.A(S.inc)(1), 2);
});

});
10 changes: 10 additions & 0 deletions test/B.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';
var runCompositionTests = require('./shared/utils').runCompositionTests;
var S = require('..');

describe('B', function() {

runCompositionTests(S.B);

});

24 changes: 24 additions & 0 deletions test/C.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';
var eq = require('./shared/utils').eq;
var R = require('ramda');
var S = require('..');

describe('C', function() {

it('is a ternary function', function() {
eq(typeof S.C, 'function');
eq(S.C.length, 3);
});

it('C(f, x, y) is equivalent to f(y)(x)', function() {
eq(S.C(S.concat, 'foo', 'bar'), 'barfoo');
eq(R.map(S.C(S.concat, '!'), ['BAM', 'POW', 'KA-POW']), ['BAM!', 'POW!', 'KA-POW!']);
});

it('is curried', function() {
eq(S.C(S.concat).length, 2);
eq(S.C(S.concat)('foo').length, 1);
eq(S.C(S.concat)('foo')('bar'), 'barfoo');
});

});
13 changes: 13 additions & 0 deletions test/Either.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';
var errorEq = require('./shared/utils').errorEq;
var S = require('..');
var throws = require('assert').throws;

describe('Either', function() {

it('throws if called', function() {
throws(function() { S.Either(); },
errorEq(Error, 'Cannot instantiate Either'));
});

});
14 changes: 14 additions & 0 deletions test/EitherType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
var $ = require('sanctuary-def');
var eq = require('./shared/utils').eq;
var S = require('..');

describe('EitherType', function() {

it('has its type definition exported', function() {
eq(S.EitherType($.String, $.Number).test(S.Left('Error')), true);
eq(S.EitherType($.String, $.Number).test(S.Right(1)), true);
eq(S.EitherType($.String, $.Number).test(1), false);
});

});
18 changes: 18 additions & 0 deletions test/I.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';
var eq = require('./shared/utils').eq;
var S = require('..');

describe('I', function() {

it('is a unary function', function() {
eq(typeof S.I, 'function');
eq(S.I.length, 1);
});

it('returns its argument', function() {
eq(S.I([1, 2, 3]), [1, 2, 3]);
eq(S.I({'@@type': 'my-package/Foreign'}),
{'@@type': 'my-package/Foreign'});
});

});
Loading

0 comments on commit e2e944f

Please sign in to comment.