Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
group.before(async () => {
await registrar.providers([
path.join(__dirname, '../providers/SwaggerProvider')
]).register()
// call in boot SwaggerProvider
ace.addCommand('Adonis/Commands/SwaggerExport')
ace.addCommand('Adonis/Commands/SwaggerExportDocs')
ace.addCommand('Adonis/Commands/SwaggerRemove')
ace.addCommand('Adonis/Commands/SwaggerRemoveDocs')
})
test('CommandsProvider', async (assert) => {
await registrar
.providers([path.join(__dirname, '../../providers/CommandsProvider')])
.registerAndBoot()
assert.isDefined(ioc.use('Adonis/Commands/Acl:Setup'))
assert.isFalse(ioc._bindings['Adonis/Commands/Acl:Setup'].singleton)
assert.isDefined(ioc.use('Adonis/Commands/Acl:Role'))
assert.isFalse(ioc._bindings['Adonis/Commands/Acl:Role'].singleton)
assert.isDefined(ioc.use('Adonis/Commands/Acl:Permission'))
assert.isFalse(ioc._bindings['Adonis/Commands/Acl:Permission'].singleton)
})
})
test('CommandsProvider', async (assert) => {
await registrar
.providers([path.join(__dirname, '../../providers/CommandsProvider')])
.registerAndBoot()
assert.isDefined(ioc.use('Adonis/Commands/Notifications:Setup'))
assert.isFalse(ioc._bindings['Adonis/Commands/Notifications:Setup'].singleton)
})
})
const config = new Config()
config.set('database', {
connection: process.env.DB,
sqlite: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, 'db.sqlite3')
}
}
})
return config
})
return registrar
.providers([
'@adonisjs/lucid/providers/LucidProvider'
])
.registerAndBoot()
.then(() => {
const schema = ioc.use('Database').schema
schema.createTable('users', (table) => {
table.increments()
table.string('username').unique()
table.string('email').unique()
table.boolean('is_admin').default(false)
table.string('password')
table.integer('company_id')
table.timestamps()
})
beforeAll(async () => {
ioc.singleton('Adonis/Src/Env', () => new Env())
ioc.alias('Adonis/Src/Env', 'Env')
ioc.singleton('Adonis/Src/Config', function () {
const config = new Config()
config.set('feud', {
tenantColumn: 'tenant_id'
})
return config
})
ioc.alias('Adonis/Src/Config', 'Config')
await registrar
.providers([
'@adonisjs/lucid/providers/LucidProvider',
path.join(__dirname, '../../providers/FeudProvider')
])
.registerAndBoot()
setupResolver()
})
},
options: { apiVersion: '6.4' },
debug: false
}
})
return config
})
ioc.alias('Adonis/Src/Config', 'Config')
ioc.bind('Adonis/Src/Helpers', () => {
return new Helpers(path.join(__dirname))
})
await registrar
.providers([
'@adonisjs/lucid/providers/LucidProvider',
path.join(__dirname, '../../providers/ScoutProvider')
])
.registerAndBoot()
const eventMock = jest.fn()
eventMock.on = jest.fn()
eventMock.emit = jest.fn()
eventMock.removeListener = jest.fn()
ioc.bind('Adonis/Src/Event', () => eventMock)
ioc.alias('Adonis/Src/Event', 'Event')
ioc.bind('Adonis/Src/Model', () => Model)
ioc.alias('Adonis/Src/Model', 'Model')
ioc.bind('Adonis/Src/Config', () => {
const config = new Config()
config.set('database', {
connection: 'testing',
testing: helpers.getConfig()
})
return config
})
ioc.bind('Adonis/Src/Helpers', () => {
return new Helpers(path.join(__dirname))
})
await fs.ensureDir(path.join(__dirname, 'database/migrations'))
await registrar
.providers([
path.join(__dirname, '../../providers/LucidProvider'),
path.join(__dirname, '../../providers/MigrationsProvider')
]).registerAndBoot()
await fs.ensureDir(path.join(__dirname, '../unit/tmp'))
await helpers.createTables(ioc.use('Database'))
setupResolver()
})
ioc.bind('Adonis/Src/Config', () => {
const config = new Config()
config.set('database', {
connection: 'testing',
testing: helpers.getConfig()
})
return config
})
ioc.bind('Adonis/Src/Helpers', () => {
return new Helpers(path.join(__dirname))
})
await fs.ensureDir(path.join(__dirname, 'database/seeds'))
await registrar
.providers([
path.join(__dirname, '../../providers/LucidMongoProvider'),
path.join(__dirname, '../../providers/MigrationsProvider')
]).registerAndBoot()
await fs.ensureDir(path.join(__dirname, '../unit/tmp'))
await helpers.createCollections(ioc.use('Database'))
setupResolver()
})
const config = new Config()
config.set('scout', {
driver: 'null',
null: {}
})
return config
})
ioc.alias('Adonis/Src/Config', 'Config')
ioc.bind('Adonis/Src/Helpers', () => {
return new Helpers(path.join(__dirname))
})
await fs.ensureDir(path.join(__dirname, 'app/Models/IndexKeepers'))
await registrar
.providers([
path.join(__dirname, '../../providers/ScoutProvider'),
path.join(__dirname, '../../providers/IndexKeeperProvider')
])
.registerAndBoot()
setupResolver()
})
})
ioc.alias('Adonis/Src/Config', 'Config')
ioc.bind('Adonis/Src/Helpers', () => {
return new Helpers(path.join(__dirname))
})
const eventMock = jest.fn()
eventMock.on = jest.fn()
eventMock.emit = jest.fn()
eventMock.removeListener = jest.fn()
ioc.bind('Adonis/Src/Event', () => eventMock)
ioc.alias('Adonis/Src/Event', 'Event')
await registrar
.providers([
'@adonisjs/lucid/providers/LucidProvider',
path.join(__dirname, '../../providers/ScoutProvider'),
path.join(__dirname, '../../providers/IndexKeeperProvider')
])
.registerAndBoot()
await fs.ensureDir(path.join(__dirname, '../tmp'))
await fs.ensureDir(path.join(__dirname, 'app/Models'))
await setup.setupTables(ioc.use('Database'))
setupResolver()
})