Skip to content

Commit

Permalink
method for querying a Luis app url
Browse files Browse the repository at this point in the history
  • Loading branch information
fczuardi committed Apr 23, 2016
1 parent 000d00d commit 18b6242
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"coveralls": "^2.11.9",
"eslint-config-calamar": "^1.0.3",
"npm-run-all": "^1.7.0",
"nyc": "^6.4.0"
"nyc": "^6.4.0",
"request-promise": "^3.0.0"
}
}
15 changes: 15 additions & 0 deletions src/lib/luis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import request from 'request-promise';

const brainURL = process.env.LUIS_APP_URL;

const query = (text) => {
const url = `${brainURL}&q=${text}`;
return request(url).then(body => {
return(JSON.parse(body));
});
};

export {
brainURL,
query
};
15 changes: 8 additions & 7 deletions test/luis.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import test from 'ava';

const brainURL = process.env.LUIS_APP_URL;
import * as luis from 'lib/luis';

test('Evironment var for the Luis app is set', t => {
t.truthy(brainURL);
t.truthy(luis.brainURL);
});

test.skip('GET on Luis URL returns a JSON', t => {
t.pass();
test('GET on Luis URL returns an object', t => {
return luis.query('').then(result => {
t.is(typeof result, 'object');
}).catch( err => {
t.is(err.statusCode, 200);
});;
});

test.todo('Get on the Luis url returns a JSON');

0 comments on commit 18b6242

Please sign in to comment.