FAC-11 / theLibrary

THE centralised resource of useful weblinks for FAC
https://thefaclibrary.herokuapp.com/
GNU General Public License v3.0
0 stars 0 forks source link

in tests: dbConnection.query is async #47

Open dangerdak opened 7 years ago

dangerdak commented 7 years ago

(me and Aisha discussed this)

Because .query is async, maybe each test should be inside the callback e.g.

dbConnection.query(sql, (err, res) => {
  if (err) return console.log(err);
  tape('SQL query case check', (t) => {
    getTopic('css', (err, res) => {
      const actual = res[0].topic;
      const expected = 'CSS';
      t.equals(actual, expected, 'getTopic object output topic should be "CSS" as the SQL query string is case insensitive');
      t.end();
    });
});
});

https://github.com/FAC-11/theLibrary/blob/master/tests/database.test.js#L8