Skip to content

Commit 6a74b30

Browse files
committed
add draftKey option
1 parent c5ce6d2 commit 6a74b30

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ module.exports = {
129129
* API request query options. (Optional)
130130
*
131131
* Type:
132+
* draftKey: string.
132133
* limit: number.
133134
* offset: number.
134135
* fields: string.
@@ -137,6 +138,7 @@ module.exports = {
137138
* Default: {}.
138139
**/
139140
query: {
141+
draftKey: 'DRAFT_KEY',
140142
limit: 100,
141143
offset: 40,
142144
fields: ['id', 'title', 'body'].join(','),

src/__tests__/pluginOptions.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,40 @@ describe('validateOptions', () => {
105105
expect(reporter.panic.mock.calls.length).toBe(1);
106106
});
107107

108+
test('draftKey option should be success.', () => {
109+
const options = {
110+
apiKey: 'key',
111+
serviceId: 'id',
112+
endpoint: 'endpoint',
113+
query: {
114+
draftKey: 'DRAFT_KEY',
115+
},
116+
};
117+
validateOptions({ reporter }, options);
118+
expect(reporter.panic).not.toBeCalled();
119+
});
120+
121+
test('invalide draftKey option should be error.', () => {
122+
const options = {
123+
apiKey: 'key',
124+
serviceId: 'id',
125+
endpoint: 'endpoint',
126+
};
127+
128+
// empty string
129+
validateOptions({ reporter }, { ...options, query: { draftKey: '' } });
130+
expect(reporter.panic.mock.calls.length).toBe(1);
131+
// float
132+
validateOptions({ reporter }, { ...options, query: { draftKey: 1.3 } });
133+
expect(reporter.panic.mock.calls.length).toBe(2);
134+
// object
135+
validateOptions({ reporter }, { ...options, query: { draftKey: {} } });
136+
expect(reporter.panic.mock.calls.length).toBe(3);
137+
// array
138+
validateOptions({ reporter }, { ...options, draftKey: [2] });
139+
expect(reporter.panic.mock.calls.length).toBe(4);
140+
});
141+
108142
test('fields option should be success.', () => {
109143
const options = {
110144
apiKey: 'key',

src/pluginOptions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const optionsSchema = Joi.object().keys({
2929
type: Joi.string(),
3030
format: Joi.string().pattern(/^(list|object)$/),
3131
query: Joi.object({
32+
draftKey: Joi.string(),
3233
fields: Joi.string(),
3334
limit: Joi.number().integer(),
3435
offset: Joi.number().integer(),

0 commit comments

Comments
 (0)