Skip to content

Commit cc698c4

Browse files
committed
refactor: migrate tests to use correct import mechanism
1 parent 4d42940 commit cc698c4

13 files changed

+31
-77
lines changed

index.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -95,40 +95,3 @@ Object.keys(servicesByVersion).forEach(serviceName => {
9595
}
9696
});
9797
});
98-
99-
// removed services
100-
// we don't want these services listed (so non-enumerable), but we do want a clear error message
101-
// if old code happens to try using one
102-
[
103-
'concept_insights',
104-
'relationship_extraction',
105-
'message_resonance',
106-
'question_and_answer',
107-
'visual_insights',
108-
'concept_expansion',
109-
'retrieve_and_rank',
110-
'alchemy_language',
111-
'alchemy_data_news',
112-
'tradeoff_analytics'
113-
].forEach(serviceName => {
114-
Object.defineProperty(exports, serviceName, {
115-
enumerable: false,
116-
configurable: true,
117-
writable: true,
118-
value() {
119-
throw new Error('The ' + serviceName + ' service is no longer available');
120-
}
121-
});
122-
});
123-
['AlchemyVisionV1', 'alchemy_vision'].forEach(serviceName => {
124-
Object.defineProperty(exports, serviceName, {
125-
enumerable: false,
126-
configurable: true,
127-
writable: true,
128-
value() {
129-
throw new Error(
130-
'The Alchemy Vision service is no longer available, please use Visual Recognition instead.'
131-
);
132-
}
133-
});
134-
});

test/integration/assistant.v1.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const watson = require('../../index');
3+
const AssistantV1 = require('../../assistant/v1');
44
const authHelper = require('../resources/auth_helper.js');
55
const auth = authHelper.auth;
66
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
@@ -102,7 +102,7 @@ const workspace1 = extend(true, {}, workspace, intents, { language: workspace.la
102102
describe('assistant_integration', function() {
103103
jest.setTimeout(TEN_SECONDS);
104104
auth.conversation.version = '2018-02-16';
105-
const assistant = new watson.AssistantV1(auth.conversation);
105+
const assistant = new AssistantV1(auth.conversation);
106106

107107
describe('message()', function() {
108108
it('alternate_intents with custom headers', function(done) {
@@ -132,7 +132,7 @@ describe('assistant_integration', function() {
132132
const constructorParams = assign({}, auth.assistant, {
133133
version: '2017-02-03',
134134
});
135-
const assistant = new watson.AssistantV1(constructorParams);
135+
const assistant = new AssistantV1(constructorParams);
136136

137137
const params = {
138138
input: {
@@ -156,7 +156,7 @@ describe('assistant_integration', function() {
156156
const constructorParams = assign({}, auth.assistant, {
157157
version: '2016-09-20',
158158
});
159-
const assistant = new watson.AssistantV1(constructorParams);
159+
const assistant = new AssistantV1(constructorParams);
160160

161161
const params = {
162162
input: {
@@ -180,7 +180,7 @@ describe('assistant_integration', function() {
180180
const constructorParams = assign({}, auth.assistant, {
181181
version: '2016-07-11',
182182
});
183-
const assistant = new watson.AssistantV1(constructorParams);
183+
const assistant = new AssistantV1(constructorParams);
184184

185185
const params = {
186186
input: {

test/integration/assistant.v2.test.js

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

3-
const watson = require('../../index');
3+
const AssistantV2 = require('../../assistant/v2');
44
const authHelper = require('../resources/auth_helper.js');
55

66
const auth = authHelper.auth.assistant;
77
auth.version = '2018-09-19';
88

99
describe('assistant v2 integration', function() {
10-
const assistant = new watson.AssistantV2(auth);
10+
const assistant = new AssistantV2(auth);
1111
const assistant_id = auth.assistant_id;
1212
let session_id;
1313

test/integration/discovery.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const DiscoveryV1 = require('../../discovery/v1-generated');
3+
const DiscoveryV1 = require('../../discovery/v1');
44
const authHelper = require('../resources/auth_helper.js');
55
const auth = authHelper.auth;
66
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)

test/integration/language_translator.v3.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const watson = require('../../index');
3+
const LanguageTranslatorV3 = require('../../language-translator/v3');
44
const authHelper = require('../resources/auth_helper.js');
55
const auth = authHelper.auth;
66
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
@@ -11,7 +11,7 @@ describe('language_translator_integration', function() {
1111
jest.setTimeout(TWENTY_SECONDS * 2);
1212

1313
auth.language_translator.v3.version = '2018-05-01';
14-
const language_translator = new watson.LanguageTranslatorV3(auth.language_translator.v3);
14+
const language_translator = new LanguageTranslatorV3(auth.language_translator.v3);
1515

1616
it('listModels()', function(done) {
1717
language_translator.listModels(null, done);

test/integration/natural_language_classifier.test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

3-
const watson = require('../../index');
4-
const assert = require('assert');
3+
const NaturalLanguageClassifierV1 = require('../../natural-language-classifier/v1');
54
const authHelper = require('../resources/auth_helper.js');
65
const auth = authHelper.auth;
76
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
@@ -10,7 +9,7 @@ const TWENTY_SECONDS = 20000;
109
describe('natural_language_classifier_integration', function() {
1110
jest.setTimeout(TWENTY_SECONDS);
1211

13-
const natural_language_classifier = new watson.NaturalLanguageClassifierV1(
12+
const natural_language_classifier = new NaturalLanguageClassifierV1(
1413
auth.natural_language_classifier
1514
);
1615

@@ -22,7 +21,7 @@ describe('natural_language_classifier_integration', function() {
2221
if (err) {
2322
return done(err);
2423
}
25-
assert.equal(result.classifier_id, params.classifier_id);
24+
expect(result.classifier_id).toBe(params.classifier_id);
2625
done();
2726
});
2827
});
@@ -36,7 +35,7 @@ describe('natural_language_classifier_integration', function() {
3635
if (err) {
3736
return done(err);
3837
}
39-
assert.equal(result.classifier_id, params.classifier_id);
38+
expect(result.classifier_id).toBe(params.classifier_id);
4039
done();
4140
});
4241
});

test/integration/personality_insights.v3.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const fs = require('fs');
4-
const watson = require('../../index');
4+
const PersonalityInsightsV3 = require('../../personality-insights/v3');
55
const path = require('path');
66
const authHelper = require('../resources/auth_helper.js');
77
const auth = authHelper.auth;
@@ -13,7 +13,7 @@ describe('personality_insights_v3_integration', function() {
1313

1414
const mobydick = fs.readFileSync(path.join(__dirname, '../resources/mobydick.txt'), 'utf8');
1515
auth.personality_insights.version = '2016-10-19';
16-
const personality_insights = new watson.PersonalityInsightsV3(auth.personality_insights);
16+
const personality_insights = new PersonalityInsightsV3(auth.personality_insights);
1717

1818
it('profile with text content', function(done) {
1919
const params = {

test/integration/speech_to_text.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const authHelper = require('../resources/auth_helper.js');
44
const auth = authHelper.auth;
55
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
6-
const watson = require('../../index');
6+
const SpeechToTextV1 = require('../../speech-to-text/v1');
77
const fs = require('fs');
88
const concat = require('concat-stream');
99
const path = require('path');
@@ -15,8 +15,8 @@ const TWO_MINUTES = 2 * 60 * 1000;
1515
describe('speech_to_text_integration', function() {
1616
jest.setTimeout(TWENTY_SECONDS);
1717

18-
const speech_to_text = new watson.SpeechToTextV1(auth.speech_to_text);
19-
const speech_to_text_rc = new watson.SpeechToTextV1(auth.speech_to_text_rc);
18+
const speech_to_text = new SpeechToTextV1(auth.speech_to_text);
19+
const speech_to_text_rc = new SpeechToTextV1(auth.speech_to_text_rc);
2020

2121
it('recognize() (RC) @slow', function(done) {
2222
const params = {
@@ -120,7 +120,7 @@ describe('speech_to_text_integration', function() {
120120
it('transcribes audio over a websocket, credentials from environment', function(done) {
121121
process.env.SPEECH_TO_TEXT_IAM_APIKEY = auth.speech_to_text_rc.iam_apikey;
122122
process.env.SPEECH_TO_TEXT_URL = auth.speech_to_text_rc.url;
123-
const speech_to_text_env = new watson.SpeechToTextV1({});
123+
const speech_to_text_env = new SpeechToTextV1({});
124124
const recognizeStream = speech_to_text_env.recognizeUsingWebSocket();
125125
recognizeStream.setEncoding('utf8');
126126
fs.createReadStream(path.join(__dirname, '../resources/weather.flac'))
@@ -148,7 +148,7 @@ describe('speech_to_text_integration', function() {
148148
},
149149
],
150150
});
151-
const speech_to_text_vcap = new watson.SpeechToTextV1({});
151+
const speech_to_text_vcap = new SpeechToTextV1({});
152152
const recognizeStream = speech_to_text_vcap.recognizeUsingWebSocket();
153153
recognizeStream.setEncoding('utf8');
154154
fs.createReadStream(path.join(__dirname, '../resources/weather.flac'))
@@ -229,7 +229,7 @@ describe('speech_to_text_integration', function() {
229229
speech_to_text.whenCustomizationReady(
230230
{ customization_id: customization_id, interval: 250, times: 400 },
231231
function(err) {
232-
if (err && err.code !== watson.SpeechToTextV1.ERR_NO_CORPORA) {
232+
if (err && err.code !== SpeechToTextV1.ERR_NO_CORPORA) {
233233
return done(err);
234234
}
235235
test(done);
@@ -239,7 +239,7 @@ describe('speech_to_text_integration', function() {
239239
}
240240

241241
beforeAll(function(done) {
242-
const speech_to_text = new watson.SpeechToTextV1(auth.speech_to_text);
242+
const speech_to_text = new SpeechToTextV1(auth.speech_to_text);
243243
speech_to_text.listLanguageModels({}, function(err, result) {
244244
if (err) {
245245
// eslint-disable-next-line no-console

test/integration/text_to_speech.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const watson = require('../../index');
3+
const TextToSpeechV1 = require('../../text-to-speech/v1');
44
const wav = require('wav');
55
const authHelper = require('../resources/auth_helper.js');
66
const auth = authHelper.auth;
@@ -10,7 +10,7 @@ const TWENTY_SECONDS = 20000;
1010
describe('text_to_speech_integration', function() {
1111
jest.setTimeout(TWENTY_SECONDS);
1212

13-
const text_to_speech = new watson.TextToSpeechV1(auth.text_to_speech);
13+
const text_to_speech = new TextToSpeechV1(auth.text_to_speech);
1414

1515
it('listVoices()', function(done) {
1616
text_to_speech.listVoices(null, done);

test/integration/tone_analyzer.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const fs = require('fs');
4-
const watson = require('../../index');
4+
const ToneAnalyzerV3 = require('../../tone-analyzer/v3');
55
const path = require('path');
66
const authHelper = require('../resources/auth_helper.js');
77
const auth = authHelper.auth;
@@ -12,7 +12,7 @@ describe('tone_analyzer_integration', function() {
1212
jest.setTimeout(TWENTY_SECONDS);
1313

1414
auth.tone_analyzer.version = '2016-06-19';
15-
const tone_analyzer = new watson.ToneAnalyzerV3(auth.tone_analyzer);
15+
const tone_analyzer = new ToneAnalyzerV3(auth.tone_analyzer);
1616

1717
it('tone()', function(done) {
1818
const mobydick = fs.readFileSync(path.join(__dirname, '../resources/tweet.txt'), 'utf8');

0 commit comments

Comments
 (0)