Sha256: e434be6ad9f0a1f7ff9c1172b264456a915ef826bc10b9011249c30e1df9536f
Contents?: true
Size: 1.64 KB
Versions: 3
Compression:
Stored size: 1.64 KB
Contents
import { normalizeControllerQueryParams } from '../lib/utils'; import { moduleFor, AbstractTestCase } from 'internal-test-helpers'; moduleFor( 'Routing query parameter utils - normalizeControllerQueryParams', class extends AbstractTestCase { ['@test converts array style into verbose object style'](assert) { let paramName = 'foo'; let params = [paramName]; let normalized = normalizeControllerQueryParams(params); assert.ok(normalized[paramName], 'turns the query param name into key'); assert.equal(normalized[paramName].as, null, "includes a blank alias in 'as' key"); assert.equal(normalized[paramName].scope, 'model', 'defaults scope to model'); } ["@test converts object style [{foo: 'an_alias'}]"](assert) { let paramName = 'foo'; let params = [{ foo: 'an_alias' }]; let normalized = normalizeControllerQueryParams(params); assert.ok(normalized[paramName], 'retains the query param name as key'); assert.equal(normalized[paramName].as, 'an_alias', "includes the provided alias in 'as' key"); assert.equal(normalized[paramName].scope, 'model', 'defaults scope to model'); } ["@test retains maximally verbose object style [{foo: {as: 'foo'}}]"](assert) { let paramName = 'foo'; let params = [{ foo: { as: 'an_alias' } }]; let normalized = normalizeControllerQueryParams(params); assert.ok(normalized[paramName], 'retains the query param name as key'); assert.equal(normalized[paramName].as, 'an_alias', "includes the provided alias in 'as' key"); assert.equal(normalized[paramName].scope, 'model', 'defaults scope to model'); } } );
Version data entries
3 entries across 3 versions & 1 rubygems