Skip to content

Commit 9053324

Browse files
committed
Merge pull request watson-developer-cloud#169 from mfulgo/dev
DCS: Adds example for passing custom configs
2 parents 784afd2 + f61ba47 commit 9053324

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ coverage
55
test/resources/auth.js
66
test/integration/
77
test/resources/tts-output.ogg
8+
.idea

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ If you want to contribute to the repository, follow these steps:
2828

2929
1. Fork the repo.
3030
1. Develop and test your code changes: `npm install -d && npm test`. Make sure you work in the `dev` branch. PLEASE don't do your work in `master`.
31-
1. In order to run the tests locally you should comment out `test.integration-all-services.js` because the integration tests require you to have service credentials for all the services.
32-
Travis will run the integration tests for all services once the changes are merged in.
31+
1. Travis-CI will run the integration tests for all services once your changes are merged.
32+
If you wish to run integration tests locally you must provide service credentials for all the services. See `test/test.integration-all-services.js`.
3333
1. Add a test for your changes. Only refactoring and documentation changes require no new tests.
3434
1. Make the test pass.
3535
1. Commit your changes.

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,16 @@ var document_conversion = watson.document_conversion({
303303
document_conversion.convert({
304304
// (JSON) ANSWER_UNITS, NORMALIZED_HTML, or NORMALIZED_TEXT
305305
file: fs.createReadStream('sample-docx.docx'),
306-
conversion_target: document_conversion.conversion_target.ANSWER_UNITS
306+
conversion_target: document_conversion.conversion_target.ANSWER_UNITS,
307+
// Add custom configuration properties or omit for defaults
308+
word: {
309+
heading: {
310+
fonts: [
311+
{ level: 1, min_size: 24 },
312+
{ level: 2, min_size: 16, max_size: 24 }
313+
]
314+
}
315+
}
307316
}, function (err, response) {
308317
if (err) {
309318
console.error(err);

test/test.document_conversion.v1-experimental.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ describe('document_conversion', function() {
2121

2222
var payload = {
2323
conversion_target: 'ANSWER_UNITS',
24+
word: {
25+
heading: {
26+
fonts: [
27+
{ level: 1, min_size: 24 },
28+
{ level: 2, min_size: 16, max_size: 24 }
29+
]
30+
}
31+
},
2432
file: fs.createReadStream(__dirname + '/resources/sampleWORD.docx'),
2533
};
2634

@@ -68,5 +76,11 @@ describe('document_conversion', function() {
6876
assert.equal(req.method, 'POST');
6977
assert(req.formData);
7078
});
79+
80+
it('should send extra config params', function() {
81+
var req = servInstance.convert(payload, noop);
82+
var config = JSON.parse(req.formData.config.value);
83+
assert(config.word.heading.fonts);
84+
});
7185
});
7286
});

test/test.integration-all-services.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
'use strict';
22

3+
var fs = require('fs');
4+
5+
if (fs.existsSync(__dirname + '/resources/auth.js')) {
6+
37
var nock = require('nock');
48
var watson = require('../lib/index');
59
var auth = require('./resources/auth');
6-
var fs = require('fs');
710
var assert = require('assert');
811

912
var mobydick = fs.readFileSync(__dirname + '/resources/mobydick.txt', 'utf8');
@@ -14,8 +17,6 @@ var TEN_SECONDS = 10000;
1417
var FIVE_SECONDS = 5000;
1518
var TWO_SECONDS = 2000;
1619

17-
if (fs.existsSync(__dirname + '/resources/auth.js')) {
18-
1920
describe('integration-all-services', function() {
2021

2122
this.slow(TWO_SECONDS); // this controls when the tests get a colored warning for taking too long
@@ -590,7 +591,15 @@ describe('integration-all-services', function() {
590591
it('convertFile()', function(done) {
591592
document_conversion.convert({
592593
file: fs.createReadStream(__dirname + '/resources/sampleWORD.docx'),
593-
conversion_target: 'ANSWER_UNITS'
594+
conversion_target: 'ANSWER_UNITS',
595+
word: {
596+
heading: {
597+
fonts: [
598+
{ level: 1, min_size: 24 },
599+
{ level: 2, min_size: 16, max_size: 24 }
600+
]
601+
}
602+
}
594603
}, failIfError.bind(failIfError, done));
595604
});
596605
});

0 commit comments

Comments
 (0)