The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/api/server/lib/projectionAllowsAttribute.s...

29 lines
1.2 KiB

import { expect } from 'chai';
import { projectionAllowsAttribute } from './projectionAllowsAttribute';
describe('projectionAllowsAttribute', () => {
it('should return true if there are no options', () => {
expect(projectionAllowsAttribute('attributeName')).to.be.equal(true);
});
it('should return true if there is no projection', () => {
expect(projectionAllowsAttribute('attributeName', {})).to.be.equal(true);
});
it('should return true if the field is projected', () => {
expect(projectionAllowsAttribute('attributeName', { projection: { attributeName: 1 } })).to.be.equal(true);
});
it('should return false if the field is disallowed by projection', () => {
expect(projectionAllowsAttribute('attributeName', { projection: { attributeName: 0 } })).to.be.equal(false);
});
it('should return false if the field is not projected and others are', () => {
expect(projectionAllowsAttribute('attributeName', { projection: { anotherAttribute: 1 } })).to.be.equal(false);
});
it('should return true if the field is not projected and others are disallowed', () => {
expect(projectionAllowsAttribute('attributeName', { projection: { anotherAttribute: 0 } })).to.be.equal(true);
});
});