Comments (3)
This is an issue that I struggle with myself. Lacona Output is designed primarily to describe an interface, not necessarily raw data... so testing it is not always natural.
For https://github.com/lacona/lacona-phrase-datetime, assume that for each "complete" input, there is one "correct" output. That is, if the user has entered a full phrase, there should be no ambiguity there. Because I make that assumption, I just
- Filter out all of the outputs that have
placeholder
words in them, because these are not complete. - Verify that there is only one output
- Compare result value
- Compare the raw text of the output to make sure that it is the same as the input, using
function text (input) {
return _.map(input.words, 'text').join('')
}
Of course, this has some issues. It doesn't work to test what lacona outputs as the user is typing. And it doesn't work for cases like yours, where a valid input "10 mi" could be the initial substring of another valid input "10 mile".
In your case, I would actually modify your phrase and add a limit
to your <choice>
, maybe something like this.
<sequence>
<Number />
<literal text=' ' />
<choice>
<choice limit={1}>
<literal text='m' />
<literal text='meters' />
</choice>
<choice limit={1}>
<literal text='mi' />
<literal text='miles' />
</choice>
</choice>
</sequence>
With this, Lacona will never "miles" for the input of "mi", because one of the choices matched already. So
'10 m' suggests '10 m' and '10 mi'
'10 me' suggests '10 meters'
'10 mi' suggests '10 mi'
'10 mil' suggests '10 miles'
That's possibly a better interface for the user, because it won't be making multiple suggestions that are functionally identical. It has the side effect of making your testing easier!
from elliptical.
Thanks. That makes a lot of sense. I'll try it out this weekend and let you know how it goes.
from elliptical.
Closing this for now, please let me know how your trial goes.
from elliptical.
Related Issues (16)
- brew cask apps aren't detected to be opened as an Application HOT 2
- Issue: Command List HOT 4
- Getting more done in GitHub with ZenHub HOT 2
- Submit to JSDelivr HOT 1
- Submit to JSDelivr HOT 3
- Can't get examples to work. HOT 2
- Phrase dependency management HOT 3
- Closed
- Documentation links don't work. HOT 2
- How to create phrase that can choose multiple items in one 'branch'?
- How it works under the hood? HOT 2
- Cannot make this work - only returns 'undefined' HOT 2
- Moving to a new Phrase structure HOT 1
- Cannot read property 'defaultProps' of undefined HOT 2
- need bare-bone example HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elliptical.