Skip to content

Commit 910f67d

Browse files
Anwesha NaskarAnwesha Naskar
authored andcommitted
test(tests): Adds tests to improve code coverage
1 parent d41409f commit 910f67d

File tree

2 files changed

+248
-0
lines changed

2 files changed

+248
-0
lines changed

test/integration/test.speech_to_text.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,34 @@ describe('speech_to_text_integration', function() {
375375
})
376376
);
377377

378+
it(
379+
'addAudio()',
380+
waitUntilReady(function(done) {
381+
speech_to_text.addAudio(
382+
{
383+
customization_id: customization_id,
384+
audio_name: 'blank',
385+
audio_resource: fs.readFileSync(path.join(__dirname, '../resources/blank.wav')),
386+
content_type: 'audio/wav',
387+
},
388+
done
389+
);
390+
})
391+
);
392+
393+
it(
394+
'deleteAudio()',
395+
waitUntilReady(function(done) {
396+
speech_to_text.deleteAudio(
397+
{
398+
customization_id: customization_id,
399+
audio_name: 'blank',
400+
},
401+
done
402+
);
403+
})
404+
);
405+
378406
it(
379407
'deleteCorpus()',
380408
waitUntilReady(function(done) {

test/unit/test.speech_to_text.v1.js

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,4 +816,224 @@ describe('speech_to_text', function() {
816816
assert.equal(req.method, 'DELETE');
817817
});
818818
});
819+
820+
describe('addAudio()', function() {
821+
const path = '/v1/acoustic_customizations/id_1/audio/audio1';
822+
823+
it('should check no parameters provided', function() {
824+
speech_to_text.addAudio({}, missingParameter);
825+
speech_to_text.addAudio(null, missingParameter);
826+
speech_to_text.addAudio({ customization_id: 'id_1', audio_name: 'audio' }, missingParameter);
827+
});
828+
829+
it('should generate a valid payload', function() {
830+
const req = speech_to_text.addAudio(
831+
{
832+
customization_id: 'id_1',
833+
audio_name: 'audio1',
834+
audio_resource: 'sample1',
835+
content_type: 'audio/basic',
836+
},
837+
noop
838+
);
839+
assert.equal(req.uri.href, service.url + path);
840+
assert.equal(req.method, 'POST');
841+
});
842+
});
843+
844+
describe('deleteAudio()', function() {
845+
const path = '/v1/acoustic_customizations/id_1/audio/audio1';
846+
847+
it('should check no parameters provided', function() {
848+
speech_to_text.deleteAudio({}, missingParameter);
849+
speech_to_text.deleteAudio(null, missingParameter);
850+
speech_to_text.deleteAudio({ customization_id: 'id_1' }, missingParameter);
851+
});
852+
853+
it('should generate a valid payload', function() {
854+
const req = speech_to_text.deleteAudio(
855+
{
856+
customization_id: 'id_1',
857+
audio_name: 'audio1',
858+
},
859+
noop
860+
);
861+
assert.equal(req.uri.href, service.url + path);
862+
assert.equal(req.method, 'DELETE');
863+
});
864+
});
865+
866+
describe('getAudio()', function() {
867+
const path = '/v1/acoustic_customizations/id_1/audio/audio1';
868+
869+
it('should check no parameters provided', function() {
870+
speech_to_text.getAudio({}, missingParameter);
871+
speech_to_text.getAudio(null, missingParameter);
872+
speech_to_text.getAudio({ customization_id: 'id_1' }, missingParameter);
873+
});
874+
875+
it('should generate a valid payload', function() {
876+
const req = speech_to_text.getAudio(
877+
{
878+
customization_id: 'id_1',
879+
audio_name: 'audio1',
880+
},
881+
noop
882+
);
883+
assert.equal(req.uri.href, service.url + path);
884+
assert.equal(req.method, 'GET');
885+
});
886+
});
887+
888+
describe('listAudio()', function() {
889+
const path = '/v1/acoustic_customizations/id_1/audio';
890+
891+
it('should check no parameters provided', function() {
892+
speech_to_text.listAudio({}, missingParameter);
893+
speech_to_text.listAudio(null, missingParameter);
894+
});
895+
896+
it('should generate a valid payload', function() {
897+
const req = speech_to_text.listAudio(
898+
{
899+
customization_id: 'id_1',
900+
},
901+
noop
902+
);
903+
assert.equal(req.uri.href, service.url + path);
904+
assert.equal(req.method, 'GET');
905+
});
906+
});
907+
908+
describe('createAcousticModel()', function() {
909+
const path = '/v1/acoustic_customizations';
910+
911+
it('should check no parameters provided', function() {
912+
speech_to_text.createAcousticModel({}, missingParameter);
913+
speech_to_text.createAcousticModel(null, missingParameter);
914+
speech_to_text.createAcousticModel({ name: 'name1' }, missingParameter);
915+
});
916+
917+
it('should generate a valid payload', function() {
918+
const req = speech_to_text.createAcousticModel(
919+
{
920+
name: 'name1',
921+
base_model_name: 'base1',
922+
},
923+
noop
924+
);
925+
assert.equal(req.uri.href, service.url + path);
926+
assert.equal(req.method, 'POST');
927+
});
928+
});
929+
930+
describe('deleteAcousticModel()', function() {
931+
const path = '/v1/acoustic_customizations/id1';
932+
933+
it('should check no parameters provided', function() {
934+
speech_to_text.deleteAcousticModel({}, missingParameter);
935+
speech_to_text.deleteAcousticModel(null, missingParameter);
936+
});
937+
938+
it('should generate a valid payload', function() {
939+
const req = speech_to_text.deleteAcousticModel(
940+
{
941+
customization_id: 'id1',
942+
},
943+
noop
944+
);
945+
assert.equal(req.uri.href, service.url + path);
946+
assert.equal(req.method, 'DELETE');
947+
});
948+
});
949+
950+
describe('getAcousticModel()', function() {
951+
const path = '/v1/acoustic_customizations/id1';
952+
953+
it('should check no parameters provided', function() {
954+
speech_to_text.getAcousticModel({}, missingParameter);
955+
speech_to_text.getAcousticModel(null, missingParameter);
956+
});
957+
958+
it('should generate a valid payload', function() {
959+
const req = speech_to_text.getAcousticModel(
960+
{
961+
customization_id: 'id1',
962+
},
963+
noop
964+
);
965+
assert.equal(req.uri.href, service.url + path);
966+
assert.equal(req.method, 'GET');
967+
});
968+
});
969+
970+
describe('listAcousticModels()', function() {
971+
const path = '/v1/acoustic_customizations';
972+
973+
it('should generate a valid payload', function() {
974+
const req = speech_to_text.listAcousticModels({}, noop);
975+
assert.equal(req.uri.href, service.url + path);
976+
assert.equal(req.method, 'GET');
977+
});
978+
});
979+
980+
describe('resetAcousticModel()', function() {
981+
const path = '/v1/acoustic_customizations/id1/reset';
982+
983+
it('should check no parameters provided', function() {
984+
speech_to_text.resetAcousticModel({}, missingParameter);
985+
speech_to_text.resetAcousticModel(null, missingParameter);
986+
});
987+
988+
it('should generate a valid payload', function() {
989+
const req = speech_to_text.resetAcousticModel(
990+
{
991+
customization_id: 'id1',
992+
},
993+
noop
994+
);
995+
assert.equal(req.uri.href, service.url + path);
996+
assert.equal(req.method, 'POST');
997+
});
998+
});
999+
1000+
describe('trainAcousticModel()', function() {
1001+
const path = '/v1/acoustic_customizations/id1/train';
1002+
1003+
it('should check no parameters provided', function() {
1004+
speech_to_text.trainAcousticModel({}, missingParameter);
1005+
speech_to_text.trainAcousticModel(null, missingParameter);
1006+
});
1007+
1008+
it('should generate a valid payload', function() {
1009+
const req = speech_to_text.trainAcousticModel(
1010+
{
1011+
customization_id: 'id1',
1012+
},
1013+
noop
1014+
);
1015+
assert.equal(req.uri.href, service.url + path);
1016+
assert.equal(req.method, 'POST');
1017+
});
1018+
});
1019+
1020+
describe('upgradeAcousticModel()', function() {
1021+
const path = '/v1/acoustic_customizations/id1/upgrade_model';
1022+
1023+
it('should check no parameters provided', function() {
1024+
speech_to_text.upgradeAcousticModel({}, missingParameter);
1025+
speech_to_text.upgradeAcousticModel(null, missingParameter);
1026+
});
1027+
1028+
it('should generate a valid payload', function() {
1029+
const req = speech_to_text.upgradeAcousticModel(
1030+
{
1031+
customization_id: 'id1',
1032+
},
1033+
noop
1034+
);
1035+
assert.equal(req.uri.href, service.url + path);
1036+
assert.equal(req.method, 'POST');
1037+
});
1038+
});
8191039
});

0 commit comments

Comments
 (0)