scratch-vm/test/unit/extension_text_to_speech.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-03-07 16:33:20 -05:00
const test = require('tap').test;
const TextToSpeech = require('../../src/extensions/scratch3_text2speech/index.js');
const fakeStage = {
textToSpeechLanguage: null
};
const fakeRuntime = {
getTargetForStage: () => fakeStage,
on: () => {} // Stub out listener methods used in constructor.
};
const ext = new TextToSpeech(fakeRuntime);
test('if no language is saved in the project, use default', t => {
t.strictEqual(ext.getCurrentLanguage(), 'en');
t.end();
});
test('if an unsupported language is dropped onto the set language block, use default', t => {
ext.setLanguage({LANGUAGE: 'nope'});
t.strictEqual(ext.getCurrentLanguage(), 'en');
t.end();
});
2019-10-31 14:56:28 -04:00
test('if a supported language name is dropped onto the set language block, use it', t => {
ext.setLanguage({LANGUAGE: 'español'});
t.strictEqual(ext.getCurrentLanguage(), 'es');
t.end();
});
2019-03-07 16:33:20 -05:00
test('get the extension locale for a supported locale that differs', t => {
2019-10-04 14:14:37 -04:00
ext.setLanguage({LANGUAGE: 'ja-hira'});
2019-03-07 16:33:20 -05:00
t.strictEqual(ext.getCurrentLanguage(), 'ja');
t.end();
});