Last change
on this file was
484,
checked in by hendrikvanantwerpen, 11 years ago
|
Commit node_modules, to make checkouts and builds more deterministic.
|
File size:
1.2 KB
|
Line | |
---|
1 | |
---|
2 | /** |
---|
3 | * Module dependencies. |
---|
4 | */ |
---|
5 | |
---|
6 | var Suite = require('../suite') |
---|
7 | , Test = require('../test'); |
---|
8 | |
---|
9 | /** |
---|
10 | * TDD-style interface: |
---|
11 | * |
---|
12 | * exports.Array = { |
---|
13 | * '#indexOf()': { |
---|
14 | * 'should return -1 when the value is not present': function(){ |
---|
15 | * |
---|
16 | * }, |
---|
17 | * |
---|
18 | * 'should return the correct index when the value is present': function(){ |
---|
19 | * |
---|
20 | * } |
---|
21 | * } |
---|
22 | * }; |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | module.exports = function(suite){ |
---|
27 | var suites = [suite]; |
---|
28 | |
---|
29 | suite.on('require', visit); |
---|
30 | |
---|
31 | function visit(obj) { |
---|
32 | var suite; |
---|
33 | for (var key in obj) { |
---|
34 | if ('function' == typeof obj[key]) { |
---|
35 | var fn = obj[key]; |
---|
36 | switch (key) { |
---|
37 | case 'before': |
---|
38 | suites[0].beforeAll(fn); |
---|
39 | break; |
---|
40 | case 'after': |
---|
41 | suites[0].afterAll(fn); |
---|
42 | break; |
---|
43 | case 'beforeEach': |
---|
44 | suites[0].beforeEach(fn); |
---|
45 | break; |
---|
46 | case 'afterEach': |
---|
47 | suites[0].afterEach(fn); |
---|
48 | break; |
---|
49 | default: |
---|
50 | suites[0].addTest(new Test(key, fn)); |
---|
51 | } |
---|
52 | } else { |
---|
53 | var suite = Suite.create(suites[0], key); |
---|
54 | suites.unshift(suite); |
---|
55 | visit(obj[key]); |
---|
56 | suites.shift(); |
---|
57 | } |
---|
58 | } |
---|
59 | } |
---|
60 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.