This repository has been archived by the owner on Nov 14, 2017. It is now read-only.
/
bdd_spec.js
86 lines (63 loc) · 2.4 KB
/
bdd_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var describe = require('Jody').describe,
describe_under_test = require('../lib/Jody').describe,
specs = require('../lib/Jody').specs;
var createdSpecCase
describe("Describe").
beforeEach( function () {
describe_under_test("example spec");
createdSpecCase = specs.pop();
}).
it("Should set specified description", function () {
createdSpecCase.desc.should().beEqual("example spec");
}).
it("Should create empty array of specs", function () {
createdSpecCase.specs.length.should().beEqual(0);
});
describe("Describe with a beforeEach").
it("Should create beforeEachMethod", function () {
var beforeEachFunction = function () {};
describe_under_test("example spec with beforeEach").
beforeEach(beforeEachFunction);
var specCase = specs.pop();
specCase.beforeEachMethodBody.should().beEqual(beforeEachFunction);
});
var specCase = function () {},
spec_under_test,
itFunction = function () {};
describe("Describe with new spec").
beforeEach(function () {
describe_under_test("example spec with spec").
it("example spec", itFunction);
specCase = specs.pop();
spec_under_test = specCase.specs[0];
}).
it("Should add spec to array of specs", function () {
specCase.specs.length.should().beEqual(1);
}).
it("Should set spec description", function () {
spec_under_test.desc.should().beEqual("example spec");
}).
it("Should set the spec method body", function () {
spec_under_test.methodBody.should().beEqual(itFunction);
}).
it("Should set spec failed until proven passed", function () {
spec_under_test.passed.should().beEqual('unset');
});
describe("Describe spec with After all").
it("Should create after all method", function () {
var afterAllFunction = function (cb) {cb();};
describe_under_test("example spec with after all").
it("a spec", function () {}).
afterAll(afterAllFunction);
var specCase = specs.pop();
specCase.afterAllMethodBody.should().beEqual(afterAllFunction);
});
describe("Describe spec with before All").
it("Should create before method body", function () {
var beforeAllFunction = function () {};
describe_under_test("example spec with after all").
beforeAll(beforeAllFunction).
it("a spec", function () {})
var specCase = specs.pop();
specCase.beforeAllMethodBody.should().beEqual(beforeAllFunction);
});