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) {