-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathoption.js
89 lines (71 loc) · 2.42 KB
/
option.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
87
88
89
'use strict';
var assert = require('assert');
var should = require('should');
var App = require('..');
var app;
describe('.option()', function() {
beforeEach(function () {
app = new App();
})
it('should set an option.', function() {
app.option('a', 'b');
app.options.should.have.property('a');
});
it('should get an option.', function() {
app.option('a', 'b');
app.option('a').should.equal('b');
});
it('should extend the `options` object.', function() {
app.option({x: 'xxx', y: 'yyy', z: 'zzz'});
app.option('x').should.equal('xxx');
app.option('y').should.equal('yyy');
app.option('z').should.equal('zzz');
});
it('options should be on the `options` object.', function() {
app.option({x: 'xxx', y: 'yyy', z: 'zzz'});
app.options.x.should.equal('xxx');
app.options.y.should.equal('yyy');
app.options.z.should.equal('zzz');
});
it('should be chainable.', function() {
app.option({x: 'xxx', y: 'yyy', z: 'zzz'});
app.option({a: 'aaa', b: 'bbb', c: 'ccc'});
app.option('x').should.equal('xxx');
app.option('a').should.equal('aaa');
});
it('should extend the `options` object when the first param is a string.', function() {
app.option('foo', {x: 'xxx', y: 'yyy', z: 'zzz'})
app.option('bar', {a: 'aaa', b: 'bbb', c: 'ccc'});
app.option('foo').should.have.property('x');
app.option('bar').should.have.property('a');
app.options.foo.should.have.property('x');
app.options.bar.should.have.property('a');
});
it('should set an option.', function() {
app.option('a', 'b');
app.options.should.have.property('a');
});
it('should get an option.', function() {
app.option('a', 'b');
app.option('a').should.equal('b');
});
it('should extend the `options` object.', function() {
app.option({x: 'xxx', y: 'yyy', z: 'zzz'});
app.option('x').should.equal('xxx');
app.option('y').should.equal('yyy');
app.option('z').should.equal('zzz');
});
it('options should be on the `options` object.', function() {
app.option({x: 'xxx', y: 'yyy', z: 'zzz'});
app.options.x.should.equal('xxx');
app.options.y.should.equal('yyy');
app.options.z.should.equal('zzz');
});
it('should be chainable.', function() {
app
.option({x: 'xxx', y: 'yyy', z: 'zzz'})
.option({a: 'aaa', b: 'bbb', c: 'ccc'});
app.option('x').should.equal('xxx');
app.option('a').should.equal('aaa');
});
});