Skip to content

Commit

Permalink
chore(test): remove usage of deprecated buffer API (#3596)
Browse files Browse the repository at this point in the history
  • Loading branch information
devoto13 authored Dec 21, 2020
1 parent 35a5842 commit fb76ed6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test/unit/preprocessor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('preprocessor', () => {
let mockFs
let emitterSetting
// mimic first few bytes of a pdf file
const binarydata = new Buffer([0x25, 0x50, 0x44, 0x66, 0x46, 0x00]) // eslint-disable-line node/no-deprecated-api
const binarydata = Buffer.from([0x25, 0x50, 0x44, 0x66, 0x46, 0x00])

beforeEach(() => {
mockFs = mocks.fs.create({
Expand Down
24 changes: 12 additions & 12 deletions test/unit/runner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ describe('runner', () => {
const EXIT = constant.EXIT_CODE

it('should return 0 exit code if present in the buffer', () => {
const result = m.parseExitCode(new Buffer(`something\nfake${EXIT}10`)) // eslint-disable-line node/no-deprecated-api
const result = m.parseExitCode(Buffer.from(`something\nfake${EXIT}10`))
expect(result.exitCode).to.equal(0)
})

it('should remove the exit code part of the returned buffer', () => {
const buffer = new Buffer(`some${EXIT}01`) // eslint-disable-line node/no-deprecated-api
const buffer = Buffer.from(`some${EXIT}01`)
const result = m.parseExitCode(buffer)

expect(buffer.toString()).to.equal(`some${EXIT}01`)
Expand All @@ -28,7 +28,7 @@ describe('runner', () => {

it('should not touch buffer without exit code and return default', () => {
const msg = 'some nice \n messgae {}'
const buffer = new Buffer(msg) // eslint-disable-line node/no-deprecated-api
const buffer = Buffer.from(msg)
const result = m.parseExitCode(buffer, 10)

expect(result.buffer.toString()).to.equal(msg)
Expand All @@ -53,21 +53,21 @@ describe('runner', () => {
})

it('should parse any single digit exit code', () => {
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`)).exitCode).to.equal(1) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}17`)).exitCode).to.equal(7) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}01`)).exitCode).to.equal(1)
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}17`)).exitCode).to.equal(7)
})

it('should return exit code 0 if failOnEmptyTestSuite is false and and non-empty int is 0', () => {
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`), undefined, false).exitCode).to.equal(0) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}01`), undefined, false).exitCode).to.equal(0)
})

it('should return exit code if failOnEmptyTestSuite is true', () => {
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}00`), undefined, true).exitCode).to.equal(0) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}01`), undefined, true).exitCode).to.equal(1) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}07`), undefined, true).exitCode).to.equal(7) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}10`), undefined, true).exitCode).to.equal(0) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}11`), undefined, true).exitCode).to.equal(1) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(new Buffer(`something\nfake${EXIT}17`), undefined, true).exitCode).to.equal(7) // eslint-disable-line node/no-deprecated-api
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}00`), undefined, true).exitCode).to.equal(0)
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}01`), undefined, true).exitCode).to.equal(1)
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}07`), undefined, true).exitCode).to.equal(7)
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}10`), undefined, true).exitCode).to.equal(0)
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}11`), undefined, true).exitCode).to.equal(1)
expect(m.parseExitCode(Buffer.from(`something\nfake${EXIT}17`), undefined, true).exitCode).to.equal(7)
})
})
})

0 comments on commit fb76ed6

Please sign in to comment.