assert(app.messengerLog); assert.deepStrictEqual(app.bootLog, [ 'configDidLoad', 'didLoad', 'willReady', 'serverDidReady', 'beforeClose' ]); assert.deepStrictEqual(app.agent.bootLog, [ 'configDidLoad', 'didLoad', 'willReady',
it('Stay attached', async function(state) { const configDir = await fsMkdtemp(path.join(os.tmpdir(), 'ndb-test-')); const frontend = await launch({ configDir: configDir, argv: ['.'], cwd: path.join(__dirname, 'assets', 'test-project'), debugFrontend: false, doNotCopyPreferences: true, appName: 'integration_test_runner', releaseFrontendFolder: state.frontendFolder, doNotProcessExit: true }); await setupHelpers(frontend); await frontend.setSetting('waitAtEnd', true); frontend.runConfiguration('atexit'); await frontend.waitForConsoleMessage('42'); const processes = await frontend.nodeProcess(); processes.sort(); assert.equal(`node -e process.once('exit', _ => console.log(42))`, processes[0]); assert.equal(`node npm run atexit`, processes[1]); const targetDestroyed = frontend.waitTargetDestroyed(2); await frontend.killProcess(`node -e process.once('exit', _ => console.log(42))`); await targetDestroyed; assert.deepStrictEqual([], await frontend.nodeProcess()); await frontend.close(); await util.promisify(removeFolder)(configDir); });
assert.fail('No error thrown'); } catch (err) { assert.deepStrictEqual(err, new Error('Something bad happened.')); await sample.program.triggerDag(event); } catch (err) { assert.deepStrictEqual(err, new Error(expectedMsg));
assert.deepStrictEqual(app._app.stages, [ 'configWillLoad', 'configDidLoad',
//buildOptions tests describe('Test buildOptions function', () => { const source = { option1: '1', option2: '2' }; const sourceAddon = { option3: '3'}; const expected = { option1: '1', option2: '2' }; const expectedAddon = { option1: '1', option2: '2', option3: '3'}; it('buildOptions returns and equal object to the object which was paased', () => { let result = buildOptions(source); assert.deepStrictEqual(result, source); }); it('buildOptions doesnt add non object or null arguments to the result', () => { let result = buildOptions(source, 2, '3', null); assert.deepStrictEqual(result, expected); }); it('buildOptions adds value to the result from the several source argumets', () => { let result = buildOptions(source, sourceAddon); assert.deepStrictEqual(result, expectedAddon); }); });
assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [ assert.deepStrictEqual(report.results[0].messages, [
it('$xxx', function * () { let doc = yield User.findOne({ name: 'aaa' }) assert.deepStrictEqual(doc.posts[0].comments.length, 1) yield User.update({ name: 'aaa' }, { $pop: { 'posts.0.comments': 1 } }) doc = yield User.findOne({ name: 'aaa' }) assert.deepStrictEqual(doc.posts[0].comments.length, 0) })
it('should execute with object', () => { Aigle.mixin({ countBy: _.countBy }, { override: true }); const object = { a: 1.1, b: 1.4, c: 2.2 }; return Aigle.delay(DELAY, object) .countBy((n) => Aigle.delay(DELAY, Math.floor(n))) .then((object) => assert.deepStrictEqual(object, { '1': 2, '2': 1 })); });
it('beforeFindOne', function * () { let doc = yield User.findOne({ refe: '222222222222222222222222' }).select({ _id: 0, name: 1 }) assert.deepStrictEqual(doc, { name: 'aaa' }) doc = yield User.findOne({ refe: ObjectId('222222222222222222222222') }).select({ _id: 0, name: 1 }) assert.deepStrictEqual(doc, { name: 'aaa' }) })
it('should work with iteratable tasks', () => { const arr = [ ['task1', Aigle.delay(DELAY * 3, 1)], ['task2', Aigle.resolve(2)], ['task3', 3], ]; const tasks = new Map(arr); return Aigle.all(tasks).then((res) => assert.deepStrictEqual(res, arr)); });
it('beforeRemove', function * () { try { yield User.remove({ refe: '222222222222222222222222' }) const count = yield User.count() assert.deepStrictEqual(count, 1) } catch (e) { assert.deepStrictEqual(e.op, 'remove') assert.deepStrictEqual(typeof e.args[0].refe, 'object') assert.deepStrictEqual(e.args[0].refe.toString(), '222222222222222222222222') assert.ok(e.message.match('Cannot convert undefined or null to object')) } })
it('$pullAll', function * () { yield User.update({ name: 'aaa' }, { $addToSet: { 'posts.0.comments': { $each: ['555555555555555555555555', '666666666666666666666666'] } } }) let doc = yield User.findOne({ name: 'aaa' }) assert.deepStrictEqual(doc.posts[0].comments.length, 3) yield User.update({ 'posts.comments': '333333333333333333333333' }, { $pullAll: { 'posts.$.comments': ['555555555555555555555555', '666666666666666666666666'] } }) doc = yield User.findOne({ name: 'aaa' }) assert.deepStrictEqual(doc.posts[0].comments.length, 1) })
it('$xxx', function * () { let count = yield User.count({ name: { $exists: true } }) assert.deepStrictEqual(count, 2) count = yield User.count({ name: { $exists: true }, refe: '111111111111111111111111' }) assert.deepStrictEqual(count, 1) count = yield User.count({ haha: { $exists: true } }) assert.deepStrictEqual(count, 0) })
it('$eq', function * () { const docs = yield User .find({ refe: { $eq: '111111111111111111111111' } }) .select({ _id: 0, name: 1 }) assert.deepStrictEqual(docs, [ { name: 'bbb' } ]) })
it('$pull', function * () { yield User.update({ name: 'aaa' }, { $addToSet: { 'posts.0.comments': '555555555555555555555555' } }) let doc = yield User.findOne({ name: 'aaa' }) assert.deepStrictEqual(doc.posts[0].comments.length, 2) yield User.update({ 'posts.comments': '333333333333333333333333' }, { $pull: { 'posts.$.comments': { $in: ['555555555555555555555555'] } } }) doc = yield User.findOne({ name: 'aaa' }) assert.deepStrictEqual(doc.posts[0].comments.length, 1) })