Skip to content

Commit 77a33a3

Browse files
committed
update to chai
1 parent 4179d55 commit 77a33a3

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

Diff for: test/bulk.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
'use strict'
2+
3+
import { createRequire } from 'module'
4+
import chaiAsPromised from 'chai-as-promised'
5+
26
/* globals describe it */
37

8+
const totalObjectsForInsert = 10
9+
const test1BatchSize = 1
10+
const test2BatchSize = 10
11+
const require = createRequire(import.meta.url)
412
const { TestEnv } = require('./env/test-env')
513
const env = new TestEnv()
614
const chai = require('chai')
15+
chai.use(chaiAsPromised)
716
const expect = chai.expect
817
const assert = chai.assert
918

10-
const totalObjectsForInsert = 10
11-
const test1BatchSize = 1
12-
const test2BatchSize = 10
13-
1419
describe('bulk', function () {
1520
this.timeout(100000)
1621

@@ -857,6 +862,11 @@ describe('bulk', function () {
857862
assert(table !== null)
858863
})
859864

865+
async function doesThrow (sql, message, connection) {
866+
const proxy = connection || env.theConnection
867+
await expect(proxy.promises.query(sql)).to.be.rejectedWith(message)
868+
}
869+
860870
it('bulk insert condition failure', async function handler () {
861871
const createTableSql = 'CREATE TABLE Persons (Name varchar(255) NOT NULL)'
862872
await env.theConnection.promises.query(env.dropTableSql('Persons'))
@@ -867,9 +877,9 @@ describe('bulk', function () {
867877
const nullJohn = 'INSERT INTO [Persons] ([Name]) OUTPUT INSERTED.* VALUES (null), (N\'John\')'
868878
const error = 'Cannot insert the value NULL into column'
869879

870-
await env.doesThrow(johnNullSql, error)
871-
await env.doesThrow(nullSql, error)
872-
await env.doesThrow(nullJohn, error)
880+
await doesThrow(johnNullSql, error)
881+
await doesThrow(nullSql, error)
882+
await doesThrow(nullJohn, error)
873883
})
874884

875885
it('non null varchar write empty string', async function handler () {

Diff for: test/env/test-env.js

-5
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,6 @@ class TestEnv {
226226
await pool.close()
227227
}
228228

229-
async doesThrow (sql, message, connection) {
230-
const proxy = connection || this.theConnection
231-
await expect(proxy.promises.query(sql)).to.be.rejectedWith(message)
232-
}
233-
234229
/*
235230
{
236231
+ col_a: 0.2857142857142857,

0 commit comments

Comments
 (0)