-
Notifications
You must be signed in to change notification settings - Fork 938
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
chore: migrate from nodeunit to jest #640
Open
cesine
wants to merge
35
commits into
shutterstock:main
Choose a base branch
from
cesine:coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
e5f3528
chore: migrate from nodeunit to Jest
cesine a231955
test: migrate Legend and Scatterplot renderer tests to Jest
cesine ed1805a
test: Improve HoverDetail test coverage
cesine 17d7596
chore: Update Jest config for accurate coverage reporting
cesine a163d0e
baseline coverage
cesine 227ac0c
test: Migrate Rickshaw.Graph.Axis.Y test to Jest
cesine 7379291
test: Migrate Rickshaw.Graph.Axis.X test to Jest
cesine 85413f7
test: Migrate Rickshaw.Graph.Annotate test to Jest
cesine 38bff07
test: Migrate Rickshaw.Fixtures.Time test to Jest
cesine 83c98b8
test: Migrate Rickshaw.Fixtures.Time.Local test to Jest
cesine 83e96a3
before asking to refactor global state in beforeEach
cesine d4231ed
test: Migrate Rickshaw.Graph.RangeSlider test to Jest
cesine 7970a6b
test: Migrate Rickshaw.Graph.RangeSlider test to Jest
cesine c390782
test: Migrate Rickshaw.Graph.DragZoom test to Jest
cesine 06e71fe
test: Migrate Rickshaw.Graph.Renderer.Multi test to Jest
cesine 2a85df1
test: Migrate Rickshaw.Series.FixedDuration test to Jest
cesine 04f50b9
test: migrate Rickshaw.Graph tests to Jest
cesine ba9b4e3
test: migrate Rickshaw.Color.Palette tests to Jest
cesine 863b07c
test: migrate Rickshaw.Graph.RangeSlider.Preview tests to Jest
cesine d6e1078
test: Migrate Graph Renderer tests to Jest
cesine dce3641
test: Migrate Rickshaw core tests to Jest
cesine e70c472
test: Improve Rickshaw.Series fill methods test
cesine f1deeb5
remove coverage baseline
cesine 39ffe72
Merge branch 'main' into coverage
cesine e75a413
jest uses null coalescing which is not available in node 12
cesine 90424a1
add coverage expecations
cesine e16c721
chore: update jest coverage thresholds
cesine bb01012
more generated test cases
cesine baa626b
remove sinon
cesine 6a5a1f4
test: improve Highlight behavior test coverage
cesine 4f0d2fc
test: Add test suite for Rickshaw.Graph.Behavior.Series.Order
cesine f241019
test: Add test suite for Rickshaw.Graph.Renderer.LinePlot
cesine 7ecedb2
update coverage expectations
cesine 116a6a9
only report to coveralls on main
cesine c57e5ef
clean up jsdom
cesine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
moduleDirectories: ['node_modules'], | ||
testMatch: ['**/**/*.test.js'], | ||
collectCoverageFrom: [ | ||
'Rickshaw.*.js', | ||
'rickshaw.js', | ||
'!rickshaw.min.js', | ||
'!**/node_modules/**', | ||
], | ||
coverageThreshold: { | ||
global: { | ||
branches: 59, | ||
functions: 62, | ||
lines: 67, | ||
statements: 66, | ||
} | ||
}, | ||
setupFiles: ['./jest.setup.js'], | ||
transform: {}, | ||
testEnvironmentOptions: { | ||
url: 'http://localhost/' | ||
} | ||
}; |
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,4 @@ | ||
// Set up any global variables needed for testing | ||
global.d3 = require('d3'); | ||
|
||
// No need to extend expect here as we're not using custom matchers yet |
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,52 +1,57 @@ | ||
var Rickshaw = require('../rickshaw'); | ||
|
||
exports.load = function(test) { | ||
|
||
test.equal(typeof Rickshaw.Class, 'object', 'Rickshaw.Class is a function'); | ||
test.done(); | ||
}; | ||
|
||
exports.instantiation = function(test) { | ||
|
||
Rickshaw.namespace('Rickshaw.Sample.Class'); | ||
|
||
Rickshaw.Sample.Class = Rickshaw.Class.create({ | ||
name: 'sample', | ||
concat: function(suffix) { | ||
return [this.name, suffix].join(' '); | ||
} | ||
}); | ||
|
||
var sample = new Rickshaw.Sample.Class(); | ||
test.equal(sample.concat('polka'), 'sample polka'); | ||
|
||
Rickshaw.namespace('Rickshaw.Sample.Class.Prefix'); | ||
|
||
Rickshaw.Sample.Subclass = Rickshaw.Class.create( Rickshaw.Sample.Class, { | ||
name: 'sampler' | ||
}); | ||
|
||
var sampler = new Rickshaw.Sample.Subclass(); | ||
test.equal(sampler.concat('polka'), 'sampler polka'); | ||
|
||
test.done(); | ||
}; | ||
|
||
exports.array = function(test) { | ||
|
||
Rickshaw.namespace('Rickshaw.Sample.Array'); | ||
|
||
Rickshaw.Sample.Array = Rickshaw.Class.create(Array, { | ||
second: function() { | ||
return this[1]; | ||
} | ||
}); | ||
|
||
var array = new Rickshaw.Sample.Array(); | ||
array.push('red'); | ||
array.push('blue'); | ||
|
||
test.equal(array.second(), 'blue'); | ||
|
||
test.done(); | ||
}; | ||
const Rickshaw = require('../rickshaw'); | ||
|
||
describe('Rickshaw.Class', () => { | ||
test('should be defined as an object', () => { | ||
expect(typeof Rickshaw.Class).toBe('object'); | ||
}); | ||
|
||
describe('instantiation', () => { | ||
test('should create a basic class instance', () => { | ||
// Create fresh class definition for this test | ||
const TestClass = Rickshaw.Class.create({ | ||
name: 'sample', | ||
concat: function(suffix) { | ||
return [this.name, suffix].join(' '); | ||
} | ||
}); | ||
|
||
const sample = new TestClass(); | ||
expect(sample.concat('polka')).toBe('sample polka'); | ||
}); | ||
|
||
test('should create a subclass instance', () => { | ||
// Create fresh parent class for this test | ||
const ParentClass = Rickshaw.Class.create({ | ||
name: 'sample', | ||
concat: function(suffix) { | ||
return [this.name, suffix].join(' '); | ||
} | ||
}); | ||
|
||
// Create fresh subclass for this test | ||
const SubClass = Rickshaw.Class.create(ParentClass, { | ||
name: 'sampler' | ||
}); | ||
|
||
const sampler = new SubClass(); | ||
expect(sampler.concat('polka')).toBe('sampler polka'); | ||
}); | ||
}); | ||
|
||
describe('array inheritance', () => { | ||
test('should extend Array functionality', () => { | ||
// Create fresh array class for this test | ||
const TestArray = Rickshaw.Class.create(Array, { | ||
second: function() { | ||
return this[1]; | ||
} | ||
}); | ||
|
||
const array = new TestArray(); | ||
array.push('red'); | ||
array.push('blue'); | ||
|
||
expect(array.second()).toBe('blue'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest no longer supports node 12 https://jestjs.io/docs/upgrading-to-jest29
https://github.com/cesine/rickshaw/actions/runs/12040292801/job/33569879332