0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Added basic tests for @tryghost/database-info

- these check a few of the imports and static functions
This commit is contained in:
Daniel Lockyer 2022-03-02 14:28:23 +01:00
parent f77983061e
commit 4acf78a08e
3 changed files with 54 additions and 10 deletions

View file

@ -20,6 +20,7 @@
},
"devDependencies": {
"c8": "7.11.0",
"knex": "1.0.3",
"mocha": "9.1.4",
"should": "13.2.3",
"sinon": "12.0.1"

View file

@ -0,0 +1,53 @@
// Switch these lines once there are useful utils
// const testUtils = require('./utils');
require('./utils');
const Knex = require('knex');
const DatabaseInfo = require('../');
describe('DatabaseInfo', function () {
it('should export a class', function () {
DatabaseInfo.should.be.a.class;
});
it('can construct the class', function () {
const knex = Knex({
client: 'sqlite3'
});
const databaseInfo = new DatabaseInfo(knex);
databaseInfo.should.be.an.instanceOf(DatabaseInfo);
});
it('recognises sqlite3 client is SQLite', function () {
const knex = Knex({
client: 'sqlite3'
});
DatabaseInfo.isSQLite(knex).should.be.true();
});
it('recognises better-sqlite3 client is SQLite', function () {
const knex = Knex({
client: 'better-sqlite3'
});
DatabaseInfo.isSQLite(knex).should.be.true();
});
it('recognises mysql client is MySQL', function () {
const knex = Knex({
client: 'mysql'
});
DatabaseInfo.isMySQL(knex).should.be.true();
});
it('recognises mysql2 client is MySQL', function () {
const knex = Knex({
client: 'mysql2'
});
DatabaseInfo.isMySQL(knex).should.be.true();
});
});

View file

@ -1,10 +0,0 @@
// Switch these lines once there are useful utils
// const testUtils = require('./utils');
require('./utils');
describe('Hello world', function () {
it('Runs a test', function () {
// TODO: Write me!
'hello'.should.eql('hello');
});
});