Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
ember-cli-custom-assertions-collection
Advanced tools
Changelog
[0.5.0] - 2015-09-29
datesEqual
Readme
Turns out it's impossible to effectively use Chai in QUnit. Chai throws exceptions on failed Chai assertions, which are tracked by QUnit, though with a poor message. But Chai is unable to report successful assertions to QUnit. If you compose a QUnit test entirely from Chai assertions, QUnit will fail due to no assertions.
This is really unfortunate because Chai has a decent assertions library, and QUnit's library is very basic and often not enough.
This Ember addon aims to provide missing assertions and many more.
Assertions themselves are properly unit-tested.
This addon is WIP and is being populated with assertions as they are needed.
Feel free to join. Find yourself doing clumsy stuff in tests? PR a custom assertion!
This addon depends on the following addons:
And plain npm packages:
If you find it not working due to something of the above missing, try installing that into your app. And file an issue here!
ember cli install ember-cli-custom-assertions-collection
.ember-cli-custom-assertions
.assert.isFalse(foo, 'foo should be false')
.isFalse( obj [, message] )
Checks if obj
is exactly false
.
assert.isFalse( false ) // pass
assert.isFalse( 1 === 2 ) // pass
assert.isFalse( null ) // fail
arrayContains( arr, value [, message])
Checks if array contains value
assert.arrayContains(['foo', 'bar'], 'bar') // pass
assert.arrayContains(['foo', 'bar'], 'quux') // fail
arraysSameMembers( arr1, arr2 [, message] )
Checks if both arrays have identical content, in any order.
Members are compared via ===
, so it's safe to compare Ember models: will not crash due to circular references like propEqual
does.
assert.arraysSameMembers( ['foo', 'bar'], ['bar', 'foo'] ) // pass
assert.arraysSameMembers( ['foo', 'bar'], ['bar', 'baz'] ) // fail
assert.arraysSameMembers( ['foo', 'bar'], ['bar'] ) // fail
arraysSameMembersOrdered( arr1, arr2 [, message] )
Checks if both arrays identical content, in identical order. Members are compared via ===
.
assert.arraysSameMembersOrdered( ['foo', 'bar'], ['foo', 'bar'] ) // pass
assert.arraysSameMembersOrdered( ['foo', 'bar'], ['bar', 'foo'] ) // fail
assert.arraysSameMembersOrdered( ['foo', 'bar'], ['bar', 'baz'] ) // fail
assert.arraysSameMembersOrdered( ['foo', 'bar'], ['bar'] ) // fail
numbersAlmostEqual( number1, number2 [, precision = 6] [, message] )
You know how 1 - 0.9 === 0.1
is false
in JS? That's because in JS float-point operations aren't precise.
Use this to compare them loosely:
assert.numbersAlmostEqual( 1 - 0.9, 1 ) // pass
assert.numbersAlmostEqual( 1 - 1/3, 2/3 ) // pass
assert.numbersAlmostEqual( 1, 0.00001 ) // fail
assert.numbersAlmostEqual( 1, 0.00001, precision: 4 ) // pass
This assertion uses a method suggested by MDN. Not sure whether it'll work correctly every time.
largerThan(arg1, arg2 [, message])
Compares the two arguments using >
, >=
, <
and <=
respectively.
assert.smallerThan( 1, 2 ) // pass
datesEqual(date1, date2 [, message])
So dates are objects and two distinct objects aren't equal even if they represent identical dates.
This assertion compares the two dates by converting them to unix timestamp integers and comparing those.
assert.datesEqual( new Date('2015-01-01'), new Date('2015-01-01') ) // pass
If this thing catches up, we could document it with YUIDOC.
All suggestion are welcome in issues and in Ember Slack community.
Oh, and don't forget to star the addon on Github! :beers"
Created in Firecracker.
FAQs
An ever growing library of assertions for QUnit in Ember.
We found that ember-cli-custom-assertions-collection demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).