Fix assertion descriptions (#2405)

* Fix assertion descriptions

Move return statement to the end of define()

* ospec: Fix assertion definitions

* Fix typo in assertion

* Add test for descriptions being returned on fail

* Reference result instead of self in returned description method

* Fix style errors
This commit is contained in:
soulofmischief 2019-09-22 02:35:07 -05:00 committed by Isiah Meadows
parent ddb3d4ab07
commit 0ea6a190b6
3 changed files with 24 additions and 2 deletions

View file

@ -123,6 +123,7 @@ _2019-07-24_
#### Bug fixes
- API: `m.route.set()` causes all mount points to be redrawn ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592))
- ospec: Fix assertion definitions breaking on comparison failure
- render/attrs: Using style objects in hyperscript calls will now properly diff style properties from one render to another as opposed to re-writing all element style properties every render.
- render/attrs All vnodes attributes are properly removed when absent or set to `null` or `undefined` [#1804](https://github.com/MithrilJS/mithril.js/issues/1804) [#2082](https://github.com/MithrilJS/mithril.js/issues/2082) ([#1865](https://github.com/MithrilJS/mithril.js/pull/1865), [#2130](https://github.com/MithrilJS/mithril.js/pull/2130))
- render/core: Render state correctly on select change event [#1916](https://github.com/MithrilJS/mithril.js/issues/1916) ([#1918](https://github.com/MithrilJS/mithril.js/pull/1918) [@robinchew](https://github.com/robinchew), [#2052](https://github.com/MithrilJS/mithril.js/pull/2052))

View file

@ -291,8 +291,11 @@ else window.o = m()
var message = serialize(self.value) + "\n " + verb + "\n" + serialize(value)
if (compare(self.value, value)) succeed(self, message)
else fail(self, message)
var result = results[self.i]
return function(message) {
if (!self.pass) self.message = message + "\n\n" + self.message
if (!result.pass) {
result.message = message + "\n\n" + result.message
}
}
}
}

View file

@ -299,7 +299,7 @@ o.spec("ospec", function() {
})
})
o.spec("throwing in test context is recoreded as a failure", function() {
o.spec("throwing in test context is recorded as a failure", function() {
var oo
o.beforeEach(function(){oo = o.new()})
o.afterEach(function() {
@ -659,6 +659,24 @@ o.spec("ospec", function() {
})
})
})
o.spec("descriptions", function() {
o("description returned on failure", function(done) {
var oo = o.new()
oo("no description", function() {
oo(1).equals(2)
})
oo("description", function() {
oo(1).equals(2)("howdy")
})
oo.run(function(results) {
o(results.length).equals(2)
o(results[1].message).equals(`howdy\n\n${results[0].message}`)
o(results[1].pass).equals(false)
done()
})
})
})
})
o.spec("the done parser", function() {
o("accepts non-English names", function() {