Skip to content

Commit 3a61d98

Browse files
chadhietalakrisselden
authored andcommitted
[GLIMMER2] Migrate query-params (#13544)
1 parent e5e6d25 commit 3a61d98

File tree

5 files changed

+79
-58
lines changed

5 files changed

+79
-58
lines changed

packages/ember-glimmer/lib/environment.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { default as log } from './helpers/log';
3030
import { default as readonly } from './helpers/readonly';
3131
import { default as unbound } from './helpers/unbound';
3232
import { default as classHelper } from './helpers/-class';
33+
import { default as queryParams } from './helpers/query-param';
3334
import { OWNER } from 'container/owner';
3435

3536
const builtInHelpers = {
@@ -43,6 +44,7 @@ const builtInHelpers = {
4344
log,
4445
readonly,
4546
unbound,
47+
'query-params': queryParams,
4648
'-class': classHelper
4749
};
4850

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { InternalHelperReference } from '../utils/references';
2+
import { assert } from 'ember-metal/debug';
3+
import QueryParams from 'ember-routing/system/query_params';
4+
import assign from 'ember-metal/assign';
5+
6+
function queryParams({ positional, named }) {
7+
assert('The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName=\'foo\') as opposed to just (query-params \'foo\')', positional.value().length === 0);
8+
9+
return QueryParams.create({
10+
values: assign({}, named.value())
11+
});
12+
}
13+
14+
export default {
15+
isInternalHelper: true,
16+
toReference(args) {
17+
return new InternalHelperReference(queryParams, args);
18+
}
19+
};

packages/ember/tests/helpers/link_to_test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ function sharedTeardown() {
7878
setTemplates({});
7979
}
8080

81-
import { test, testModule } from 'ember-glimmer/tests/utils/skip-if-glimmer';
81+
import { test } from 'ember-glimmer/tests/utils/skip-if-glimmer';
8282

83-
testModule('The {{link-to}} helper', {
83+
QUnit.module('The {{link-to}} helper', {
8484
setup() {
8585
run(function() {
8686
sharedSetup();
@@ -1502,7 +1502,7 @@ test('{{link-to}} populates href with default query param values even without qu
15021502
equal(jQuery('#the-link').attr('href'), '/', 'link has right href');
15031503
});
15041504

1505-
test('{{link-to}} populates href with default query param values with empty query-params object', function() {
1505+
QUnit.test('{{link-to}} populates href with default query param values with empty query-params object', function() {
15061506
if (isEnabled('ember-routing-route-configured-query-params')) {
15071507
App.IndexRoute = Route.extend({
15081508
queryParams: {
@@ -1523,7 +1523,7 @@ test('{{link-to}} populates href with default query param values with empty quer
15231523
equal(jQuery('#the-link').attr('href'), '/', 'link has right href');
15241524
});
15251525

1526-
test('{{link-to}} populates href with supplied query param values', function() {
1526+
QUnit.test('{{link-to}} populates href with supplied query param values', function() {
15271527
if (isEnabled('ember-routing-route-configured-query-params')) {
15281528
App.IndexRoute = Route.extend({
15291529
queryParams: {
@@ -1544,7 +1544,7 @@ test('{{link-to}} populates href with supplied query param values', function() {
15441544
equal(jQuery('#the-link').attr('href'), '/?foo=456', 'link has right href');
15451545
});
15461546

1547-
test('{{link-to}} populates href with partially supplied query param values', function() {
1547+
QUnit.test('{{link-to}} populates href with partially supplied query param values', function() {
15481548
if (isEnabled('ember-routing-route-configured-query-params')) {
15491549
App.IndexRoute = Route.extend({
15501550
queryParams: {
@@ -1569,7 +1569,7 @@ test('{{link-to}} populates href with partially supplied query param values', fu
15691569
equal(jQuery('#the-link').attr('href'), '/?foo=456', 'link has right href');
15701570
});
15711571

1572-
test('{{link-to}} populates href with partially supplied query param values, but omits if value is default value', function() {
1572+
QUnit.test('{{link-to}} populates href with partially supplied query param values, but omits if value is default value', function() {
15731573
if (isEnabled('ember-routing-route-configured-query-params')) {
15741574
App.IndexRoute = Route.extend({
15751575
queryParams: {
@@ -1590,7 +1590,7 @@ test('{{link-to}} populates href with partially supplied query param values, but
15901590
equal(jQuery('#the-link').attr('href'), '/', 'link has right href');
15911591
});
15921592

1593-
test('{{link-to}} populates href with fully supplied query param values', function() {
1593+
QUnit.test('{{link-to}} populates href with fully supplied query param values', function() {
15941594
if (isEnabled('ember-routing-route-configured-query-params')) {
15951595
App.IndexRoute = Route.extend({
15961596
queryParams: {
@@ -1615,7 +1615,7 @@ test('{{link-to}} populates href with fully supplied query param values', functi
16151615
equal(jQuery('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href');
16161616
});
16171617

1618-
test('{{link-to}} with only query-params and a block updates when route changes', function() {
1618+
QUnit.test('{{link-to}} with only query-params and a block updates when route changes', function() {
16191619
Router.map(function() {
16201620
this.route('about');
16211621
});
@@ -1649,7 +1649,7 @@ test('{{link-to}} with only query-params and a block updates when route changes'
16491649
equal(jQuery('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href');
16501650
});
16511651

1652-
test('Block-less {{link-to}} with only query-params updates when route changes', function() {
1652+
QUnit.test('Block-less {{link-to}} with only query-params updates when route changes', function() {
16531653
Router.map(function() {
16541654
this.route('about');
16551655
});

0 commit comments

Comments
 (0)