test.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var assert = require('assert');
  2. var fs = require('fs');
  3. var networking = require('../modules/networking');
  4. var helpers = require('../modules/helpers');
  5. var config = require('../modules/config');
  6. var skins = require('../modules/skins');
  7. var cache = require("../modules/cache");
  8. var uuids = fs.readFileSync('test/uuids.txt').toString().split("\r\n");
  9. // Get a random UUID in order to prevent rate limiting
  10. var uuid = uuids[Math.floor((Math.random() * 200) + 1)];
  11. describe('Avatar Serving', function(){
  12. before(function() {
  13. cache.get_redis().flushall();
  14. });
  15. describe('UUID', function(){
  16. it("should be an invalid uuid", function(done){
  17. assert.equal(helpers.uuid_valid("invaliduuid"), false);
  18. done();
  19. });
  20. it("should be a valid uuid", function(done){
  21. assert.equal(helpers.uuid_valid("0098cb60fa8e427cb299793cbd302c9a"), true);
  22. done();
  23. });
  24. });
  25. describe('Avatar', function(){
  26. it("should be downloaded", function(done) {
  27. helpers.get_avatar(uuid, false, 180, function(err, status, image) {
  28. assert.equal(status, 2);
  29. done();
  30. });
  31. });
  32. it("should be local", function(done) {
  33. helpers.get_avatar(uuid, false, 180, function(err, status, image) {
  34. assert.equal(status, 1);
  35. done();
  36. });
  37. });
  38. });
  39. describe('Mojang Errors', function(){
  40. before(function() {
  41. cache.get_redis().flushall();
  42. });
  43. it("should be rate limited", function(done) {
  44. helpers.get_avatar(uuid, false, 180, function(err, status, image) {
  45. assert.equal(err, null);
  46. done();
  47. });
  48. });
  49. });
  50. });