-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.cloneSettings.js
More file actions
96 lines (82 loc) · 2.1 KB
/
Copy pathtest.cloneSettings.js
File metadata and controls
96 lines (82 loc) · 2.1 KB
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
90
91
92
93
94
95
96
var util = require('util'),
should = require('should'),
NDDB = require('./../nddb').NDDB,
JSUS = require('JSUS').JSUS;
var cycle = {};
var options = {
shared: {
a: 1,
b: 2,
c: cycle
},
log: function() {
},
logCtx: {
a: 1,
b: 2
}
};
cycle.cycle = options;
options.logCtx.cycle = cycle;
var db;
var items = [
{
painter: "Jesus",
title: "Tea in the desert",
year: 0,
},
{
painter: "Dali",
title: ["Portrait of Paul Eluard", "Das Rätsel der Begierde", "Das finstere Spiel oder Unheilvolles Spiel"],
year: 1929,
portrait: true
},
{
painter: "Dali",
title: "Barcelonese Mannequin",
year: 1927
},
{
painter: "Monet",
title: {en: "Water Lilies", de: "Wasser Lilies"},
year: 1906
},
{
painter: "Monet",
title: "Wheatstacks (End of Summer)",
year: 1891
},
{
painter: "Manet",
title: "Olympia",
year: 1863
},
];
db = new NDDB(options);
db.importDB(items);
db.addFilter('aa', function() {});
describe('NDDB cloneSettings', function() {
it('should copy shared properties by reference', function(){
var o2 = db.cloneSettings();
o2.shared.c.cycle.should.be.type('object');
});
it('a new db should not have options.shared', function(){
('undefined' === typeof db.__options.shared).should.be.true;
db.__shared.should.be.type('object');
});
it('should copy shared properties by reference with breed method',
function(){
var db2 = db.breed();
('undefined' === typeof db2.__options.shared).should.be.true;
db2.__shared.should.be.type('object');
});
it('should copy log and logCtx properties by reference', function(){
var o2 = db.cloneSettings();
o2.logCtx.cycle.should.be.type('object');
o2.log.should.be.type('function');
});
it('should copy user-defined filters', function(){
var o2 = db.cloneSettings();
o2.filters.aa.should.be.type('function');
});
});