-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: run address-codec tests in the browser (#2466)
Update tests to use jasmine compatible functions. This means changing `test` to `it`, `toStrictEqual` to `toEqual` (which is still strict), `toThrowError` to `toError`, and updating the param for toError to pass an `Error` object. Remove the need to specify --single-run.
- Loading branch information
Showing
15 changed files
with
213 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = function (config) { | ||
config.set({ | ||
plugins: ["karma-webpack", "karma-jasmine", "karma-chrome-launcher"], | ||
|
||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: ["jasmine"], | ||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
// Use webpack to bundle our test files | ||
"test/**/*.test.ts": ["webpack"], | ||
}, | ||
|
||
browsers: ["ChromeHeadless"], | ||
// runs only one browser at a time | ||
concurrency: 1, | ||
// CI mode | ||
singleRun: true, | ||
client: { | ||
jasmine: { | ||
// ensures that tests are run in order instead of a random order | ||
random: false, | ||
}, | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const baseKarmaConfig = require('../../karma.config') | ||
const webpackConfig = require('./test/webpack.config') | ||
delete webpackConfig.entry | ||
|
||
module.exports = function (config) { | ||
baseKarmaConfig(config) | ||
|
||
config.set({ | ||
base: '', | ||
webpack: webpackConfig, | ||
|
||
// list of files / patterns to load in the browser | ||
files: ['test/**/*.test.ts'], | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import { seqEqual, concatArgs } from '../src/utils' | ||
|
||
test('two sequences are equal', () => { | ||
it('two sequences are equal', () => { | ||
expect(seqEqual([1, 2, 3], [1, 2, 3])).toBe(true) | ||
}) | ||
|
||
test('elements must be in the same order', () => { | ||
it('elements must be in the same order', () => { | ||
expect(seqEqual([3, 2, 1], [1, 2, 3])).toBe(false) | ||
}) | ||
|
||
test('sequences do not need to be the same type', () => { | ||
it('sequences do not need to be the same type', () => { | ||
expect(seqEqual(Buffer.from([1, 2, 3]), [1, 2, 3])).toBe(true) | ||
expect(seqEqual(Buffer.from([1, 2, 3]), new Uint8Array([1, 2, 3]))).toBe(true) | ||
}) | ||
|
||
test('sequences with a single element', () => { | ||
it('sequences with a single element', () => { | ||
expect(seqEqual(Buffer.from([1]), [1])).toBe(true) | ||
expect(seqEqual(Buffer.from([1]), new Uint8Array([1]))).toBe(true) | ||
}) | ||
|
||
test('empty sequences', () => { | ||
it('empty sequences', () => { | ||
expect(seqEqual(Buffer.from([]), [])).toBe(true) | ||
expect(seqEqual(Buffer.from([]), new Uint8Array([]))).toBe(true) | ||
}) | ||
|
||
test('plain numbers are concatenated', () => { | ||
expect(concatArgs(10, 20, 30, 40)).toStrictEqual([10, 20, 30, 40]) | ||
it('plain numbers are concatenated', () => { | ||
expect(concatArgs(10, 20, 30, 40)).toEqual([10, 20, 30, 40]) | ||
}) | ||
|
||
test('a variety of values are concatenated', () => { | ||
it('a variety of values are concatenated', () => { | ||
expect( | ||
concatArgs(1, [2, 3], Buffer.from([4, 5]), new Uint8Array([6, 7])), | ||
).toStrictEqual([1, 2, 3, 4, 5, 6, 7]) | ||
).toEqual([1, 2, 3, 4, 5, 6, 7]) | ||
}) | ||
|
||
test('a single value is returned as an array', () => { | ||
expect(concatArgs(Buffer.from([7]))).toStrictEqual([7]) | ||
it('a single value is returned as an array', () => { | ||
expect(concatArgs(Buffer.from([7]))).toEqual([7]) | ||
}) | ||
|
||
test('no arguments returns an empty array', () => { | ||
expect(concatArgs()).toStrictEqual([]) | ||
it('no arguments returns an empty array', () => { | ||
expect(concatArgs()).toEqual([]) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
const { merge } = require('webpack-merge') | ||
const { webpackForTest } = require('../../../weback.test.config') | ||
const { getDefaultConfiguration } = require('../../../webpack.config') | ||
|
||
module.exports = merge( | ||
getDefaultConfiguration(), | ||
webpackForTest('./test/index.ts', __dirname), | ||
) |
Oops, something went wrong.