UNPKG

1.4 kBJavaScriptView Raw
1var desribeFunction = require('..');
2var fooFilename = __dirname + '/foo.js';
3
4desribeFunction(fooFilename, 'getFoo()', function (getFn) {
5 it('has function argument', function () {
6 la(typeof getFn === 'function');
7 });
8
9 it('returns actual function', function () {
10 var fn = getFn();
11 la(typeof fn === 'function');
12 });
13
14 it('works', function () {
15 var getFoo = getFn();
16 la(getFoo() === 'foo');
17 });
18});
19
20desribeFunction(fooFilename, 'getFoo()', function (getFn) {
21 it('returns "foo"', function () {
22 var getFoo = getFn();
23 la(getFoo() === 'foo');
24 });
25});
26
27desribeFunction(fooFilename, 'getFoo()', function (getFn) {
28 var getFoo;
29
30 beforeEach(function () {
31 getFoo = getFn();
32 });
33
34 it('returns "foo"', function () {
35 la(getFoo() === 'foo');
36 });
37
38 afterEach(function () {
39 la(getFn() === getFoo);
40 });
41});
42
43// storing value in 'this'
44desribeFunction(fooFilename, 'getFoo()', function (getFn) {
45 beforeEach(function () {
46 this.getFoo = getFn();
47 });
48
49 it('returns "foo"', function () {
50 la(this.getFoo() === 'foo');
51 });
52});
53
54// using assign shortcut
55desribeFunction(fooFilename, 'getFoo()', function (getFn) {
56 function assign(property, get) {
57 this[property] = get();
58 return this[property];
59 }
60
61 beforeEach(assign.bind(this.ctx, 'getFoo', getFn));
62
63 it('returns "foo"', function () {
64 la(this.getFoo() === 'foo');
65 });
66});