-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLEANUP beta] Assert on view and controller keywords
(cherry picked from commit 8f72bf2)
- Loading branch information
Showing
18 changed files
with
306 additions
and
258 deletions.
There are no files selected for viewing
60 changes: 44 additions & 16 deletions
60
packages/ember-htmlbars/tests/compat/controller_keyword_test.js
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,72 +1,100 @@ | ||
import Ember from 'ember-metal/core'; | ||
import EmberComponent from 'ember-views/views/component'; | ||
import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; | ||
import compile from 'ember-template-compiler/system/compile'; | ||
|
||
import { registerAstPlugin, removeAstPlugin } from 'ember-htmlbars/tests/utils'; | ||
import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection'; | ||
import DeprecateViewAndControllerPaths from 'ember-template-compiler/plugins/deprecate-view-and-controller-paths'; | ||
import AssertNoViewAndControllerPaths from 'ember-template-compiler/plugins/assert-no-view-and-controller-paths'; | ||
|
||
let component; | ||
|
||
QUnit.module('ember-htmlbars: compat - controller keyword (use as a path)', { | ||
setup() { | ||
Ember.ENV._ENABLE_LEGACY_CONTROLLER_SUPPORT = false; | ||
registerAstPlugin(AssertNoViewAndControllerPaths); | ||
|
||
component = null; | ||
}, | ||
teardown() { | ||
runDestroy(component); | ||
|
||
removeAstPlugin(AssertNoViewAndControllerPaths); | ||
Ember.ENV._ENABLE_LEGACY_CONTROLLER_SUPPORT = true; | ||
} | ||
}); | ||
|
||
QUnit.test('reading the controller keyword fails assertion', function() { | ||
var text = 'a-prop'; | ||
expectAssertion(function() { | ||
component = EmberComponent.extend({ | ||
prop: text, | ||
layout: compile('{{controller.prop}}') | ||
}).create(); | ||
|
||
runAppend(component); | ||
}, /Using `{{controller}}` or any path based on it .*/); | ||
}); | ||
|
||
QUnit.module('ember-htmlbars: compat - controller keyword (use as a path) [LEGACY]', { | ||
setup() { | ||
registerAstPlugin(TransformEachIntoCollection); | ||
registerAstPlugin(DeprecateViewAndControllerPaths); | ||
|
||
component = null; | ||
}, | ||
teardown() { | ||
runDestroy(component); | ||
|
||
removeAstPlugin(TransformEachIntoCollection); | ||
removeAstPlugin(DeprecateViewAndControllerPaths); | ||
} | ||
}); | ||
|
||
QUnit.test('reading the controller keyword is deprecated [DEPRECATED]', function() { | ||
QUnit.test('reading the controller keyword works [LEGACY]', function() { | ||
var text = 'a-prop'; | ||
expectDeprecation(function() { | ||
ignoreAssertion(function() { | ||
component = EmberComponent.extend({ | ||
prop: text, | ||
layout: compile('{{controller.prop}}') | ||
}).create(); | ||
}, /Using `{{controller}}` or any path based on it .*/); | ||
|
||
runAppend(component); | ||
}, /Using `{{controller}}` or any path based on it .* has been deprecated./); | ||
runAppend(component); | ||
equal(component.$().text(), text, 'controller keyword is read'); | ||
}); | ||
|
||
QUnit.test('reading the controller keyword for hash is deprecated [DEPRECATED]', function() { | ||
expectDeprecation(function() { | ||
QUnit.test('reading the controller keyword for hash [LEGACY]', function() { | ||
ignoreAssertion(function() { | ||
component = EmberComponent.extend({ | ||
prop: true, | ||
layout: compile('{{if true \'hiho\' option=controller.prop}}') | ||
}).create(); | ||
|
||
runAppend(component); | ||
}, /Using `{{controller}}` or any path based on it .* has been deprecated./); | ||
}, /Using `{{controller}}` or any path based on it .*/); | ||
ok(true, 'access keyword'); | ||
}); | ||
|
||
QUnit.test('reading the controller keyword for param is deprecated [DEPRECATED]', function() { | ||
QUnit.test('reading the controller keyword for param [LEGACY]', function() { | ||
var text = 'a-prop'; | ||
expectDeprecation(function() { | ||
ignoreAssertion(function() { | ||
component = EmberComponent.extend({ | ||
prop: true, | ||
layout: compile(`{{if controller.prop '${text}'}}`) | ||
}).create(); | ||
|
||
runAppend(component); | ||
}, /Using `{{controller}}` or any path based on it .* has been deprecated./); | ||
}, /Using `{{controller}}` or any path based on it .*/); | ||
equal(component.$().text(), text, 'controller keyword is read'); | ||
}); | ||
|
||
QUnit.test('reading the controller keyword for param with block is deprecated [DEPRECATED]', function() { | ||
expectDeprecation(function() { | ||
QUnit.test('reading the controller keyword for param with block fails assertion [LEGACY]', function() { | ||
ignoreAssertion(function() { | ||
component = EmberComponent.extend({ | ||
prop: true, | ||
layout: compile(`{{#each controller as |things|}}{{/each}}`) | ||
}).create(); | ||
|
||
runAppend(component); | ||
}, /Using `{{controller}}` or any path based on it .* has been deprecated./); | ||
}, /Using `{{controller}}` or any path based on it .*/); | ||
ok(true, 'access keyword'); | ||
}); |
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,34 +1,35 @@ | ||
import Ember from 'ember-metal/core'; | ||
import EmberComponent from 'ember-views/views/component'; | ||
import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; | ||
import compile from 'ember-template-compiler/system/compile'; | ||
|
||
import { registerAstPlugin, removeAstPlugin } from 'ember-htmlbars/tests/utils'; | ||
import DeprecateViewAndControllerPaths from 'ember-template-compiler/plugins/deprecate-view-and-controller-paths'; | ||
import AssertNoViewAndControllerPaths from 'ember-template-compiler/plugins/assert-no-view-and-controller-paths'; | ||
|
||
let component; | ||
|
||
QUnit.module('ember-htmlbars: compat - view keyword (use as a path)', { | ||
setup() { | ||
registerAstPlugin(DeprecateViewAndControllerPaths); | ||
Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT = false; | ||
registerAstPlugin(AssertNoViewAndControllerPaths); | ||
component = null; | ||
}, | ||
teardown() { | ||
runDestroy(component); | ||
removeAstPlugin(DeprecateViewAndControllerPaths); | ||
removeAstPlugin(AssertNoViewAndControllerPaths); | ||
Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT = true; | ||
} | ||
}); | ||
|
||
QUnit.test('reading the view keyword is deprecated [DEPRECATED]', function() { | ||
QUnit.test('reading the view keyword fails assertion', function() { | ||
var text = 'a-prop'; | ||
expectDeprecation(function() { | ||
expectAssertion(function() { | ||
component = EmberComponent.extend({ | ||
prop: text, | ||
layout: compile('{{view.prop}}') | ||
}).create(); | ||
|
||
runAppend(component); | ||
}, /Using `{{view}}` or any path based on it .* has been deprecated./); | ||
|
||
equal(component.$().text(), text, 'view keyword is read'); | ||
}, /Using `{{view}}` or any path based on it .*/); | ||
}); | ||
|
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
Oops, something went wrong.