mirror of
https://github.com/directus/directus.git
synced 2026-02-08 16:24:56 -05:00
@@ -9,6 +9,7 @@ describe('Operations / Condition', () => {
|
||||
_eq: true,
|
||||
},
|
||||
};
|
||||
|
||||
const data = {
|
||||
status: true,
|
||||
};
|
||||
@@ -22,6 +23,7 @@ describe('Operations / Condition', () => {
|
||||
_eq: true,
|
||||
},
|
||||
};
|
||||
|
||||
const data = {
|
||||
status: false,
|
||||
};
|
||||
@@ -42,6 +44,7 @@ describe('Operations / Condition', () => {
|
||||
_eq: true,
|
||||
},
|
||||
};
|
||||
|
||||
const data = {};
|
||||
|
||||
expect.assertions(2); // ensure catch block is reached
|
||||
|
||||
@@ -96,6 +96,7 @@ describe('Operations / Item Delete', () => {
|
||||
|
||||
test('should emit events for deleteOne when true', async () => {
|
||||
const key = 1;
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key, emitEvents: true } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -106,6 +107,7 @@ describe('Operations / Item Delete', () => {
|
||||
|
||||
test.each([undefined, false])('should not emit events for deleteOne when %s', async (emitEvents) => {
|
||||
const key = 1;
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key, emitEvents } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -127,6 +129,7 @@ describe('Operations / Item Delete', () => {
|
||||
|
||||
test('should emit events for deleteMany when true', async () => {
|
||||
const keys = [1, 2, 3];
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key: keys, emitEvents: true } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -137,6 +140,7 @@ describe('Operations / Item Delete', () => {
|
||||
|
||||
test.each([undefined, false])('should not emit events for deleteMany when %s', async (emitEvents) => {
|
||||
const keys = [1, 2, 3];
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key: keys, emitEvents } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
|
||||
@@ -96,6 +96,7 @@ describe('Operations / Item Read', () => {
|
||||
|
||||
test('should emit events for readOne when true', async () => {
|
||||
const key = 1;
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key, emitEvents: true } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -106,6 +107,7 @@ describe('Operations / Item Read', () => {
|
||||
|
||||
test.each([undefined, false])('should not emit events for readOne when %s', async (emitEvents) => {
|
||||
const key = 1;
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key, emitEvents } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -127,6 +129,7 @@ describe('Operations / Item Read', () => {
|
||||
|
||||
test('should emit events for readMany when true', async () => {
|
||||
const keys = [1, 2, 3];
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key: keys, emitEvents: true } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -137,6 +140,7 @@ describe('Operations / Item Read', () => {
|
||||
|
||||
test.each([undefined, false])('should not emit events for readMany when %s', async (emitEvents) => {
|
||||
const keys = [1, 2, 3];
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, key: keys, emitEvents } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
|
||||
@@ -59,6 +59,7 @@ describe('Operations / Item Update', () => {
|
||||
|
||||
test.each([undefined, []])('should call updateByQuery with correct query when key is $payload', async (key) => {
|
||||
const query = { limit: -1 };
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, payload: testPayload, query, key } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -71,6 +72,7 @@ describe('Operations / Item Update', () => {
|
||||
|
||||
test('should emit events for updateByQuery when true', async () => {
|
||||
const query = { limit: -1 };
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, payload: testPayload, query, emitEvents: true } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -83,6 +85,7 @@ describe('Operations / Item Update', () => {
|
||||
|
||||
test.each([undefined, false])('should not emit events for updateByQuery when %s', async (emitEvents) => {
|
||||
const query = { limit: -1 };
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, payload: testPayload, query, emitEvents } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -106,6 +109,7 @@ describe('Operations / Item Update', () => {
|
||||
|
||||
test('should emit events for updateOne when true', async () => {
|
||||
const key = 1;
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, payload: testPayload, key, emitEvents: true } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -116,6 +120,7 @@ describe('Operations / Item Update', () => {
|
||||
|
||||
test.each([undefined, false])('should not emit events for updateOne when %s', async (emitEvents) => {
|
||||
const key = 1;
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, payload: testPayload, key: key, emitEvents } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -137,6 +142,7 @@ describe('Operations / Item Update', () => {
|
||||
|
||||
test('should emit events for updateMany when true', async () => {
|
||||
const keys = [1, 2, 3];
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, payload: testPayload, key: keys, emitEvents: true } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
@@ -147,6 +153,7 @@ describe('Operations / Item Update', () => {
|
||||
|
||||
test.each([undefined, false])('should not emit events for updateMany when %s', async (emitEvents) => {
|
||||
const keys = [1, 2, 3];
|
||||
|
||||
await config.handler(
|
||||
{ collection: testCollection, payload: testPayload, key: keys, emitEvents } as any,
|
||||
{ accountability: testAccountability, getSchema } as any
|
||||
|
||||
@@ -17,6 +17,7 @@ export default defineOperationApi<Options>({
|
||||
// If 'body' is of type object/undefined (happens when body consists solely of a placeholder)
|
||||
// convert it to JSON string
|
||||
const safeBody = typeof body !== 'string' ? JSON.stringify(body) : body;
|
||||
|
||||
await mailService.send({
|
||||
html: type === 'wysiwyg' ? safeBody : md(safeBody),
|
||||
to,
|
||||
|
||||
@@ -43,6 +43,7 @@ export default defineOperationApi<Options>({
|
||||
message: messageString,
|
||||
};
|
||||
});
|
||||
|
||||
const result = await notificationsService.createMany(payload);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -37,10 +37,12 @@ test('no headers configured', async () => {
|
||||
|
||||
test('headers array is converted to object', async () => {
|
||||
const body = 'body';
|
||||
|
||||
const headers = [
|
||||
{ header: 'header1', value: 'value1' },
|
||||
{ header: 'header2', value: 'value2' },
|
||||
];
|
||||
|
||||
await config.handler({ url, method, body, headers }, {} as any);
|
||||
|
||||
expect(axiosDefault).toHaveBeenCalledWith(
|
||||
|
||||
Reference in New Issue
Block a user