return testApp.request(mockHelper.load("audio_player_events/playback_finished.json")) .should.eventually.be.fulfilled .and.not.have.deep.property("response.outputSpeech.type"); }); }); return testApp.request(mockHelper.load("audio_player_events/playback_failed.json")) .should.eventually.be.fulfilled .and.not.have.deep.property("response.outputSpeech.type"); }); }); return testApp.request(mockHelper.load("audio_player_events/playback_nearly_finished.json")) .should.eventually.be.fulfilled .and.not.have.deep.property("response.outputSpeech.type"); }); }); return testApp.request(mockHelper.load("audio_player_events/playback_started.json")) .should.eventually.be.fulfilled .and.not.have.deep.property("response.outputSpeech.type"); }); }); return testApp.request(mockHelper.load("audio_player_events/playback_stopped.json")) .should.eventually.be.fulfilled .and.not.have.deep.property("response.outputSpeech.type"); }); });
return testApp.request(mockRequest) .should.eventually.be.fulfilled .and.not.have.deep.property("response.outputSpeech.type"); });
return response.response.directives; }); return expect(subject).to.eventually.deep.include(dialogDirective); });
it("should properly handle boolean parameters", function() { var query = conn.query("CREATE TABLE bar (a BOOLEAN, b BOOLEAN)").then(function() { return conn.query("INSERT INTO bar VALUES (?, ?)", [true, false]); }).then(function() { return conn.query("SELECT * FROM bar"); }); return shouldHaveValidResult(query, 1, 2, ["a", "b"]) .should.eventually.have.property("data") .that.deep.equals([[true, false]]); });
it("should properly handle (escaped) quotes", function() { var query = conn.query("SELECT '\\\\asdf' AS a, '\"' AS b, '\\\"' AS c, '\\\\\"' AS d, '\\'' AS e"); return shouldHaveValidResult(query, 1, 5, ["a", "b", "c", "d", "e"]) .should.eventually.have.property("data") .that.deep.equals([['\\asdf', '"', '\"', '\\"', "'"]]); });
describe('Output', function() { it('Should be resolved with the same passed context', function() { return expect(runResult).to.eventually.equal(context).deep.equal(sample.hints.context); }); it('Should provide a default context if no context is passed', function() { return expect(runWithoutContextResult).to.eventually.be.an('object'); }); it('Should return a promise', function() { expect(runResult).to.be.a('promise'); expect(runWithoutContextResult).to.be.a('promise'); }); });
it("should properly store and retrieve escaped values", function() { var query = conn.query( "CREATE TABLE foo(a string);\n" + "INSERT INTO foo VALUES ('\t\n\r\n\tlalala\t\n\r')" ).then(function() { return conn.query("SELECT * FROM foo"); }); return shouldHaveValidResult(query, 1, 1, ["a"]) .should.eventually.have.property("data") .that.deep.equals([['\t\n\r\n\tlalala\t\n\r']]); });
it("should properly rebuild stored JSON", function() { var json = {a: 9, b: {c: 's'}, c: [1,2,3,{a: 1}]}; var query = conn.query("CREATE TABLE foo (a JSON)").then(function() { return conn.query("INSERT INTO foo VALUES ('" + JSON.stringify(json) + "')"); }).then(function() { return conn.query("SELECT * FROM foo"); }); return shouldHaveValidResult(query, 1, 1, ["a"]) .should.eventually.have.property("data") .that.deep.equals([[json]]); });
return response.response.directives; }); return expect(subject).to.eventually.deep.include(dialogDirective); });
it("should properly handle null parameters", function() { var query = conn.query("CREATE TABLE bar (a INT)").then(function() { return conn.query("INSERT INTO bar VALUES (?)", [null]); }).then(function() { return conn.query("SELECT * FROM bar"); }); return shouldHaveValidResult(query, 1, 1, ["a"]) .should.eventually.have.property("data") .that.deep.equals([[null]]); });
it("should properly convert booleans", function() { var query = conn.query("CREATE TABLE foo (a BOOLEAN, b BOOLEAN)").then(function() { return conn.query("INSERT INTO foo VALUES (true, false)"); }).then(function() { return conn.query("SELECT * FROM foo"); }); return shouldHaveValidResult(query, 1, 2, ["a", "b"]) .should.eventually.have.property("data") .that.deep.equals([[true, false]]); });
it("should properly handle NULL values", function() { var query = conn.query("CREATE TABLE foo (a INT)").then(function() { return conn.query("INSERT INTO foo VALUES (NULL)"); }).then(function() { return conn.query("SELECT * FROM foo"); }); return shouldHaveValidResult(query, 1, 1, ["a"]) .should.eventually.have.property("data") .that.deep.equals([[null]]); });
it("should properly handle json parameters", function() { var json = {a: 9, b: {c: 's'}, c: [1,2,3,{a: 1}]}; var query = conn.query("CREATE TABLE bar (a JSON)").then(function() { return conn.query("INSERT INTO bar VALUES (?)", [json]); }).then(function() { return conn.query("SELECT * FROM bar"); }); return shouldHaveValidResult(query, 1, 1, ["a"]) .should.eventually.have.property("data") .that.deep.equals([[json]]); });
it("should generate pretty results when requested implicitly through query params", function() { var query = conn.query( "INSERT INTO foo VALUES (42,4.2,'42'),(43,4.3,'43'),(44,4.4,'44'),(45,4.5,'45')" ).then(function() { return conn.query("SELECT * FROM foo WHERE d > ?", [42], true); }); return shouldHaveValidResult(query, 3, 3, ["d", "e", "f"]) .should.eventually.have.property("data") .that.deep.equals([ {d: 43, e: 4.3, f: "43"}, {d: 44, e: 4.4, f: "44"}, {d: 45, e: 4.5, f: "45"} ]); });
it("should yield a valid pretty result on demand", function() { var query = conn.query( "CREATE TABLE foo(a INT, b FLOAT, c BLOB);\n" + "INSERT INTO foo VALUES (42,4.2,'42'),(43,4.3,'43'),(44,4.4,'44'),(45,4.5,'45')" ).then(function() { return conn.query("SELECT * FROM foo", true); }); return shouldHaveValidResult(query, 4, 3, ["a", "b", "c"]) .should.eventually.have.property("data") .that.deep.equals([ {a: 42, b: 4.2, c: "42"}, {a: 43, b: 4.3, c: "43"}, {a: 44, b: 4.4, c: "44"}, {a: 45, b: 4.5, c: "45"} ]); });