test/unit/services.rule.v2.js
import test from 'ava';
import sinon from 'sinon';
import { client, ruleService } from '../../src';
test.before('start server', () => {
client.apiBaseUrl = 'https://somesite.Clinical6.com';
});
test.after('server shut down', () => {});
test.beforeEach((t) => {
client.cache = 'never';
client.authToken = 'valid_token';
t.context.server = sinon.fakeServer.create();
t.context.server.autoRespond = true;
t.context.event = {
date: '2016-02-25T02:33:16Z'
};
t.context.rule = 'alerts';
t.context.server.respondWith('POST', `${client.apiBaseUrl}/api/reminder/rules/${t.context.rule}/events/12/mark`,
[200, { 'Content-Type': 'application/json' }, JSON.stringify({
id: 12,
date: '2016-02-25T02:33:16Z',
extras: null,
status: '3',
created_at: '2016-02-25T02:33:16Z',
updated_at: '2016-02-25T02:33:16Z'
})]);
t.context.server.respondWith('GET', `${client.apiBaseUrl}/api/reminder/events/recent*`,
[200, { 'Content-Type': 'application/json' }, JSON.stringify({
test: [{
id: 10,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T15:54:09Z',
updated_at: '2016-06-27T15:54:09Z'
}, {
id: 11,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T16:25:30Z',
updated_at: '2016-06-27T16:25:30Z'
}, {
id: 12,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T16:30:50Z',
updated_at: '2016-06-27T16:30:50Z'
}]
})]);
t.context.server.respondWith('GET', `${client.apiBaseUrl}/api/reminder/rules/test/events/upcoming*`,
[200, { 'Content-Type': 'application/json' }, JSON.stringify({
test: [
{
id: 2,
date: '2016-02-25T02:33:16Z',
extras: null,
status: 5,
created_at: '2016-06-09T17:17:25Z',
updated_at: '2016-06-09T17:17:25Z'
}
]
})]);
t.context.server.respondWith('GET', `${client.apiBaseUrl}/api/reminder/rules/test/events/2016-06-27/by_date`,
[200, { 'Content-Type': 'application/json' }, JSON.stringify({
test: [{
id: 10,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T15:54:09Z',
updated_at: '2016-06-27T15:54:09Z'
}, {
id: 11,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T16:25:30Z',
updated_at: '2016-06-27T16:25:30Z'
}, {
id: 12,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T16:30:50Z',
updated_at: '2016-06-27T16:30:50Z'
}
]
})]);
t.context.server.respondWith('GET', `${client.apiBaseUrl}/api/reminder/rules/test/events`,
[200, { 'Content-Type': 'application/json' }, JSON.stringify({
test: [{
id: 1,
date: '2016-02-25T02:33:16Z',
extras: null,
status: 3,
created_at: '2016-06-09T17:09:20Z',
updated_at: '2016-06-09T18:01:56Z'
}, {
id: 2,
date: '2016-02-25T02:33:16Z',
extras: null,
status: 5,
created_at: '2016-06-09T17:17:25Z',
updated_at: '2016-06-09T17:17:25Z'
}, {
id: 3,
date: '2016-02-25T02:33:16Z',
extras: null,
status: 5,
created_at: '2016-06-09T17:19:24Z',
updated_at: '2016-06-09T17:19:24Z'
}
]
})]);
t.context.server.respondWith('GET', `${client.apiBaseUrl}/api/reminder/rules/test/events/recent*`,
[200, { 'Content-Type': 'application/json' }, JSON.stringify({
test: [{
id: 10,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T15:54:09Z',
updated_at: '2016-06-27T15:54:09Z'
}, {
id: 11,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T16:25:30Z',
updated_at: '2016-06-27T16:25:30Z'
}, {
id: 12,
date: '2016-06-27T15:53:07Z',
extras: null,
status: 5,
created_at: '2016-06-27T16:30:50Z',
updated_at: '2016-06-27T16:30:50Z'
}
]
})]);
t.context.server.respondWith('POST', `${client.apiBaseUrl}/api/reminder/rules/${t.context.rule}/events/mark`,
[201, { 'Content-Type': 'application/json' }, JSON.stringify({ status: 'ok' })]);
});
test.afterEach(t => t.context.server.restore());
// RuleService.markEvent method
/**
* @test {RuleService.markEvent}
*/
test('[unit] RuleService.markEvent should throw errors for invalid parameters', (t) => {
const { rule } = t.context;
const ruleIdError = 'RuleService.markEvent error: ruleId is not defined'
+ ' and eventId is not defined';
const eventIdError = 'RuleService.markEvent error: eventId is not defined';
t.throws(() => ruleService.markEvent(), ruleIdError);
t.throws(() => ruleService.markEvent(rule), eventIdError);
});
/**
* @test {RuleService.markEvent}
*/
test('[unit] RuleService.markEvent should successfully mark an event as ignored with no supplied event action', async (t) => {
const { rule } = t.context;
const response = await ruleService.markEvent(rule, '12');
// const request = t.context.server.requests[0];
// t.is(request.method, 'POST');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/${rule}/events/12/mark`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
t.is(response.status, '3');
});
/**
* @test {RuleService.markEvent}
*/
test('[unit] RuleService.markEvent should successfully mark an event based on the event action', async (t) => {
const { rule } = t.context;
const response = await ruleService.markEvent(rule, '12', 'ignored');
// const request = t.context.server.requests[0];
// t.is(request.method, 'POST');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/${rule}/events/12/mark`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
t.is(response.status, '3');
});
// RuleService.getRecentEvents method
/**
* @test {RuleService.getRecentEvents}
*/
test.serial('[unit] RuleService.getRecentEvents should throw an error when there is no authToken', (t) => {
client.authToken = undefined;
const expectedError = 'RuleService.getRecentEvents error: requires authToken';
t.throws(() => ruleService.getRecentEvents(), expectedError);
});
// /**
// * @test {RuleService.getRecentEvents}
// */
// test('[unit] RuleService.getRecentEvents should make a properly formatted get request', async (t) => {
// await ruleService.getRecentEvents();
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/events/recent`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
// /**
// * @test {RuleService.getRecentEvents}
// */
// test('[unit] RuleService.getRecentEvents should make a properly formatted get request with the timeUnit parameter', async (t) => {
// await ruleService.getRecentEvents('week');
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/events/recent?time_unit=week`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
/**
* @test {RuleService.getRecentEvents}
*/
test('[unit] RuleService.getRecentEvents should receive a valid response for a get request', async (t) => {
const response = await ruleService.getRecentEvents();
t.truthy(response);
t.is(response.test.length, 3);
t.is(response.test[0].id, 10);
t.is(response.test[0].date, '2016-06-27T15:53:07Z');
t.is(response.test[0].extras, null);
t.is(response.test[0].status, 5);
t.is(response.test[0].created_at, '2016-06-27T15:54:09Z');
t.is(response.test[0].updated_at, '2016-06-27T15:54:09Z');
t.is(response.test[1].id, 11);
t.is(response.test[1].date, '2016-06-27T15:53:07Z');
t.is(response.test[1].extras, null);
t.is(response.test[1].status, 5);
t.is(response.test[1].created_at, '2016-06-27T16:25:30Z');
t.is(response.test[1].updated_at, '2016-06-27T16:25:30Z');
t.is(response.test[2].id, 12);
t.is(response.test[2].date, '2016-06-27T15:53:07Z');
t.is(response.test[2].extras, null);
t.is(response.test[2].status, 5);
t.is(response.test[2].created_at, '2016-06-27T16:30:50Z');
t.is(response.test[2].updated_at, '2016-06-27T16:30:50Z');
});
/**
* @test {RuleService.getRecentEvents}
*/
test('[unit] RuleService.getRecentEvents should receive a valid response for a get request with the timeUnit parameter', async (t) => {
const response = await ruleService.getRecentEvents('week');
t.truthy(response);
t.is(response.test.length, 3);
t.is(response.test[0].id, 10);
t.is(response.test[0].date, '2016-06-27T15:53:07Z');
t.is(response.test[0].extras, null);
t.is(response.test[0].status, 5);
t.is(response.test[0].created_at, '2016-06-27T15:54:09Z');
t.is(response.test[0].updated_at, '2016-06-27T15:54:09Z');
t.is(response.test[1].id, 11);
t.is(response.test[1].date, '2016-06-27T15:53:07Z');
t.is(response.test[1].extras, null);
t.is(response.test[1].status, 5);
t.is(response.test[1].created_at, '2016-06-27T16:25:30Z');
t.is(response.test[1].updated_at, '2016-06-27T16:25:30Z');
t.is(response.test[2].id, 12);
t.is(response.test[2].date, '2016-06-27T15:53:07Z');
t.is(response.test[2].extras, null);
t.is(response.test[2].status, 5);
t.is(response.test[2].created_at, '2016-06-27T16:30:50Z');
t.is(response.test[2].updated_at, '2016-06-27T16:30:50Z');
});
// RuleService.getUpcomingEvents method
/**
* @test {RuleService.getUpcomingEvents}
*/
test.serial('[unit] RuleService.getUpcomingEvents should throw an error when there is no authToken', (t) => {
client.authToken = undefined;
const expectedError = 'RuleService.getUpcomingEvents error: requires authToken'
+ ' and ruleId is not defined';
t.throws(() => ruleService.getUpcomingEvents(), expectedError);
});
/**
* @test {RuleService.getUpcomingEvents}
*/
test('[unit] RuleService.getUpcomingEvents should throw an error when there is no ruleId', (t) => {
const expectedError = 'RuleService.getUpcomingEvents error: ruleId is not defined';
t.throws(() => ruleService.getUpcomingEvents(), expectedError);
});
// /**
// * @test {RuleService.getUpcomingEvents}
// */
// test('[unit] RuleService.getUpcomingEvents should make a properly formatted get request', async (t) => {
// await ruleService.getUpcomingEvents('test');
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/test/events/upcoming`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
// /**
// * @test {RuleService.getUpcomingEvents}
// */
// test('[unit] RuleService.getUpcomingEvents should make a properly formatted get request with the timeUnit parameter', async (t) => {
// await ruleService.getUpcomingEvents('test', 'week');
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/test/events/upcoming?time_unit=week`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
/**
* @test {RuleService.getUpcomingEvents}
*/
test('[unit] RuleService.getUpcomingEvents should receive a valid response for a get request', async (t) => {
const response = await ruleService.getUpcomingEvents('test');
t.truthy(response);
t.is(response[0].id, 2);
t.is(response[0].date, '2016-02-25T02:33:16Z');
t.is(response[0].extras, null);
t.is(response[0].status, 5);
t.is(response[0].createdAt, '2016-06-09T17:17:25Z');
t.is(response[0].updatedAt, '2016-06-09T17:17:25Z');
});
/**
* @test {RuleService.getUpcomingEvents}
*/
test('[unit] RuleService.getUpcomingEvents should receive a valid response for a get request with the timeUnit parameter', async (t) => {
const response = await ruleService.getUpcomingEvents('test', 'week');
t.truthy(response);
t.is(response[0].id, 2);
t.is(response[0].date, '2016-02-25T02:33:16Z');
t.is(response[0].extras, null);
t.is(response[0].status, 5);
t.is(response[0].createdAt, '2016-06-09T17:17:25Z');
t.is(response[0].updatedAt, '2016-06-09T17:17:25Z');
});
// RuleService.getEventsByDate method
/**
* @test {RuleService.getEventsByDate}
*/
test.serial('[unit] RuleService.getEventsByDate should throw an error when there is no authToken', (t) => {
client.authToken = undefined;
const expectedError = 'RuleService.getEventsByDate error: requires authToken'
+ ' and ruleId is not defined'
+ ' and date is not defined';
t.throws(() => ruleService.getEventsByDate(), expectedError);
});
/**
* @test {RuleService.getEventsByDate}
*/
test('[unit] RuleService.getEventsByDate should throw an error when there is no ruleId', (t) => {
const expectedError = 'RuleService.getEventsByDate error: ruleId is not defined'
+ ' and date is not defined';
t.throws(() => ruleService.getEventsByDate(), expectedError);
});
/**
* @test {RuleService.getEventsByDate}
*/
test('[unit] RuleService.getEventsByDate should throw an error when there is no date', (t) => {
const expectedError = 'RuleService.getEventsByDate error: date is not defined';
t.throws(() => ruleService.getEventsByDate('test'), expectedError);
});
// /**
// * @test {RuleService.getEventsByDate}
// */
// test('[unit] RuleService.getEventsByDate should make a properly formatted get request', async (t) => {
// await ruleService.getEventsByDate('test', '2016-06-27');
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/test/events/2016-06-27/by_date`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
/**
* @test {RuleService.getEventsByDate}
*/
test('[unit] RuleService.getEventsByDate should receive a valid response for a get request', async (t) => {
const response = await ruleService.getEventsByDate('test', '2016-06-27');
t.truthy(response);
t.is(response[0].id, 10);
t.is(response[0].date, '2016-06-27T15:53:07Z');
t.is(response[0].extras, null);
t.is(response[0].status, 5);
t.is(response[0].createdAt, '2016-06-27T15:54:09Z');
t.is(response[0].updatedAt, '2016-06-27T15:54:09Z');
t.is(response[1].id, 11);
t.is(response[1].date, '2016-06-27T15:53:07Z');
t.is(response[1].extras, null);
t.is(response[1].status, 5);
t.is(response[1].createdAt, '2016-06-27T16:25:30Z');
t.is(response[1].updatedAt, '2016-06-27T16:25:30Z');
t.is(response[2].id, 12);
t.is(response[2].date, '2016-06-27T15:53:07Z');
t.is(response[2].extras, null);
t.is(response[2].status, 5);
t.is(response[2].createdAt, '2016-06-27T16:30:50Z');
t.is(response[2].updatedAt, '2016-06-27T16:30:50Z');
});
// RuleService.getEventsByRule method
/**
* @test {RuleService.getEventsByRule}
*/
test('[unit] RuleService.getEventsByRule should have getEventsByRule', (t) => {
t.truthy(ruleService.getEventsByRule);
});
/**
* @test {RuleService.getEventsByRule}
*/
test.serial('[unit] RuleService.getEventsByRule should throw an error when there is no authToken', (t) => {
client.authToken = undefined;
const expectedError = 'RuleService.getEvents error: requires authToken and ruleId is not defined';
t.throws(() => ruleService.getEventsByRule(), expectedError);
});
/**
* @test {RuleService.getEventsByRule}
*/
test('[unit] RuleService.getEventsByRule should throw an error when there is no ruleId', (t) => {
const expectedError = 'RuleService.getEvents error: ruleId is not defined';
t.throws(() => ruleService.getEventsByRule(), expectedError);
});
// /**
// * @test {RuleService.getEventsByRule}
// */
// test('[unit] RuleService.getEventsByRule should make a properly formatted get request', async (t) => {
// await ruleService.getEventsByRule('test');
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/test/events`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
/**
* @test {RuleService.getEventsByRule}
*/
test('[unit] RuleService.getEventsByRule should receive a valid response for a get request', async (t) => {
const response = await ruleService.getEventsByRule('test');
t.truthy(response);
t.is(response[0].id, 1);
t.is(response[0].date, '2016-02-25T02:33:16Z');
t.is(response[0].extras, null);
t.is(response[0].status, 3);
t.is(response[0].createdAt, '2016-06-09T17:09:20Z');
t.is(response[0].updatedAt, '2016-06-09T18:01:56Z');
t.is(response[1].id, 2);
t.is(response[1].date, '2016-02-25T02:33:16Z');
t.is(response[1].extras, null);
t.is(response[1].status, 5);
t.is(response[1].createdAt, '2016-06-09T17:17:25Z');
t.is(response[1].updatedAt, '2016-06-09T17:17:25Z');
t.is(response[2].id, 3);
t.is(response[2].date, '2016-02-25T02:33:16Z');
t.is(response[2].extras, null);
t.is(response[2].status, 5);
t.is(response[2].createdAt, '2016-06-09T17:19:24Z');
t.is(response[2].updatedAt, '2016-06-09T17:19:24Z');
});
// RuleService.getFilteredRecentEvents method
/**
* @test {RuleService.getFilteredRecentEvents}
*/
test.serial('[unit] RuleService.getFilteredRecentEvents should throw an error when there is no authToken', (t) => {
client.authToken = undefined;
const expectedError = 'RuleService.getFilteredRecentEvents error: requires authToken and ruleId is not defined';
t.throws(() => ruleService.getFilteredRecentEvents(), expectedError);
});
/**
* @test {RuleService.getFilteredRecentEvents}
*/
test('[unit] RuleService.getFilteredRecentEvents should throw an error when there is no ruleId', (t) => {
const expectedError = 'RuleService.getFilteredRecentEvents error: ruleId is not defined';
t.throws(() => ruleService.getFilteredRecentEvents(), expectedError);
});
// /**
// * @test {RuleService.getFilteredRecentEvents}
// */
// test('[unit] RuleService.getFilteredRecentEvents should make a properly formatted get request', async (t) => {
// await ruleService.getFilteredRecentEvents('test');
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/test/events/recent`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
// /**
// * @test {RuleService.getFilteredRecentEvents}
// */
// test('[unit] RuleService.getFilteredRecentEvents should make a properly formatted get request with the timeUnit parameter', async (t) => {
// await ruleService.getFilteredRecentEvents('test', 'week');
// const request = t.context.server.requests[0];
// t.is(request.method, 'GET');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/test/events/recent?time_unit=week`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
// });
/**
* @test {RuleService.getFilteredRecentEvents}
*/
test('[unit] RuleService.getFilteredRecentEvents should receive a valid response for a get request', async (t) => {
const response = await ruleService.getFilteredRecentEvents('test');
t.truthy(response);
t.is(response.length, 3);
t.is(response[0].id, 10);
t.is(response[0].date, '2016-06-27T15:53:07Z');
t.is(response[0].extras, null);
t.is(response[0].status, 5);
t.is(response[0].createdAt, '2016-06-27T15:54:09Z');
t.is(response[0].updatedAt, '2016-06-27T15:54:09Z');
t.is(response[1].id, 11);
t.is(response[1].date, '2016-06-27T15:53:07Z');
t.is(response[1].extras, null);
t.is(response[1].status, 5);
t.is(response[1].createdAt, '2016-06-27T16:25:30Z');
t.is(response[1].updatedAt, '2016-06-27T16:25:30Z');
t.is(response[2].id, 12);
t.is(response[2].date, '2016-06-27T15:53:07Z');
t.is(response[2].extras, null);
t.is(response[2].status, 5);
t.is(response[2].createdAt, '2016-06-27T16:30:50Z');
t.is(response[2].updatedAt, '2016-06-27T16:30:50Z');
});
/**
* @test {RuleService.getFilteredRecentEvents}
*/
test('[unit] RuleService.getFilteredRecentEvents should receive a valid response for a get request with the timeUnit parameter', async (t) => {
const response = await ruleService.getFilteredRecentEvents('test', 'week');
t.truthy(response);
t.is(response.length, 3);
t.is(response[0].id, 10);
t.is(response[0].date, '2016-06-27T15:53:07Z');
t.is(response[0].extras, null);
t.is(response[0].status, 5);
t.is(response[0].createdAt, '2016-06-27T15:54:09Z');
t.is(response[0].updatedAt, '2016-06-27T15:54:09Z');
t.is(response[1].id, 11);
t.is(response[1].date, '2016-06-27T15:53:07Z');
t.is(response[1].extras, null);
t.is(response[1].status, 5);
t.is(response[1].createdAt, '2016-06-27T16:25:30Z');
t.is(response[1].updatedAt, '2016-06-27T16:25:30Z');
t.is(response[2].id, 12);
t.is(response[2].date, '2016-06-27T15:53:07Z');
t.is(response[2].extras, null);
t.is(response[2].status, 5);
t.is(response[2].createdAt, '2016-06-27T16:30:50Z');
t.is(response[2].updatedAt, '2016-06-27T16:30:50Z');
});
// RuleService.markEventByObj method
/**
* @test {RuleService.markEventByObj}
*/
test.serial('[unit] RuleService.markEventByObj should throw an error when there is no authToken', (t) => {
client.authToken = undefined;
const expectedError = 'RuleService.markEventByObj error: requires authToken'
+ ' and ruleId is not defined';
t.throws(() => ruleService.markEventByObj(), expectedError);
});
/**
* @test {RuleService.markEventByObj}
*/
test('[unit] RuleService.markEventByObj should throw errors for invalid parameters', (t) => {
const ruleIdError = 'RuleService.markEventByObj error: ruleId is not defined';
t.throws(() => ruleService.markEventByObj(), ruleIdError);
});
/**
* @test {RuleService.markEventByObj}
*/
test('[unit] RuleService.markEventByObj should successfully mark an event as ignored with no supplied event action', async (t) => {
const { rule } = t.context;
const eventChange = {
id: 12,
};
const response = await ruleService.markEventByObj(rule, eventChange);
// const request = t.context.server.requests[0];
// t.is(request.method, 'POST');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/${rule}/events/mark`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
t.is(response.status, 'ok');
});
/**
* @test {RuleService.markEventByObj}
*/
test('[unit] RuleService.markEventByObj should successfully mark an event based on the event action', async (t) => {
const { rule } = t.context;
const eventChange = {
id: 12,
event_action: 'ignored',
};
const response = await ruleService.markEventByObj(rule, eventChange);
// const request = t.context.server.requests[0];
// t.is(request.method, 'POST');
// t.is(request.url, `${client.apiBaseUrl}/api/reminder/rules/${rule}/events/mark`);
// t.is(request.requestHeaders.Accept, 'application/json');
// t.is(request.requestHeaders['Content-Type'], 'application/json;charset=utf-8');
// t.is(request.requestHeaders.Authorization, 'Token token=valid_token');
t.is(response.status, 'ok');
});