Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
|--------------------------------------------------------------------------
| COMMANDS
|--------------------------------------------------------------------------
|
| Ace commands tests are written in this file.
|
*/
/* global describe, it, after, before */
const chai = require('chai')
const expect = chai.expect
const fold = require('adonis-fold')
const Ioc = fold.Ioc
const stdout = require('test-console').stdout
const setup = require('./setup')
require('co-mocha')
describe('Commands', function () {
before(function * () {
yield setup.loadProviders()
setup.registerCommands()
const LucidMongo = Ioc.use('Adonis/Src/LucidMongo')
class User extends LucidMongo {}
Ioc.bind('App/Model/User', function () {
return User
})
this.database = Ioc.use('Adonis/Src/Database')
})
'use strict';
const expect = require('chai').expect;
const rewire = require('rewire');
const stdout = require('test-console').stdout;
const validateBranch = rewire('../src/lib/validateBranch'); // NOTE: rewired!
describe('validateBranch', () => {
let revert = () => {};
afterEach(() => revert()); // revert the mocking of anything
it('should show a message if the current branch is not the release branch and exit with 0', () => {
let exitCode;
revert = validateBranch.__set__({
shell: {
exec: () => ({stdout: 'fooBranch\n'}),
exit: (code) => {
exitCode = code;
return;
},
it ('should not log request log message if not an object', function (done) {
const inspect = testConsole.stdout.inspect();
const message = 'hello kartikay';
exchange.publish('request', JSON.stringify(message));
// wait for a second
setTimeout(() => {
inspect.restore();
// check for console
assert.strictEqual(inspect.output.length, 0);
done();
}, 1000);
it('should output junit file', function() {
new Reporter(runner, {
reporterOptions: { mochaFile: file }
});
var stdout = testConsole.stdout.inspect();
try{
executeTestRunner();
assert(fs.existsSync(file));
}
finally{
stdout.restore();
}
});
it('should output spec to stdout', function() {
new Reporter(runner, {
reporterOptions: { mochaFile: file }
});
var stdout = testConsole.stdout.inspect();
try{
executeTestRunner();
}
finally{
stdout.restore();
}
assert(stdout.output[1], '\u001b[0mFoo Bar module\u001b[0m\n');
});
const assert = require('chai').assert
const _ = require('underscore')
const path = require('path')
const process = require('process')
const fs = require('fs');
const stdout = require("test-console").stdout;
const stderr = require("test-console").stderr;
const util = require('../util');
util.globalize(util);
describe('util', function() {
describe('globalize', function(){
it('should make functions globally available', function(){
assert.isFunction(definedOr);
assert.isFunction(padRight);
assert.isFunction(maxLength);
assert.isFunction(longest);
})
})
describe('definedOr', function () {
var fs = require('fs');
var path = require('path');
var babel6 = require('babel-core');
var babel7 = require('@babel/core');
var stdout = require('test-console').stdout;
var assert = require('assert');
function alignLines(string) {
return string.split(/\n/)
.map(function(line) { return line.trim(); })
.filter(function(line) { return line !== ''; })
.join('\n');
}
describe('babel-plugin-transform-semantic-ui-react-imports', function() {
var fixtures = fs.readdirSync(path.resolve(__dirname, 'fixtures'));
var babelVersions = [
{ name: "Babel 6", transformFileSync: babel6.transformFileSync, transformSync: babel6.transform },
{ name: "Babel 7", transformFileSync: babel7.transformFileSync, transformSync: babel7.transformSync }
];
try {
t.is(fs.readFileSync(path, 'utf8'), content);
} catch (e) {
t.fail(e.message);
}
};
const fileDoesNotContain = (t, path, content) => {
try {
t.false(fs.readFileSync(path, 'utf8').includes(content));
} catch (e) {
t.fail(e.message);
}
};
const _stdout = require('test-console').stdout;
const _stderr = require('test-console').stderr;
let _inspect, _inspectE;
const spyOnConsole = () => {
_inspect = _stdout.inspect();
_inspectE = _stderr.inspect();
};
const restoreConsole = () => {
_inspect.restore();
_inspect.output.forEach(line => process.stdout.write(line));
_inspect = null;
_inspectE.restore();
_inspectE.output.forEach(line => process.stderr.write(line));
_inspectE = null;
'use strict'
/*
* adonis-framework
*
* (c) Harminder Virk
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
const test = require('japa')
const path = require('path')
const fs = require('fs-extra')
const { ioc } = require('@adonisjs/fold')
const stdout = require('test-console').stdout
const { Config, Helpers } = require('@adonisjs/sink')
const FileDriver = require('../../src/Logger/Drivers').file
const ConsoleDriver = require('../../src/Logger/Drivers').console
const Logger = require('../../src/Logger')
const LoggerManager = require('../../src/Logger/Manager')
const LoggerFacade = require('../../src/Logger/Facade')
const sysLog = {
emerg: 0,
alert: 1,
crit: 2,
error: 3,
warning: 4,
notice: 5,
info: 6,