forked from oracle/node-oracledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instanceof.js
154 lines (130 loc) · 3.97 KB
/
instanceof.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. */
/******************************************************************************
*
* You may not use the identified files except in compliance with the Apache
* License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*
* NAME
* 45. instanceof.js
*
* DESCRIPTION
* Testing JS instanceof.
*
* NUMBERING RULE
* Test numbers follow this numbering rule:
* 1 - 20 are reserved for basic functional tests
* 21 - 50 are reserved for data type supporting tests
* 51 onwards are for other tests
*
*****************************************************************************/
'use strict';
var oracledbCLib;
var oracledb = require('oracledb');
var should = require('should');
var dbConfig = require('./dbconfig.js');
describe('45. instanceof.js', function() {
it('45.1 instanceof works for the oracledb instance', function(done) {
(oracledb instanceof oracledb.Oracledb).should.be.true();
done();
});
it('45.2 instanceof works for pool instances', function(done) {
oracledb.createPool(
{
user : dbConfig.user,
password : dbConfig.password,
connectString : dbConfig.connectString,
poolMin : 0,
poolMax : 1,
poolIncrement : 1
},
function(err, pool){
should.not.exist(err);
(pool instanceof oracledb.Pool).should.be.true();
pool.terminate(function(err) {
should.not.exist(err);
done();
});
}
);
});
it('45.3 instanceof works for connection instances', function(done) {
oracledb.getConnection(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString
},
function(err, conn) {
should.not.exist(err);
(conn instanceof oracledb.Connection).should.be.true();
conn.release(function(err) {
should.not.exist(err);
done();
});
}
);
});
it('45.4 instanceof works for resultset instances', function(done) {
oracledb.getConnection(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString
},
function(err, conn) {
should.not.exist(err);
conn.execute(
'select 1 from dual union select 2 from dual',
[], // no binds
{
resultSet: true
},
function(err, result) {
should.not.exist(err);
(result.resultSet instanceof oracledb.ResultSet).should.be.true();
result.resultSet.close(function(err) {
should.not.exist(err);
conn.release(function(err) {
should.not.exist(err);
done();
});
});
}
);
}
);
});
it('45.5 instanceof works for lob instances', function(done) {
oracledb.getConnection(
{
user: dbConfig.user,
password: dbConfig.password,
connectString: dbConfig.connectString
},
function(err, conn) {
should.not.exist(err);
conn.execute(
'select to_clob(dummy) from dual',
function(err, result) {
should.not.exist(err);
(result.rows[0][0] instanceof oracledb.Lob).should.be.true();
conn.release(function(err) {
should.not.exist(err);
done();
});
}
);
}
);
});
});