-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathquoteIdentifier.test.js
More file actions
37 lines (30 loc) · 1006 Bytes
/
quoteIdentifier.test.js
File metadata and controls
37 lines (30 loc) · 1006 Bytes
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
'use strict'
const { describe, test } = require('node:test')
const assert = require('node:assert')
const quoteIdentifier = require('./quoteIdentifier')
describe('quoteIdentifier', () => {
describe('pg', () => {
test('simple', async t => {
assert.deepStrictEqual(quoteIdentifier('identifier', 'pg'), '"identifier"')
})
test('with quotes', async t => {
assert.deepStrictEqual(quoteIdentifier('"quotes"', 'pg'), '"""quotes"""')
})
})
describe('mysql', () => {
test('simple', t => {
assert.deepStrictEqual(quoteIdentifier('identifier', 'mysql'), '`identifier`')
})
test('with quotes', t => {
assert.deepStrictEqual(quoteIdentifier('`quotes`', 'mysql'), '```quotes```')
})
})
describe('without type', () => {
test('simple', t => {
assert.deepStrictEqual(quoteIdentifier('identifier'), '"identifier"')
})
test('with quotes', t => {
assert.deepStrictEqual(quoteIdentifier('"quotes"'), '"""quotes"""')
})
})
})