From d729972251342d4d70cb6a23e0ffbc4b989733c8 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Thu, 7 Jul 2022 00:14:10 -0300 Subject: [PATCH] chore(tests): check node version before running decipher tests --- test/browser/main.test.js | 21 ++++++++++++--------- test/node/main.test.js | 21 ++++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/test/browser/main.test.js b/test/browser/main.test.js index e518fe5b..236549dc 100644 --- a/test/browser/main.test.js +++ b/test/browser/main.test.js @@ -92,17 +92,20 @@ describe('YouTube.js Tests', () => { */ }); - describe('Deciphers', () => { - it('Should decipher signature', () => { - const result = Signature.fromSourceCode(Constants.DECIPHERS.SIG.ALGORITHM).decipher(Constants.DECIPHERS.SIG.ORIGINAL_URL); - expect(result).toEqual(Constants.DECIPHERS.SIG.DECIPHERED_URL); - }); + // Run decipher tests only on newer versions of node since we're requiring them directly. + if (process.version.match(/^v(\d+\.\d+)/)[1] > 12) { + describe('Deciphers', () => { + it('Should decipher signature', () => { + const result = Signature.fromSourceCode(Constants.DECIPHERS.SIG.ALGORITHM).decipher(Constants.DECIPHERS.SIG.ORIGINAL_URL); + expect(result).toEqual(Constants.DECIPHERS.SIG.DECIPHERED_URL); + }); - it('Should decipher ntoken', () => { - const result = NToken.fromSourceCode(Constants.DECIPHERS.N.ALGORITHM).transform(Constants.DECIPHERS.N.ORIGINAL_TOKEN); - expect(result).toEqual(Constants.DECIPHERS.N.DECIPHERED_TOKEN); + it('Should decipher ntoken', () => { + const result = NToken.fromSourceCode(Constants.DECIPHERS.N.ALGORITHM).transform(Constants.DECIPHERS.N.ORIGINAL_TOKEN); + expect(result).toEqual(Constants.DECIPHERS.N.DECIPHERED_TOKEN); + }); }); - }); + } }); function download(id, session) { diff --git a/test/node/main.test.js b/test/node/main.test.js index 80c9346b..3218ad19 100644 --- a/test/node/main.test.js +++ b/test/node/main.test.js @@ -82,17 +82,20 @@ describe('YouTube.js Tests', () => { }, 30000); }); - describe('Deciphers', () => { - it('Should decipher signature', () => { - const result = Signature.fromSourceCode(Constants.DECIPHERS.SIG.ALGORITHM).decipher(Constants.DECIPHERS.SIG.ORIGINAL_URL); - expect(result).toEqual(Constants.DECIPHERS.SIG.DECIPHERED_URL); - }); + // Run decipher tests only on newer versions of node since we're requiring them directly. + if (process.version.match(/^v(\d+\.\d+)/)[1] > 12) { + describe('Deciphers', () => { + it('Should decipher signature', () => { + const result = Signature.fromSourceCode(Constants.DECIPHERS.SIG.ALGORITHM).decipher(Constants.DECIPHERS.SIG.ORIGINAL_URL); + expect(result).toEqual(Constants.DECIPHERS.SIG.DECIPHERED_URL); + }); - it('Should decipher ntoken', () => { - const result = NToken.fromSourceCode(Constants.DECIPHERS.N.ALGORITHM).transform(Constants.DECIPHERS.N.ORIGINAL_TOKEN); - expect(result).toEqual(Constants.DECIPHERS.N.DECIPHERED_TOKEN); + it('Should decipher ntoken', () => { + const result = NToken.fromSourceCode(Constants.DECIPHERS.N.ALGORITHM).transform(Constants.DECIPHERS.N.ORIGINAL_TOKEN); + expect(result).toEqual(Constants.DECIPHERS.N.DECIPHERED_TOKEN); + }); }); - }); + } }); function download(id, session) {