Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove usage of deprecated buffer API #3596

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
})
})