The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import { computeRequestActor } from 'src/engine/utils/compute-request-actor.util';
describe('computeRequestActor', () => {
it('should prefer the api key over the application and the user', () => {
expect(
computeRequestActor({
apiKey: { id: 'api-key-id' },
application: { id: 'application-id' },
user: { id: 'user-id' },
}),
).toEqual({ kind: 'apiKey', id: 'api-key-id' });
});
it('should prefer the application over the user', () => {
expect(
computeRequestActor({
application: { id: 'application-id' },
user: { id: 'user-id' },
}),
).toEqual({ kind: 'application', id: 'application-id' });
});
it('should fall back to the user', () => {
expect(
computeRequestActor({
user: { id: 'user-id' },
}),
).toEqual({ kind: 'user', id: 'user-id' });
});
it('should return undefined when nothing authenticated the request', () => {
expect(computeRequestActor({})).toBeUndefined();
});
});