|
1 | 1 | const sinon = require('sinon'); |
| 2 | +const formatDate = require("date-fns").format; |
| 3 | +const subDate = require("date-fns").sub; |
2 | 4 | const ClientRequest = require('_http_client').ClientRequest; |
3 | 5 | const Q = require('q'); |
4 | 6 | const cloudinary = require("../../../../cloudinary"); |
@@ -696,7 +698,20 @@ describe("api", function () { |
696 | 698 | it("should support the usage API call", function () { |
697 | 699 | this.timeout(TIMEOUT.MEDIUM); |
698 | 700 | return cloudinary.v2.api.usage() |
699 | | - .then(usage => expect(usage.last_update).not.to.eql(null)); |
| 701 | + .then(usage => { |
| 702 | + expect(usage).to.be.an("object"); |
| 703 | + expect(usage).to.have.keys("plan", "last_updated", "transformations", "objects", "bandwidth", "storage", "requests", "resources", "derived_resources", "media_limits"); |
| 704 | + }); |
| 705 | + }); |
| 706 | + it("should return usage values for a specific date", function () { |
| 707 | + const yesterday = formatDate(subDate(new Date(), { days: 1 }), "dd-MM-yyyy"); |
| 708 | + return cloudinary.v2.api.usage({ date: yesterday }) |
| 709 | + .then(usage => { |
| 710 | + expect(usage).to.be.an("object"); |
| 711 | + expect(usage).to.have.keys("plan", "last_updated", "transformations", "objects", "bandwidth", "storage", "requests", "resources", "derived_resources", "media_limits"); |
| 712 | + expect(usage.bandwidth).to.be.an("object"); |
| 713 | + expect(usage.bandwidth).to.not.have.keys("limit", "used_percent"); |
| 714 | + }); |
700 | 715 | }); |
701 | 716 | describe("delete_all_resources", function () { |
702 | 717 | callReusableTest("accepts next_cursor", cloudinary.v2.api.delete_all_resources); |
|
0 commit comments