Skip to content

Commit

Permalink
Update example to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
ciju committed Sep 1, 2016
1 parent 646eb2f commit f67a979
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 41 deletions.
53 changes: 25 additions & 28 deletions describe-example.js
@@ -1,50 +1,47 @@
var assert = require('assert');
var tfns = require('./describe-compiled.js').default,
describe = tfns.describe,
setup = tfns.setup,
teardown = tfns.teardown,
test = tfns.it;

function log() {
console.log.apply(console, arguments);
}

var obj = {};
describe('True Or False? ', function () {
describe('setup', function () {
test('should setup num', function () {
import assert from 'assert';
import {
it as test,
describe as testSuite,
setup,
teardown
} from './describe';

const obj = {};
testSuite('True Or False? ', () => {
testSuite('setup', () => {
test('should setup num', () => {
assert.equal(obj.num, 2);
});
setup(function () {
setup(() => {
obj.num = 2;
});
teardown(function () {
teardown(() => {
obj.num = null;
});
});

describe('teardown', function () {
test('should teardown num', function () {
testSuite('teardown', () => {
test('should teardown num', () => {
assert.equal(obj.num, null);
});
});

describe('truthy => ', function () {
test('empty array', function () {
testSuite('truthy => ', () => {
test('empty array', () => {
assert.equal(!![0], true);
});

test('empty object', function () {
test('empty object', () => {
assert.equal(!!{}, true);
});
});

describe('falsy => ', function () {
describe('undefined & nil', function () {
test('undefined', function () {
testSuite('falsy => ', () => {
testSuite('undefined & nil', () => {
test('undefined', () => {
assert.equal(!(void 0), true);
});
test('null', function () {
test('null', () => {
assert.equal(!null, true);
});
});
Expand All @@ -53,10 +50,10 @@ describe('True Or False? ', function () {
assert.equal(![], true);
});

test('!NaN === true', function () {
test('!NaN === true', () => {
assert.equal(!NaN, true);
});
test('!(empty string) === true', function () {
test('!(empty string) === true', () => {
assert.equal(!'', true);
});
});
Expand Down
22 changes: 10 additions & 12 deletions describe.js
Expand Up @@ -45,16 +45,14 @@ activity.describe = ([title, testFn]) =>
activity.tests = ([title, testFn]) =>
reportTests(testFn, title);

export default {
setup: spush.bind(null, 'setup'),
teardown: spush.bind(null, 'teardown'),
describe: (title, testfn) => {
if (isEmptyStack()) {
execDescribe(title, testfn);
return;
}

spush('describe', [title, testfn]);
},
it: (desc, fn) => spush('tests', [desc, fn])
export const it = (desc, fn) => spush('tests', [desc, fn]);
export const describe = (title, testfn) => {
if (isEmptyStack()) {
execDescribe(title, testfn);
return;
}

spush('describe', [title, testfn]);
};
export const setup = spush.bind(null, 'setup');
export const teardown = spush.bind(null, 'teardown');
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {},
"scripts": {
"start": "babel describe.js -o describe-compiled.js && node describe-example.js"
"start": "babel-node describe-example.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f67a979

Please sign in to comment.