Skip to content

Commit 5aaf7d5

Browse files
authored
Merge pull request #6 from slidoapp/fix_deprecated_tests_methods
2 parents 0443474 + 7f1496b commit 5aaf7d5

25 files changed

Lines changed: 130 additions & 130 deletions

test/e2e/toCanvas.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ test('toCanvas - no promise available', function (t) {
1616
}
1717
const canvasEl = createCanvas(200, 200)
1818

19-
t.throw(function () { QRCode.toCanvas() },
19+
t.throws(function () { QRCode.toCanvas() },
2020
'Should throw if no arguments are provided')
2121

22-
t.throw(function () { QRCode.toCanvas('some text') },
22+
t.throws(function () { QRCode.toCanvas('some text') },
2323
'Should throw if a callback is not provided')
2424

25-
t.throw(function () { QRCode.toCanvas(canvasEl, 'some text') },
25+
t.throws(function () { QRCode.toCanvas(canvasEl, 'some text') },
2626
'Should throw if a callback is not provided')
2727

28-
t.throw(function () { QRCode.toCanvas(canvasEl, 'some text', {}) },
28+
t.throws(function () { QRCode.toCanvas(canvasEl, 'some text', {}) },
2929
'Should throw if callback is not a function')
3030

3131
t.end()
@@ -46,7 +46,7 @@ test('toCanvas', function (t) {
4646

4747
t.plan(7)
4848

49-
t.throw(function () { QRCode.toCanvas() },
49+
t.throws(function () { QRCode.toCanvas() },
5050
'Should throw if no arguments are provided')
5151

5252
QRCode.toCanvas('some text', function (err, canvasEl) {

test/e2e/toDataURL.test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ const Helpers = require('test/helpers')
77
test('toDataURL - no promise available', function (t) {
88
Helpers.removeNativePromise()
99

10-
t.throw(function () { QRCode.toDataURL() },
10+
t.throws(function () { QRCode.toDataURL() },
1111
'Should throw if no arguments are provided')
1212

13-
t.throw(function () { QRCode.toDataURL(function () {}) },
13+
t.throws(function () { QRCode.toDataURL(function () {}) },
1414
'Should throw if text is not provided')
1515

16-
t.throw(function () { QRCode.toDataURL('some text') },
16+
t.throws(function () { QRCode.toDataURL('some text') },
1717
'Should throw if a callback is not provided')
1818

19-
t.throw(function () { QRCode.toDataURL('some text', {}) },
19+
t.throws(function () { QRCode.toDataURL('some text', {}) },
2020
'Should throw if a callback is not a function')
2121

22-
t.throw(function () { QRCodeBrowser.toDataURL() },
22+
t.throws(function () { QRCodeBrowser.toDataURL() },
2323
'Should throw if no arguments are provided (browser)')
2424

25-
t.throw(function () { QRCodeBrowser.toDataURL(function () {}) },
25+
t.throws(function () { QRCodeBrowser.toDataURL(function () {}) },
2626
'Should throw if text is not provided (browser)')
2727

28-
t.throw(function () { QRCodeBrowser.toDataURL('some text') },
28+
t.throws(function () { QRCodeBrowser.toDataURL('some text') },
2929
'Should throw if a callback is not provided (browser)')
3030

31-
t.throw(function () { QRCodeBrowser.toDataURL('some text', {}) },
31+
t.throws(function () { QRCodeBrowser.toDataURL('some text', {}) },
3232
'Should throw if a callback is not a function (browser)')
3333

3434
t.end()
@@ -57,15 +57,15 @@ test('toDataURL - image/png', function (t) {
5757

5858
t.plan(8)
5959

60-
t.throw(function () { QRCode.toDataURL() },
60+
t.throws(function () { QRCode.toDataURL() },
6161
'Should throw if no arguments are provided')
6262

6363
QRCode.toDataURL('i am a pony!', {
6464
errorCorrectionLevel: 'L',
6565
type: 'image/png'
6666
}, function (err, url) {
6767
t.ok(!err, 'there should be no error ' + err)
68-
t.equals(url, expectedDataURL,
68+
t.equal(url, expectedDataURL,
6969
'url should match expected value for error correction L')
7070
})
7171

@@ -78,14 +78,14 @@ test('toDataURL - image/png', function (t) {
7878
t.notOk(url, 'url should be null')
7979
})
8080

81-
t.equals(typeof QRCode.toDataURL('i am a pony!').then, 'function',
81+
t.equal(typeof QRCode.toDataURL('i am a pony!').then, 'function',
8282
'Should return a promise')
8383

8484
QRCode.toDataURL('i am a pony!', {
8585
errorCorrectionLevel: 'L',
8686
type: 'image/png'
8787
}).then(function (url) {
88-
t.equals(url, expectedDataURL,
88+
t.equal(url, expectedDataURL,
8989
'url should match expected value for error correction L (promise)')
9090
})
9191

@@ -120,10 +120,10 @@ test('Canvas toDataURL - image/png', function (t) {
120120

121121
t.plan(11)
122122

123-
t.throw(function () { QRCodeBrowser.toDataURL() },
123+
t.throws(function () { QRCodeBrowser.toDataURL() },
124124
'Should throw if no arguments are provided')
125125

126-
t.throw(function () { QRCodeBrowser.toDataURL(function () {}) },
126+
t.throws(function () { QRCodeBrowser.toDataURL(function () {}) },
127127
'Should throw if text is not provided')
128128

129129
const canvas = createCanvas(200, 200)
@@ -132,7 +132,7 @@ test('Canvas toDataURL - image/png', function (t) {
132132
type: 'image/png'
133133
}, function (err, url) {
134134
t.ok(!err, 'there should be no error ' + err)
135-
t.equals(url, expectedDataURL, 'url generated should match expected value')
135+
t.equal(url, expectedDataURL, 'url generated should match expected value')
136136
})
137137

138138
QRCodeBrowser.toDataURL(canvas, 'i am a pony!', {
@@ -148,7 +148,7 @@ test('Canvas toDataURL - image/png', function (t) {
148148
errorCorrectionLevel: 'H',
149149
type: 'image/png'
150150
}).then(function (url) {
151-
t.equals(url, expectedDataURL, 'url generated should match expected value (promise)')
151+
t.equal(url, expectedDataURL, 'url generated should match expected value (promise)')
152152
})
153153

154154
QRCodeBrowser.toDataURL(canvas, 'i am a pony!', {
@@ -173,13 +173,13 @@ test('Canvas toDataURL - image/png', function (t) {
173173
type: 'image/png'
174174
}, function (err, url) {
175175
t.ok(!err, 'there should be no error ' + err)
176-
t.equals(url, expectedDataURL, 'url generated should match expected value')
176+
t.equal(url, expectedDataURL, 'url generated should match expected value')
177177
})
178178

179179
QRCodeBrowser.toDataURL('i am a pony!', {
180180
errorCorrectionLevel: 'H',
181181
type: 'image/png'
182182
}).then(function (url) {
183-
t.equals(url, expectedDataURL, 'url generated should match expected value (promise)')
183+
t.equal(url, expectedDataURL, 'url generated should match expected value (promise)')
184184
})
185185
})

test/e2e/toFile.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ test('toFile - no promise available', function (t) {
1111
Helpers.removeNativePromise()
1212
const fileName = path.join(os.tmpdir(), 'qrimage.png')
1313

14-
t.throw(function () { QRCode.toFile(fileName, 'some text') },
14+
t.throws(function () { QRCode.toFile(fileName, 'some text') },
1515
'Should throw if a callback is not provided')
1616

17-
t.throw(function () { QRCode.toFile(fileName, 'some text', {}) },
17+
t.throws(function () { QRCode.toFile(fileName, 'some text', {}) },
1818
'Should throw if a callback is not a function')
1919

2020
t.end()
@@ -25,10 +25,10 @@ test('toFile - no promise available', function (t) {
2525
test('toFile', function (t) {
2626
const fileName = path.join(os.tmpdir(), 'qrimage.png')
2727

28-
t.throw(function () { QRCode.toFile('some text', function () {}) },
28+
t.throws(function () { QRCode.toFile('some text', function () {}) },
2929
'Should throw if path is not provided')
3030

31-
t.throw(function () { QRCode.toFile(fileName) },
31+
t.throws(function () { QRCode.toFile(fileName) },
3232
'Should throw if text is not provided')
3333

3434
t.equal(typeof QRCode.toFile(fileName, 'some text').then, 'function',

test/e2e/toFileStream.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const QRCode = require('lib')
44
const StreamMock = require('../mocks/writable-stream')
55

66
test('toFileStream png', function (t) {
7-
t.throw(function () { QRCode.toFileStream('some text') },
7+
t.throws(function () { QRCode.toFileStream('some text') },
88
'Should throw if stream is not provided')
99

10-
t.throw(function () { QRCode.toFileStream(new StreamMock()) },
10+
t.throws(function () { QRCode.toFileStream(new StreamMock()) },
1111
'Should throw if text is not provided')
1212

1313
const fstream = new StreamMock()

test/e2e/toString.test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ const Helpers = require('test/helpers')
88
test('toString - no promise available', function (t) {
99
Helpers.removeNativePromise()
1010

11-
t.throw(function () { QRCode.toString() },
11+
t.throws(function () { QRCode.toString() },
1212
'Should throw if text is not provided')
1313

14-
t.throw(function () { QRCode.toString('some text') },
14+
t.throws(function () { QRCode.toString('some text') },
1515
'Should throw if a callback is not provided')
1616

17-
t.throw(function () { QRCode.toString('some text', {}) },
17+
t.throws(function () { QRCode.toString('some text', {}) },
1818
'Should throw if a callback is not a function')
1919

20-
t.throw(function () { QRCode.toString() },
20+
t.throws(function () { QRCode.toString() },
2121
'Should throw if text is not provided (browser)')
2222

23-
t.throw(function () { browser.toString('some text') },
23+
t.throws(function () { browser.toString('some text') },
2424
'Should throw if a callback is not provided (browser)')
2525

26-
t.throw(function () { browser.toString('some text', {}) },
26+
t.throws(function () { browser.toString('some text', {}) },
2727
'Should throw if a callback is not a function (browser)')
2828

2929
t.end()
@@ -34,43 +34,43 @@ test('toString - no promise available', function (t) {
3434
test('toString', function (t) {
3535
t.plan(5)
3636

37-
t.throw(function () { QRCode.toString() },
37+
t.throws(function () { QRCode.toString() },
3838
'Should throw if text is not provided')
3939

4040
QRCode.toString('some text', function (err, str) {
4141
t.ok(!err, 'There should be no error')
42-
t.equals(typeof str, 'string',
42+
t.equal(typeof str, 'string',
4343
'Should return a string')
4444
})
4545

46-
t.equals(typeof QRCode.toString('some text').then, 'function',
46+
t.equal(typeof QRCode.toString('some text').then, 'function',
4747
'Should return a promise')
4848

4949
QRCode.toString('some text', { errorCorrectionLevel: 'L' })
5050
.then(function (str) {
51-
t.equals(typeof str, 'string',
51+
t.equal(typeof str, 'string',
5252
'Should return a string')
5353
})
5454
})
5555

5656
test('toString (browser)', function (t) {
5757
t.plan(5)
5858

59-
t.throw(function () { browser.toString() },
59+
t.throws(function () { browser.toString() },
6060
'Should throw if text is not provided')
6161

6262
browser.toString('some text', function (err, str) {
6363
t.ok(!err, 'There should be no error (browser)')
64-
t.equals(typeof str, 'string',
64+
t.equal(typeof str, 'string',
6565
'Should return a string (browser)')
6666
})
6767

68-
t.equals(typeof browser.toString('some text').then, 'function',
68+
t.equal(typeof browser.toString('some text').then, 'function',
6969
'Should return a promise')
7070

7171
browser.toString('some text', { errorCorrectionLevel: 'L' })
7272
.then(function (str) {
73-
t.equals(typeof str, 'string',
73+
t.equal(typeof str, 'string',
7474
'Should return a string')
7575
})
7676
})

test/unit/core/alignment-pattern.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test('Alignment pattern - Row/Col coords', function (t) {
5555

5656
for (let i = 1; i <= 40; i++) {
5757
const pos = pattern.getRowColCoords(i)
58-
t.deepEqual(pos, EXPECTED_POSITION_TABLE[i - 1], 'Should return correct coords')
58+
t.same(pos, EXPECTED_POSITION_TABLE[i - 1], 'Should return correct coords')
5959
}
6060
})
6161

@@ -70,7 +70,7 @@ test('Alignment pattern - Positions', function (t) {
7070
// For each coord value check if it's present in the expected coords table
7171
pos.forEach(function (position) {
7272
position.forEach(function (coord) {
73-
t.notEqual(expectedPos.indexOf(coord), -1, 'Should return valid coord value')
73+
t.not(expectedPos.indexOf(coord), -1, 'Should return valid coord value')
7474
})
7575
})
7676
}

test/unit/core/alphanumeric-data.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test('Alphanumeric Data', function (t) {
3434

3535
const bitBuffer = new BitBuffer()
3636
alphanumericData.write(bitBuffer)
37-
t.deepEqual(bitBuffer.buffer, data.dataBit, 'Should write correct data to buffer')
37+
t.same(bitBuffer.buffer, data.dataBit, 'Should write correct data to buffer')
3838
})
3939

4040
t.end()

test/unit/core/bit-buffer.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('Bit Buffer', function (t) {
1313
t.equal(bitBuffer.getLengthInBits(), 8, 'Length should be 8')
1414

1515
for (let i = 0; i < 8; i++) {
16-
t.deepEqual(bitBuffer.get(i), expectedDataBits[i], 'Should return correct bit value')
16+
t.same(bitBuffer.get(i), expectedDataBits[i], 'Should return correct bit value')
1717
}
1818

1919
t.end()

test/unit/core/bit-matrix.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const test = require('tap').test
22
const BitMatrix = require('core/bit-matrix')
33

44
test('Bit Matrix', function (t) {
5-
t.throw(function () { BitMatrix(0) }, 'Should throw if size is 0')
6-
t.throw(function () { BitMatrix(-1) }, 'Should throw if size less than 0')
5+
t.throws(function () { BitMatrix(0) }, 'Should throw if size is 0')
6+
t.throws(function () { BitMatrix(-1) }, 'Should throw if size less than 0')
77

88
const bm = new BitMatrix(2)
99

test/unit/core/byte-data.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('Byte Data: String Input', function (t) {
1717

1818
const bitBuffer = new BitBuffer()
1919
byteData.write(bitBuffer)
20-
t.deepEqual(bitBuffer.buffer, textByte, 'Should write correct data to buffer')
20+
t.same(bitBuffer.buffer, textByte, 'Should write correct data to buffer')
2121

2222
const byteDataUtf8 = new ByteData(utf8Text)
2323
t.equal(byteDataUtf8.getLength(), 12, 'Should return correct length for utf8 chars')
@@ -34,7 +34,7 @@ test('Byte Data: Byte Input', function (t) {
3434

3535
const bitBuffer = new BitBuffer()
3636
byteData.write(bitBuffer)
37-
t.deepEqual(bitBuffer.buffer, bytes, 'Should write correct data to buffer')
37+
t.same(bitBuffer.buffer, bytes, 'Should write correct data to buffer')
3838

3939
t.end()
4040
})

0 commit comments

Comments
 (0)