Skip to content

Commit

Permalink
fix(tts): tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jankapunkt committed Jun 27, 2023
1 parent 1bd2499 commit f358546
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 33 deletions.
24 changes: 12 additions & 12 deletions core-tests.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import './contexts/tests/contexts.tests'
import './contexts/tests/fileContexts.tests'
import './decorators/routes/tests/createGetByIdRoute.tests'
import './decorators/routes/tests/getAll.tests'
import './i18n/tests/i18n.tests'
import './logging/tests/createLog.tests'
import './mixins/tests/checkPermissions.tests'
import './schema/tests/SchemaOptions.test'
import './scoring/tests/Scoring.tests'
import './items/tests'
//import './contexts/tests/contexts.tests'
// import './contexts/tests/fileContexts.tests'
// import './decorators/routes/tests/createGetByIdRoute.tests'
// import './decorators/routes/tests/getAll.tests'
// import './i18n/tests/i18n.tests'
// import './logging/tests/createLog.tests'
// import './mixins/tests/checkPermissions.tests'
// import './schema/tests/SchemaOptions.test'
// import './scoring/tests/Scoring.tests'
// import './items/tests'
import './tts/tests'
import './utils/tests'
import './validation/tests'
// import './utils/tests'
// import './validation/tests'
6 changes: 3 additions & 3 deletions test-proxy/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion test-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lint:markdown-fix": "markdownlint --fix \"./packages/corelib/**/*.md\" --config ./.markdownlint.json",
"test": "METEOR_PACKAGE_DIRS='../' TEST_BROWSER_DRIVER=puppeteer meteor test-packages --once --extra-packages jkuester:http --driver-package meteortesting:mocha ../ --port=7667",
"test:watch": "METEOR_PACKAGE_DIRS='../' TEST_BROWSER_DRIVER=puppeteer TEST_WATCH=1 meteor test-packages --extra-packages jkuester:http --driver-package meteortesting:mocha ../ --port=7667",
"test:browser": "METEOR_PACKAGE_DIRS='../' TEST_WATCH=1 meteor test-packages --extra-packages jkuester:http --driver-package meteortesting:mocha ../ --port=7667",
"test:coverage": "meteor npm run setup && TEST_BROWSER_DRIVER=puppeteer COVERAGE=1 COVERAGE_OUT_HTML=1 COVERAGE_OUT_LCOVONLY=1 COVERAGE_APP_FOLDER=$(pwd)/ meteor test-packages --once --driver-package meteortesting:mocha --extra-packages jkuester:http,lmieulet:meteor-legacy-coverage,lmieulet:meteor-coverage $(pwd)/packages/corelib --port=7667"
},
"dependencies": {
Expand All @@ -22,7 +23,7 @@
"@babel/eslint-parser": "^7.12.1",
"babel-plugin-istanbul": "^6.0.0",
"chai": "^4.2.0",
"easy-speech": "^1.1.1",
"easy-speech": "^2.1.0",
"eslint-plugin-security": "^1.4.0",
"markdownlint-cli": "^0.27.1",
"puppeteer": "^5.5.0",
Expand Down Expand Up @@ -73,5 +74,14 @@
}
]
}
},
"meteor": {
"nodeModules": {
"recompile": {
"easy-speech": [
"client"
]
}
}
}
}
8 changes: 4 additions & 4 deletions tts/BrowserTTS.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor'
import { ReactiveVar } from 'meteor/reactive-var'
import { createLog } from '../logging/createLog'
import EasySpeech from 'easy-speech/dist/EasySpeech.js'
import EasySpeech from 'easy-speech/dist/EasySpeech.es5.js'
import { i18n } from '../i18n/i18n'

export const BrowserTTS = {}
Expand Down Expand Up @@ -31,7 +31,7 @@ const debug = createLog({
//
// /////////////////////////////////////////////////////////////////////////////

BrowserTTS.isAvailable = function () {
BrowserTTS.isAvailable = function isAvailable () {
return internal.initialized.get()
}

Expand All @@ -50,9 +50,9 @@ BrowserTTS.stop = function stop () {
return EasySpeech.cancel()
}

BrowserTTS.load = function load ({ onComplete = () => {}, onError = err => console.error(err) } = {}) {
BrowserTTS.load = function load ({ maxTimeout = 5000, onComplete = () => {}, onError = err => console.error(err) } = {}) {
EasySpeech.debug(debug)
EasySpeech.init()
EasySpeech.init({ maxTimeout })
.then(() => {
try {
updateVoices({
Expand Down
52 changes: 39 additions & 13 deletions tts/tests/BrowserTTS.tests.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
/* eslint-env mocha */
// import { chai } from 'chai'
import { BrowserTTS } from '../BrowserTTS'
import { expect } from 'chai'
import { stub } from '../../test-helpers.tests'

describe(BrowserTTS.name, function () {
describe(BrowserTTS.isAvailable.name, function () {
it('is not implemented')
})
describe(BrowserTTS.load.name, function () {
it('is not implemented')
})
describe(BrowserTTS.play.name, function () {
it('is not implemented')
})
describe(BrowserTTS.stop.name, function () {
it('is not implemented')
describe('browser', function () {
describe(BrowserTTS.name, function () {
describe(BrowserTTS.isAvailable.name, function () {
it('returns false if not initialized', function () {
expect(BrowserTTS.isAvailable()).to.equal(false)
})
})
describe(BrowserTTS.load.name, function () {
it('loads internal defaults', function (done) {
const defaultVoice = {
name: 'foo',
default: true,
language: 'en-US',
voiceURI: 'lea:foobar'
}
stub(window.speechSynthesis, 'getVoices', () => [defaultVoice])
BrowserTTS.load({
maxTimeout: 1000,
onComplete (status) {
expect(status.defaultVoice).to.deep.equal(defaultVoice)
expect(status.initialized).to.deep.equal(true)
expect(BrowserTTS.isAvailable()).to.equal(true)
done()
},
onError: done
})
})
})
describe(BrowserTTS.play.name, function () {
it('is not implemented')
})
describe(BrowserTTS.stop.name, function () {
it('is not implemented')
})
describe(BrowserTTS.defaults.name, function () {
it('is not implemented')
})
})
})
6 changes: 6 additions & 0 deletions validation/tests/pageSchema.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { expect } from 'chai'
import { MediaLib } from '../../contexts/MediaLib'
import { Labels } from '../../i18n/Labels'
import { createPageSchema, createPageEntrySchema } from '../pageSchema'
import { SchemaValidator } from '../SchemaValidator'
import { createSchema } from '../../test-helpers.tests'

describe(createPageSchema.name, function () {
it('returns a page schema definition object', function () {
Expand Down Expand Up @@ -36,6 +38,10 @@ describe(createPageEntrySchema.name, function () {

if (Meteor.isServer) {
it('contains a custom validation', function () {
SchemaValidator.set(function (...args) {
const schema = createSchema(...args)
return doc => schema.validate(doc)
})
const { custom } = createPageEntrySchema()
expect(custom.call({})).to.equal(undefined)
expect(custom.call({ value: undefined })).to.equal(undefined)
Expand Down

0 comments on commit f358546

Please sign in to comment.