server-tests.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. function equals(a, b) {
  2. return !!(EJSON.stringify(a) === EJSON.stringify(b));
  3. }
  4. FS.debug = true;
  5. Tinytest.add('cfs-access-point - server - test environment', function(test) {
  6. test.isTrue(typeof FS.Collection !== 'undefined', 'test environment not initialized FS.Collection');
  7. test.isTrue(typeof FS.HTTP !== 'undefined', 'test environment not initialized FS.HTTP');
  8. });
  9. Images = new FS.Collection('images', {
  10. stores: [
  11. new FS.Store.GridFS('gridList')
  12. ]
  13. });
  14. Images.allow({
  15. insert: function() {
  16. return true;
  17. },
  18. update: function() {
  19. return true;
  20. },
  21. remove: function() {
  22. return true;
  23. },
  24. download: function() {
  25. return true;
  26. }
  27. });
  28. Meteor.publish("img", function () {
  29. return Images.find();
  30. });
  31. FS.HTTP.publish(Images, function () {
  32. return Images.find();
  33. });
  34. Meteor.methods({
  35. addTestImage: function() {
  36. Images.remove({});
  37. var url = "http://cdn.morguefile.com/imageData/public/files/b/bboomerindenial/preview/fldr_2009_04_01/file3301238617907.jpg";
  38. var fsFile = Images.insert(url);
  39. return fsFile._id;
  40. }
  41. });
  42. //Test API:
  43. //test.isFalse(v, msg)
  44. //test.isTrue(v, msg)
  45. //test.equalactual, expected, message, not
  46. //test.length(obj, len)
  47. //test.include(s, v)
  48. //test.isNaN(v, msg)
  49. //test.isUndefined(v, msg)
  50. //test.isNotNull
  51. //test.isNull
  52. //test.throws(func)
  53. //test.instanceOf(obj, klass)
  54. //test.notEqual(actual, expected, message)
  55. //test.runId()
  56. //test.exception(exception)
  57. //test.expect_fail()
  58. //test.ok(doc)
  59. //test.fail(doc)
  60. //test.equal(a, b, msg)