TalAter / annyang

💬 Speech recognition for your site
https://www.talater.com/annyang/
MIT License
6.57k stars 1.05k forks source link

first-timers-only: Add test to make sure result callbacks returns possible sentences #170

Closed TalAter closed 8 years ago

TalAter commented 8 years ago

first-timers-only

This issue is tagged :octocat: first-timers-only. It is only for people who have never contributed to open source before, and are looking for an easy way take their first steps.

Thank you for your help :heart:

Background

Callbacks added using annyang.addCallback('result', aFunction) will be called after any speech is detected, whether a command was matched or not (see docs).

The callback function should be called with an array of the possible sentences the user may have said as the first argument.

The Issue

The test specs do not currently test to verify that the callback function is called with the possible sentences the user may have said

Add a test spec that verify this spec:

  it('should call the callback with the the first argument containing an array of all possible Speech Recognition Alternatives the user may have said', func1);

This should be added into the following test suite:

describe("annyang.addCallback('result')", function() {

The last test described inside describe("annyang.addCallback('resultNoMatch')", function() {…}); in test/spec/BasicSpec.js, can be used as a template for adding the new spec described above.

Contributing to annyang

annyang is tested using Jasmine.

BasicSpec.js contains a series of spec groups (e.g. describe('a spec group', function() {})) which each contain 1 or more specs (e.g. it('should do stuff', function() {})). Some of the spec groups also contain some code which runs before each spec (beforeEach(function() {})).

To simulate Speech Recognition in the testing environment, annyang uses a mock object called Corti which mocks the browser's SpeechRecognition object. Corti also adds a number of utility functions to the SpeechRecognition object which simulate user actions (e.g. say('Hello there')), and allow checking the SpeechRecognition's status (e.g. isListening() === true).

varjmes commented 8 years ago

Another fantastic issue, going to post this on the @yourfirstpr twitter account tomorrow!

TalAter commented 8 years ago

Thank you @Charlotteis :blush:

ZahraTee commented 8 years ago

I'd be happy to take a look at this. :)

I'm just wondering whether there's a particular reason why "the" is repeated in the test spec outlined here? I notice it's the case for all of the test specs beginning "should call the callback with" in BasicSpec.js.

TalAter commented 8 years ago

Thanks @ZahraTee, I'm looking forward to your contribution.

Regarding the 'the', that was just a typo. I'm pushing a fix for that now. Nicely spotted :eyes:

TalAter commented 8 years ago

Closed in PR #171

Code looks great @ZahraTee.

Thank you for the help, and I hope it is the first of many :octocat: contributions to open source!

P.S. - When submitting pull requests, some project maintainers would ask you to submit your work as a single commit. In the future, you can squash multiple commits like the 2 you had in this pull request into a single commit before sending the pull request. Check out this handy tutorial by @kentcdodds on how to do this - https://egghead.io/lessons/javascript-how-to-squash-multiple-git-commits?series=how-to-contribute-to-an-open-source-project-on-github

Thanks again :+1: