@kavist/arjuna
Version:
Node.js Boilerplate, revisited
72 lines (54 loc) • 1.43 kB
JavaScript
const chai = require('chai'), expect = chai.expect;
chai.use(require('chai-like'));
chai.use(require('chai-things'));
const { sql: connection } = require('../../../.utility/database');
const SqlModel = require('../../../structure/sql-model');
const Repository = require('../../../pattern/repository');
describe('repository all method', function() {
let userRepo = null;
before(function() {
});
after(function() {
});
beforeEach(function() {
class User extends SqlModel {
constructor()
{
super({
connection: connection,
tableName: 'user',
protecteds: [
'password'
],
schema: {
id: {
type: SqlModel.ORM.BIGINT.UNSIGNED,
autoIncrement: true,
allowNull: false,
primaryKey: true
},
username: {
type: SqlModel.ORM.STRING,
},
},
});
}
}
class UserRepo extends Repository {
constructor()
{
super({
model: new User()
});
}
}
userRepo = new UserRepo();
});
afterEach(async function() {
});
it('should success when creating instance from child class', async function() {
const users = await userRepo.all();
expect(userRepo.all).to.be.an('function');
expect(users).to.be.an('array');
});
});