Skip to content

Commit a7b6acc

Browse files
committed
chore: upgrade lab to v15
Signed-off-by: Robinson Rodriguez <[email protected]>
1 parent 881b62a commit a7b6acc

11 files changed

+374
-810
lines changed

package-lock.json

+196-456
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"dotenv": "^5.0.1",
5252
"final-fs": "^1.6.0",
5353
"inflection": "^1.10.0",
54+
"lab": "15.x",
5455
"mkdirp": "~0.5.0",
5556
"parse-database-url": "~0.3.0",
5657
"prompt": "^1.0.0",
@@ -71,7 +72,6 @@
7172
"eslint-plugin-node": "^8.0.1",
7273
"eslint-plugin-promise": "^4.0.1",
7374
"eslint-plugin-standard": "^4.0.0",
74-
"lab": "^14.3.1",
7575
"proxyquire": "^1.4.0",
7676
"rimraf": "^2.6.2",
7777
"sinon": "^7.2.2"

test/config_test.js

+24-70
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,21 @@ lab.experiment('config', function () {
1212
var configPath = path.join(__dirname, 'database.json');
1313
var _config = config.load(configPath, 'dev');
1414

15-
lab.test(
16-
'should export all environment settings',
17-
18-
function (done) {
19-
Code.expect(_config.dev).to.exists();
20-
Code.expect(_config.test).to.exists();
21-
Code.expect(_config.prod).to.exists();
22-
done();
23-
}
24-
);
15+
lab.test('should export all environment settings', () => {
16+
Code.expect(_config.dev).to.exists();
17+
Code.expect(_config.test).to.exists();
18+
Code.expect(_config.prod).to.exists();
19+
});
2520

2621
lab.test(
2722
'should export a getCurrent function with all current ' +
28-
'environment settings',
29-
30-
function (done) {
23+
'environment settings', () => {
3124
var current;
3225
Code.expect(_config.getCurrent).to.exists();
3326
current = _config.getCurrent();
3427
Code.expect(current.env).to.equal('dev');
3528
Code.expect(current.settings.driver).to.equal('sqlite3');
3629
Code.expect(current.settings.filename).to.equal(':memory:');
37-
done();
3830
}
3931
);
4032
});
@@ -45,12 +37,11 @@ lab.experiment('config', function () {
4537
function () {
4638
var configPath = path.join(__dirname, 'database_with_syntax_error.json');
4739

48-
lab.test('should throw a syntax error', function (done) {
40+
lab.test('should throw a syntax error', async () => {
4941
Code.expect(
5042
config.load.bind(this, configPath, 'dev'),
5143
'Expected broken file to produce syntax error'
5244
).to.throw(SyntaxError);
53-
done();
5445
});
5546
}
5647
);
@@ -63,14 +54,11 @@ lab.experiment('config', function () {
6354
var _config = config.load(configPath);
6455

6556
lab.test(
66-
'should load a value from the default env',
67-
68-
function (done) {
57+
'should load a value from the default env', () => {
6958
var current = _config.getCurrent();
7059
Code.expect(current.env).to.equal('local');
7160
Code.expect(current.settings.driver).to.equal('sqlite3');
7261
Code.expect(current.settings.filename).to.equal(':memory:');
73-
done();
7462
}
7563
);
7664
}
@@ -88,13 +76,10 @@ lab.experiment('config', function () {
8876
var _config = config.load(configPath);
8977

9078
lab.test(
91-
'should load a value from the env set in NODE_ENV',
92-
93-
function (done) {
79+
'should load a value from the env set in NODE_ENV', () => {
9480
var current = _config.getCurrent();
9581
Code.expect(current.settings.driver).to.equal('sqlite3');
9682
Code.expect(current.settings.filename).to.equal(':memory:');
97-
done();
9883
}
9984
);
10085
}
@@ -109,11 +94,8 @@ lab.experiment('config', function () {
10994
var _config = config.load(configPath, 'prod');
11095

11196
lab.test(
112-
'should load a value from the environments',
113-
114-
function (done) {
97+
'should load a value from the environments', () => {
11598
Code.expect(_config.prod.username).to.equal('username_from_env');
116-
done();
11799
}
118100
);
119101
}
@@ -128,16 +110,13 @@ lab.experiment('config', function () {
128110
var _config = config.load(configPath, 'prod');
129111

130112
lab.test(
131-
'should load a value from the environments',
132-
133-
function (done) {
113+
'should load a value from the environments', () => {
134114
var current = _config.getCurrent();
135115
Code.expect(current.settings.driver).to.equal('postgres');
136116
Code.expect(current.settings.user).to.equal('uname');
137117
Code.expect(current.settings.password).to.equal('pw');
138118
Code.expect(current.settings.host).to.equal('server.com');
139119
Code.expect(current.settings.database).to.equal('dbname');
140-
done();
141120
}
142121
);
143122
}
@@ -148,19 +127,14 @@ lab.experiment('config', function () {
148127
var _config = config.loadUrl(databaseUrl, 'dev');
149128

150129
lab.test(
151-
'should export the settings as the current environment',
152-
153-
function (done) {
130+
'should export the settings as the current environment', () => {
154131
Code.expect(_config.dev).to.exists();
155-
done();
156132
}
157133
);
158134

159135
lab.test(
160136
'should export a getCurrent function with all current ' +
161-
'environment settings',
162-
163-
function (done) {
137+
'environment settings', () => {
164138
var current;
165139
Code.expect(_config.getCurrent).to.exists();
166140
current = _config.getCurrent();
@@ -170,7 +144,6 @@ lab.experiment('config', function () {
170144
Code.expect(current.settings.password).to.equal('pw');
171145
Code.expect(current.settings.host).to.equal('server.com');
172146
Code.expect(current.settings.database).to.equal('dbname');
173-
done();
174147
}
175148
);
176149
});
@@ -180,14 +153,13 @@ lab.experiment('config', function () {
180153
config.load = _configLoad;
181154
config.loadUrl = _configLoadUrl;
182155

183-
lab.test('should something', function (done) {
156+
lab.test('should something', () => {
184157
Code.expect(config.load.bind(this, configPath, 'dev')).to.not.throw();
185-
done();
186158
});
187159
});
188160

189161
lab.experiment('loading a url from url property', function () {
190-
lab.test('should export a valid config', function (done) {
162+
lab.test('should export a valid config', () => {
191163
var databaseUrl = {
192164
dev: {
193165
url: 'postgres://uname:[email protected]/dbname'
@@ -204,13 +176,9 @@ lab.experiment('config', function () {
204176
Code.expect(current.settings.password).to.equal('pw');
205177
Code.expect(current.settings.host).to.equal('server.com');
206178
Code.expect(current.settings.database).to.equal('dbname');
207-
208-
done();
209179
});
210180

211-
lab.test('should export the value if specified in suboject', function (
212-
done
213-
) {
181+
lab.test('should export the value if specified in suboject', () => {
214182
var databaseUrl = {
215183
dev: {
216184
url: {
@@ -224,8 +192,6 @@ lab.experiment('config', function () {
224192
var current = cfg.getCurrent();
225193
Code.expect(current.env).to.equal('dev');
226194
Code.expect(current.settings.url).to.equal('http://example.com');
227-
228-
done();
229195
});
230196
});
231197

@@ -241,16 +207,12 @@ lab.experiment('config', function () {
241207

242208
var cfg = config.loadObject(databaseUrl, 'dev');
243209

244-
lab.test('should export the settings as the current environment', function (
245-
done
246-
) {
210+
lab.test('should export the settings as the current environment', () => {
247211
Code.expect(cfg.dev).to.exists();
248-
done();
249212
});
250213

251214
lab.test(
252-
'should export a getCurrent function with all current environment settings',
253-
function (done) {
215+
'should export a getCurrent function with all current environment settings', () => {
254216
Code.expect(cfg.getCurrent).to.exists();
255217
var current = cfg.getCurrent();
256218
Code.expect(current.env).to.equal('dev');
@@ -262,8 +224,6 @@ lab.experiment('config', function () {
262224
Code.expect(current.settings.host).to.equal('server.com');
263225
Code.expect(current.settings.database).to.equal('dbname');
264226
Code.expect(current.settings.ssl).to.equal(true);
265-
266-
done();
267227
}
268228
);
269229
});
@@ -273,7 +233,7 @@ lab.experiment('config', function () {
273233
function () {
274234
lab.test(
275235
'should export a getCurrent function with all current environment settings',
276-
function (done, cleanup) {
236+
function (flags) {
277237
process.env.DATABASE_URL = 'postgres://uname:[email protected]/dbname';
278238
var databaseUrl = {
279239
dev: {
@@ -285,10 +245,9 @@ lab.experiment('config', function () {
285245
};
286246
var cfg = config.loadObject(databaseUrl, 'dev');
287247

288-
cleanup(function (next) {
248+
flags.onCleanup = () => {
289249
delete process.env.DATABASE_URL;
290-
next();
291-
});
250+
};
292251

293252
Code.expect(cfg.getCurrent).to.exists();
294253
var current = cfg.getCurrent();
@@ -301,8 +260,6 @@ lab.experiment('config', function () {
301260
Code.expect(current.settings.host).to.equal('server.com');
302261
Code.expect(current.settings.database).to.equal('dbname');
303262
Code.expect(current.settings.ssl).to.equal(true);
304-
305-
done();
306263
}
307264
);
308265
}
@@ -311,7 +268,7 @@ lab.experiment('config', function () {
311268
lab.experiment(
312269
'loading from an ENV URL within the object and extending it from the ENV',
313270
function () {
314-
lab.test('', function (done, cleanup) {
271+
lab.test('', function (flags) {
315272
process.env.DATABASE_URL =
316273
'postgres://uname:[email protected]/dbname?ssl=false&testing=false';
317274
var databaseUrl = {
@@ -332,10 +289,9 @@ lab.experiment('config', function () {
332289
};
333290
var cfg = config.loadObject(databaseUrl, 'dev');
334291

335-
cleanup(function (next) {
292+
flags.onCleanup = () => {
336293
delete process.env.DATABASE_URL;
337-
next();
338-
});
294+
};
339295

340296
Code.expect(cfg.getCurrent).to.exists();
341297
var current = cfg.getCurrent();
@@ -352,8 +308,6 @@ lab.experiment('config', function () {
352308
Code.expect(current.settings.testing).to.equal('false');
353309
Code.expect(current.settings.cache).to.equal(false);
354310
Code.expect(current.settings.ssl).to.equal(true);
355-
356-
done();
357311
});
358312
}
359313
);

test/driver/base_test.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ lab.experiment('base', function () {
1515
lab.experiment('default implementation', function () {
1616
var base = new Base(internals);
1717

18-
lab.test('inherits from EventEmitter', function (done) {
18+
lab.test('inherits from EventEmitter', () => {
1919
Code.expect(base.on).to.be.not.null();
2020
Code.expect(base.emit).to.be.not.null();
21-
done();
2221
});
2322

24-
lab.test('throws errors for all API methods', function (done) {
23+
lab.test('throws errors for all API methods', () => {
2524
Code.expect(function () {
2625
base.createTable();
2726
}).to.throw(Error);
@@ -77,15 +76,12 @@ lab.experiment('base', function () {
7776
Code.expect(function () {
7877
base.runSql();
7978
}).to.throw(Error);
80-
81-
done();
8279
});
8380

84-
lab.test('escapes single quotes', function (done) {
81+
lab.test('escapes single quotes', () => {
8582
Code.expect("Bill''s Mother''s House").to.equal(
8683
base.escape("Bill's Mother's House")
8784
);
88-
done();
8985
});
9086
});
9187
});

0 commit comments

Comments
 (0)