-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX canary] Deprecate passing function as test argument to deprecate/warn/assert #12370
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import ViewNodeManager from 'ember-htmlbars/node-managers/view-node-manager'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. THANK YOU FOR WRITING TESTS FOR THIS!!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :P Pssst. There's component-node-manager too. I was thinking this should be pulled out to another PR so it doesn't interfere with the [BUGFIX release]. I guess it doesn't need to go into release though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are to confirm the changes in the assertion work properly (that is why there isn't a corresponding change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I needed it to help me confirm I kept the same logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok 👍 |
||
|
||
QUnit.module('ember-htmlbars: node-managers - ViewNodeManager'); | ||
|
||
QUnit.test('create method should assert if component hasn\'t been found', assert => { | ||
assert.expect(1); | ||
|
||
let found = { | ||
component: null, | ||
layout: null | ||
}; | ||
|
||
let path; | ||
|
||
expectAssertion(() => { | ||
ViewNodeManager.create(null, null, null, found, null, path); | ||
}, 'HTMLBars error: Could not find component named "' + path + '" (no component or template with that name was found)'); | ||
}); | ||
|
||
QUnit.test('create method shouldn\'t assert if `found.component` is truthy', assert => { | ||
assert.expect(1); | ||
|
||
let found = { | ||
component: {}, | ||
layout: null | ||
}; | ||
let attrs = {}; | ||
let renderNode = {}; | ||
|
||
let env = { | ||
renderer: { | ||
componentUpdateAttrs() { | ||
assert.ok('env.renderer.componentUpdateAttrs called'); | ||
} | ||
} | ||
}; | ||
|
||
ViewNodeManager.create(renderNode, env, attrs, found); | ||
}); | ||
|
||
QUnit.test('create method shouldn\'t assert if `found.layout` is truthy', assert => { | ||
assert.expect(0); | ||
|
||
let found = { | ||
component: null, | ||
layout: true | ||
}; | ||
|
||
ViewNodeManager.create(null, null, null, found); | ||
}); | ||
|
||
QUnit.test('create method shouldn\'t assert if `path` is falsy and `contentTemplate` is truthy', assert => { | ||
assert.expect(0); | ||
|
||
let found = { | ||
component: null, | ||
layout: null | ||
}; | ||
let path = null; | ||
let contentTemplate = true; | ||
|
||
ViewNodeManager.create(null, null, null, found, null, path, null, contentTemplate); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,8 +294,8 @@ function normalizeClasses(classes, output, streamBasePath) { | |
} | ||
|
||
function validateTaglessComponent(component) { | ||
assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), function() { | ||
assert('You cannot use `classNameBindings` on a tag-less component: ' + component.toString(), () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind tweaking this into an IIFE to keep the function style? |
||
var classNameBindings = component.classNameBindings; | ||
return !classNameBindings || classNameBindings.length === 0; | ||
}); | ||
}()); | ||
} |
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.
Instead of rewriting to avoid the function, can you make the function an IIFE instead? I personally find the function style of writing this much easier to understand.