deprecations-test.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. const nock = require('nock')
  2. const GitHub = require('../../')
  3. require('../mocha-node-setup')
  4. describe('deprecations', () => {
  5. let github
  6. beforeEach(() => {
  7. github = new GitHub({
  8. baseUrl: 'https://deprecations-test.com'
  9. })
  10. cy.stub(console, 'warn')
  11. })
  12. it('github.integrations.*', () => {
  13. nock('https://deprecations-test.com')
  14. .get('/app/installations')
  15. .reply(200, [])
  16. return github.integrations.getInstallations({})
  17. .then(() => {
  18. expect(console.warn.callCount).to.equal(1)
  19. })
  20. })
  21. it('deprecated followRedirects option', () => {
  22. GitHub({
  23. followRedirects: false
  24. })
  25. expect(console.warn.callCount).to.equal(1)
  26. })
  27. it('deprecated protocol, host, port, pathPrefix options', () => {
  28. GitHub({
  29. protocol: 'https',
  30. host: 'deprecations-test.com',
  31. port: 1234,
  32. pathPrefix: '/deprecations-test.com/'
  33. })
  34. expect(console.warn.callCount).to.equal(4)
  35. // it logs same messages only once (#871)
  36. GitHub({
  37. protocol: 'https',
  38. host: 'deprecations-test.com',
  39. port: 1234,
  40. pathPrefix: '/deprecations-test.com/'
  41. })
  42. expect(console.warn.callCount).to.equal(4)
  43. })
  44. it('deprecated Promise option', () => {
  45. GitHub({
  46. Promise: {}
  47. })
  48. expect(console.warn.callCount).to.equal(1)
  49. })
  50. it('deprecated ca option', () => {
  51. GitHub({
  52. baseUrl: 'https://api.github.com',
  53. ca: 'certificate123'
  54. })
  55. expect(console.warn.callCount).to.equal(1)
  56. })
  57. it('deprecated proxy option', () => {
  58. GitHub({
  59. baseUrl: 'https://api.github.com',
  60. proxy: 'http://localhost:1234'
  61. })
  62. expect(console.warn.callCount).to.equal(1)
  63. })
  64. it('deprecated family option', () => {
  65. GitHub({
  66. baseUrl: 'https://api.github.com',
  67. family: 6
  68. })
  69. expect(console.warn.callCount).to.equal(1)
  70. })
  71. it('deprecated rejectUnauthorized option', () => {
  72. GitHub({
  73. baseUrl: 'https://api.github.com',
  74. rejectUnauthorized: false
  75. })
  76. expect(console.warn.callCount).to.equal(1)
  77. })
  78. it('deprecated client.activity.getEventsForRepoIssues()', () => {
  79. nock('https://deprecations-test.com')
  80. .get('/repos/foo/bar/issues/events')
  81. .reply(200, [])
  82. return github.activity.getEventsForRepoIssues({
  83. owner: 'foo',
  84. repo: 'bar'
  85. })
  86. .then(() => {
  87. expect(console.warn.callCount).to.equal(1)
  88. })
  89. })
  90. it('deprecated sha parameter for client.gitdata.getCommit({sha})', () => {
  91. nock('https://deprecations-test.com')
  92. .get('/repos/foo/bar/git/commits/sha123')
  93. .reply(200, {})
  94. return github.gitdata.getCommit({
  95. owner: 'foo',
  96. repo: 'bar',
  97. sha: 'sha123'
  98. })
  99. .then(() => {
  100. expect(console.warn.callCount).to.equal(1)
  101. })
  102. })
  103. it('deprecated authentication type "integration"', () => {
  104. nock('https://deprecations-test.com')
  105. .get('/app/installations')
  106. .reply(200, [])
  107. github.authenticate({
  108. type: 'integration',
  109. token: 'foo'
  110. })
  111. return github.apps.getInstallations({})
  112. .then(() => {
  113. expect(console.warn.callCount).to.equal(1)
  114. })
  115. })
  116. it('deprecated response.meta', () => {
  117. nock('https://deprecations-test.com')
  118. .get('/orgs/myorg')
  119. .reply(200, {})
  120. return github.orgs.get({org: 'myorg'})
  121. .then(response => {
  122. expect(response.meta).to.deep.equal(response.headers)
  123. expect(console.warn.callCount).to.equal(1)
  124. })
  125. })
  126. })