This repository has been archived by the owner on Jul 15, 2019. It is now read-only.
forked from proverma/arrow
-
Notifications
You must be signed in to change notification settings - Fork 59
/
arrow-tests.js
77 lines (63 loc) · 2.86 KB
/
arrow-tests.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
/*
* Copyright (c) 2012-2013, Yahoo! Inc. All rights reserved.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
YUI.add('arrow-tests', function (Y, NAME) {
var path = require('path'),
curDir,
arrowRoot = path.join(__dirname, '../../../..'),
Arrow = require(arrowRoot + '/lib/interface/arrow'),
StubDriver = require(arrowRoot + '/tests/unit/stub/driver.js');
controllerName = 'tests/unit/stub/controller.js';
controllerNameAbsolute = path.join(arrowRoot, controllerName);
suite = new Y.Test.Suite(NAME),
A = Y.Assert;
suite.add(new Y.Test.Case({
'setUp': function () {
curDir = process.cwd();
process.chdir(arrowRoot);
},
'tearDown': function () {
process.chdir(curDir);
},
'test controller': function () {
var driver = new StubDriver(),
arrow,
executed = false;
arrow = new Arrow();
arrow.runController(controllerName, {}, {param: "value"}, driver, function (errMsg, data, controller) {
executed = true;
A.isTrue(!errMsg, 'Should have successfully executed controller');
A.areEqual(controller.testParams.param, "value", "Controller should get the parameter");
});
A.isTrue(executed, 'Should have executed controller');
executed = false;
arrow.runController(controllerNameAbsolute, {}, {param: "value"}, driver, function (errMsg, data, controller) {
executed = true;
A.isTrue(!errMsg, 'Should have successfully executed controller');
A.areEqual(controller.testParams.param, "value", "Controller should get the parameter");
});
A.isTrue(executed, 'Should have executed controller');
},
'test error controller': function () {
var driver = new StubDriver(),
arrow,
executed = false;
arrow = new Arrow();
arrow.runController(controllerName, {}, {error: "error"}, driver, function (errMsg) {
executed = true;
A.isString(errMsg, 'Should have failed to execute controller');
});
A.isTrue(executed, 'Should have executed controller');
executed = false;
arrow = new Arrow();
arrow.runController(controllerName, {}, {testName: "error", error: "error"}, driver, function (errMsg) {
executed = true;
A.isString(errMsg, 'Should have failed to execute controller');
});
A.isTrue(executed, 'Should have executed controller with testName');
}
}));
Y.Test.Runner.add(suite);
}, '0.0.1' ,{requires:['test']});