diff --git a/translate/quickstart.js b/translate/quickstart.js index 6fd4e0350b1..d56235c2401 100644 --- a/translate/quickstart.js +++ b/translate/quickstart.js @@ -17,7 +17,7 @@ // [START translate_quickstart] // Imports the Google Cloud client library -const Translate = require('@google-cloud/translate'); +const {Translate} = require('@google-cloud/translate'); // Your Google Cloud Platform project ID const projectId = 'YOUR_PROJECT_ID'; diff --git a/translate/system-test/quickstart.test.js b/translate/system-test/quickstart.test.js index 8516f23cb56..7013e8a558b 100644 --- a/translate/system-test/quickstart.test.js +++ b/translate/system-test/quickstart.test.js @@ -19,7 +19,8 @@ const proxyquire = require(`proxyquire`).noPreserveCache(); const sinon = require(`sinon`); const test = require(`ava`); const tools = require(`@google-cloud/nodejs-repo-tools`); -const translate = proxyquire(`@google-cloud/translate`, {})(); +const {Translate} = proxyquire(`@google-cloud/translate`, {}); +const translate = new Translate(); test.before(tools.checkCredentials); test.before(tools.stubConsole); @@ -58,6 +59,8 @@ test.cb(`should translate a string`, t => { }; proxyquire(`../quickstart`, { - '@google-cloud/translate': sinon.stub().returns(translateMock), + '@google-cloud/translate': { + Translate: sinon.stub().returns(translateMock), + }, }); }); diff --git a/translate/system-test/translate.test.js b/translate/system-test/translate.test.js index e9d5218bba4..b6562b3d7f1 100644 --- a/translate/system-test/translate.test.js +++ b/translate/system-test/translate.test.js @@ -18,7 +18,8 @@ const path = require(`path`); const test = require(`ava`); const tools = require(`@google-cloud/nodejs-repo-tools`); -const translate = require(`@google-cloud/translate`)(); +const {Translate} = require(`@google-cloud/translate`); +const translate = new Translate(); const cwd = path.join(__dirname, `..`); const cmd = `node translate.js`; diff --git a/translate/translate.js b/translate/translate.js index ac1d78213f9..bf36c7ffb7a 100644 --- a/translate/translate.js +++ b/translate/translate.js @@ -18,7 +18,7 @@ function detectLanguage(text) { // [START translate_detect_language] // Imports the Google Cloud client library - const Translate = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate'); // Creates a client const translate = new Translate(); @@ -51,7 +51,7 @@ function detectLanguage(text) { function listLanguages() { // [START translate_list_codes] // Imports the Google Cloud client library - const Translate = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate'); // Creates a client const translate = new Translate(); @@ -74,7 +74,7 @@ function listLanguages() { function listLanguagesWithTarget(target) { // [START translate_list_language_names] // Imports the Google Cloud client library - const Translate = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate'); // Creates a client const translate = new Translate(); @@ -102,7 +102,7 @@ function listLanguagesWithTarget(target) { function translateText(text, target) { // [START translate_translate_text] // Imports the Google Cloud client library - const Translate = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate'); // Creates a client const translate = new Translate(); @@ -138,7 +138,7 @@ function translateText(text, target) { function translateTextWithModel(text, target, model) { // [START translate_text_with_model] // Imports the Google Cloud client library - const Translate = require('@google-cloud/translate'); + const {Translate} = require('@google-cloud/translate'); // Creates a client const translate = new Translate();