Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/kareem/test/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict';
const assert = require('assert');
const Kareem = require('../');
describe('hasHooks', function() {
it('returns false for toString (Automattic/mongoose#6538)', function() {
const k = new Kareem();
assert.ok(!k.hasHooks('toString'));
});
});
describe('merge', function() {
it('handles async pres if source doesnt have them', function() {
const k1 = new Kareem();
k1.pre('cook', true, function(next, done) {
execed.first = true;
setTimeout(
function() {
done('error!');
},
5);
next();
});
assert.equal(k1._pres.get('cook').numAsync, 1);
const k2 = new Kareem();
const k3 = k2.merge(k1);
assert.equal(k3._pres.get('cook').numAsync, 1);
});
});
describe('filter', function() {
it('returns clone with only hooks that match `fn()`', function() {
const k1 = new Kareem();
k1.pre('update', { document: true }, f1);
k1.pre('update', { query: true }, f2);
k1.pre('remove', { document: true }, f3);
k1.post('update', { document: true }, f1);
k1.post('update', { query: true }, f2);
k1.post('remove', { document: true }, f3);
const k2 = k1.filter(hook => hook.document);
assert.equal(k2._pres.get('update').length, 1);
assert.equal(k2._pres.get('update')[0].fn, f1);
assert.equal(k2._pres.get('remove').length, 1);
assert.equal(k2._pres.get('remove')[0].fn, f3);
assert.equal(k2._posts.get('update').length, 1);
assert.equal(k2._posts.get('update')[0].fn, f1);
assert.equal(k2._posts.get('remove').length, 1);
assert.equal(k2._posts.get('remove')[0].fn, f3);
const k3 = k1.filter(hook => hook.query);
assert.equal(k3._pres.get('update').length, 1);
assert.equal(k3._pres.get('update')[0].fn, f2);
assert.ok(!k3._pres.has('remove'));
assert.equal(k3._posts.get('update').length, 1);
assert.equal(k3._posts.get('update')[0].fn, f2);
assert.ok(!k3._posts.has('remove'));
function f1() {}
function f2() {}
function f3() {}
});
});
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0227 ]-- |