-
Notifications
You must be signed in to change notification settings - Fork 938
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate from nodeunit to jest (#640)
- Loading branch information
Showing
30 changed files
with
3,318 additions
and
2,253 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
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.