deno.land / x / mongoose@6.7.5 / test / helpers / projection.applyProjection.test.js

projection.applyProjection.test.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
const applyProjection = require('../../lib/helpers/projection/applyProjection');const assert = require('assert');
describe('applyProjection', function() { it('handles deep inclusive projections', function() { const obj = { str: 'test', nested: { str2: 'test2', num3: 42 } };
assert.deepEqual(applyProjection(obj, { str: 1 }), { str: 'test' }); assert.deepEqual(applyProjection(obj, { 'nested.str2': 1 }), { nested: { str2: 'test2' } }); assert.deepEqual(applyProjection(obj, { str: 1, nested: { num3: 1 } }), { str: 'test', nested: { num3: 42 } }); });
it('handles deep exclusive projections', function() { const obj = { str: 'test', nested: { str2: 'test2', num3: 42 } };
assert.deepEqual(applyProjection(obj, { nested: 0 }), { str: 'test' }); assert.deepEqual(applyProjection(obj, { 'nested.str2': 0 }), { str: 'test', nested: { num3: 42 } }); assert.deepEqual(applyProjection(obj, { nested: { num3: 0 } }), { str: 'test', nested: { str2: 'test2' } }); });});
mongoose

Version Info

Tagged at
a year ago