Skip to content

Commit f1ceb22

Browse files
add system test
1 parent 870e031 commit f1ceb22

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

packages/translate/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ Translate.prototype.getLanguages = function(target, callback) {
270270
* `en` for English). If an object, you may also specify the source
271271
* language.
272272
* @param {string} options.format - Set the text's format as `html` or `text`.
273+
* If not provided, we will try to auto-detect if the text given is HTML. If
274+
* not, we set the format as `text`.
273275
* @param {string} options.from - The ISO 639-1 language code the source input
274276
* is written in.
275277
* @param {string} options.to - The ISO 639-1 language code to translate the

packages/translate/system-test/translate.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ var API_KEY = process.env.GCLOUD_TESTS_API_KEY;
9696
done();
9797
});
9898
});
99+
100+
it('should autodetect HTML', function(done) {
101+
var input = '<body>' + INPUT[0].input + '</body>';
102+
var expectedTranslation = [
103+
'<body>',
104+
INPUT[0].expectedTranslation,
105+
'</body>'
106+
].join(' ');
107+
108+
var opts = {
109+
from: 'en',
110+
to: 'es'
111+
};
112+
113+
translate.translate(input, opts, function(err, results) {
114+
assert.ifError(err);
115+
assert.strictEqual(results, expectedTranslation);
116+
done();
117+
});
118+
});
99119
});
100120

101121
describe('supported languages', function() {

0 commit comments

Comments
 (0)