Skip to content

Instantly share code, notes, and snippets.

@hltbra
Created May 17, 2011 23:02
Show Gist options
  • Save hltbra/977613 to your computer and use it in GitHub Desktop.
Save hltbra/977613 to your computer and use it in GitHub Desktop.
describe("CompletaPraMim", function() {
var NAMES_JSON = 'http://localhost:4567/names.json';
var result;
var completer = new CompletaPraMim(NAMES_JSON, function(values) {
result = values;
});
function checkIf(options) {
runs(function() {
completer.tell(options.telling);
});
waits(600);
runs(function() {
expect(result).toEqual(options.outputs);
});
}
beforeEach(function() {
result = [];
});
it("should returns empty list when JSON is empty", function() {
checkIf({telling: 'abc',
outputs: []});
});
it("should return elements whose starting text matches", function() {
var paul = ['value1', 'Paul'];
checkIf({telling: 'P',
outputs: [paul]});
});
it("should be able to return multilpes elements", function() {
var paul = ['value2', 'Beatle1: Paul'];
var john = ['value3', 'Beatle2: John'];
checkIf({telling: 'Beatle',
outputs: [paul, john]});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment