|
1 |
| -const expect = require("expect.js"); |
2 |
| -const cloudinary = require("../cloudinary.js"); |
3 |
| -const createTestConfig = require('./testUtils/createTestConfig'); |
| 1 | +const cloudinary = require("../../cloudinary.js"); |
| 2 | +const createTestConfig = require('../testUtils/createTestConfig'); |
4 | 3 |
|
5 | 4 | describe("cloudinary", function () {
|
6 | 5 | beforeEach(function () {
|
@@ -793,92 +792,4 @@ describe("cloudinary", function () {
|
793 | 792 | result = cloudinary.utils.url("sample.jpg", options);
|
794 | 793 | expect(result).to.eql('http://res.cloudinary.com/test123/image/upload/s--v2fTPYTu--/sample.jpg');
|
795 | 794 | });
|
796 |
| - describe("getUserAgent", function () { |
797 |
| - var platform = ""; |
798 |
| - before(function () { |
799 |
| - platform = cloudinary.utils.userPlatform; |
800 |
| - cloudinary.utils.userPlatform = ""; |
801 |
| - }); |
802 |
| - after(function () { |
803 |
| - cloudinary.utils.userPlatform = platform; |
804 |
| - }); |
805 |
| - it("should add a user platform to USER_AGENT", function () { |
806 |
| - cloudinary.utils.userPlatform = "Spec/1.0 (Test)"; |
807 |
| - expect(cloudinary.utils.getUserAgent()).to.match(/Spec\/1.0 \(Test\) CloudinaryNodeJS\/[\d.]+/); |
808 |
| - }); |
809 |
| - }); |
810 |
| - describe("config", function () { |
811 |
| - let cloudinaryUrlBackup; |
812 |
| - let accountUrlBackup; |
813 |
| - before(function () { |
814 |
| - cloudinaryUrlBackup = process.env.CLOUDINARY_URL; |
815 |
| - accountUrlBackup = process.env.CLOUDINARY_ACCOUNT_URL; |
816 |
| - }); |
817 |
| - describe("CLOUDINARY_URL", function () { |
818 |
| - after(function () { |
819 |
| - process.env.CLOUDINARY_URL = cloudinaryUrlBackup || ''; |
820 |
| - cloudinary.config(true); |
821 |
| - }); |
822 |
| - it("should allow nested values in CLOUDINARY_URL", function () { |
823 |
| - process.env.CLOUDINARY_URL = "cloudinary://key:secret@test123?foo[bar]=value"; |
824 |
| - cloudinary.config(true); |
825 |
| - const foo = cloudinary.config().foo; |
826 |
| - expect(foo && foo.bar).to.eql('value'); |
827 |
| - }); |
828 |
| - it("should load a properly formatted CLOUDINARY_URL", function () { |
829 |
| - process.env.CLOUDINARY_URL = "cloudinary://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test"; |
830 |
| - cloudinary.config(true); |
831 |
| - }); |
832 |
| - it("should not be sensitive to case in CLOUDINARY_URL's protocol", function () { |
833 |
| - process.env.CLOUDINARY_URL = "CLouDiNaRY://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test"; |
834 |
| - cloudinary.config(true); |
835 |
| - }); |
836 |
| - it("should throw error when CLOUDINARY_URL doesn't start with 'cloudinary://'", function () { |
837 |
| - process.env.CLOUDINARY_URL = "https://123456789012345:ALKJdjklLJAjhkKJ45hBK92baj3@test?cloudinary=foo"; |
838 |
| - try { |
839 |
| - cloudinary.config(true); |
840 |
| - expect().fail(); |
841 |
| - } catch (err) { |
842 |
| - expect(err.message).to.eql("Invalid CLOUDINARY_URL protocol. URL should begin with 'cloudinary://'"); |
843 |
| - } |
844 |
| - }); |
845 |
| - it("should not throw an error when CLOUDINARY_URL environment variable is missing", function () { |
846 |
| - delete process.env.CLOUDINARY_URL; |
847 |
| - cloudinary.config(true); |
848 |
| - }); |
849 |
| - }); |
850 |
| - describe("CLOUDINARY_ACCOUNT_URL", function () { |
851 |
| - after(function () { |
852 |
| - process.env.CLOUDINARY_ACCOUNT_URL = accountUrlBackup || ''; |
853 |
| - cloudinary.config(true); |
854 |
| - }); |
855 |
| - it("should allow nested values in CLOUDINARY_ACCOUNT_URL", function () { |
856 |
| - process.env.CLOUDINARY_ACCOUNT_URL = "account://key:secret@test123?foo[bar]=value"; |
857 |
| - cloudinary.config(true); |
858 |
| - const foo = cloudinary.config().foo; |
859 |
| - expect(foo && foo.bar).to.eql('value'); |
860 |
| - }); |
861 |
| - it("should load a properly formatted CLOUDINARY_ACCOUNT_URL", function () { |
862 |
| - process.env.CLOUDINARY_ACCOUNT_URL = "account://635412789012345:ALKJdjklLJAjhkKJ45hBK92tam2@test1"; |
863 |
| - cloudinary.config(true); |
864 |
| - }); |
865 |
| - it("should not be sensitive to case in CLOUDINARY_ACCOUNT_URL's protocol", function () { |
866 |
| - process.env.CLOUDINARY_ACCOUNT_URL = "aCCouNT://635283989012345:ALKGssklLJAjhkKJ45hBK92tas5@test1"; |
867 |
| - cloudinary.config(true); |
868 |
| - }); |
869 |
| - it("should throw error when CLOUDINARY_ACCOUNT_URL doesn't start with 'account://'", function () { |
870 |
| - process.env.CLOUDINARY_ACCOUNT_URL = "https://635283989012345:ALKGssklLJAjhkKJ45hBK92tas5@test1?account=foo"; |
871 |
| - try { |
872 |
| - cloudinary.config(true); |
873 |
| - expect().fail(); |
874 |
| - } catch (err) { |
875 |
| - expect(err.message).to.eql("Invalid CLOUDINARY_ACCOUNT_URL protocol. URL should begin with 'account://'"); |
876 |
| - } |
877 |
| - }); |
878 |
| - it("should not throw an error when CLOUDINARY_ACCOUNT_URL environment variable is missing", function () { |
879 |
| - delete process.env.CLOUDINARY_ACCOUNT_URL; |
880 |
| - cloudinary.config(true); |
881 |
| - }); |
882 |
| - }); |
883 |
| - }); |
884 | 795 | });
|
0 commit comments