mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
UI: Ember 5 deprecations: filterBy, mapBy, auto location (#25546)
* Replace all mapBy * Replace findBys * Remove auto location https://deprecations.emberjs.com/v4.x/\#toc_deprecate-auto-location * fixes Co-authored-by: Kianna <30884335+kiannaquach@users.noreply.github.com>
This commit is contained in:
@@ -132,7 +132,11 @@ export default ApplicationAdapter.extend({
|
||||
|
||||
saveZeroAddressConfig(store, type, snapshot) {
|
||||
const path = encodePath(snapshot.id);
|
||||
const roles = store.peekAll('role-ssh').filterBy('zeroAddress').mapBy('id').join(',');
|
||||
const roles = store
|
||||
.peekAll('role-ssh')
|
||||
.filter((role) => role.zeroAddress)
|
||||
.map((role) => role.id)
|
||||
.join(',');
|
||||
const url = `/v1/${path}/config/zeroaddress`;
|
||||
const data = { roles };
|
||||
if (roles === '') {
|
||||
|
||||
@@ -139,9 +139,9 @@ export default Component.extend(DEFAULTS, {
|
||||
}
|
||||
// if type is provided we can ignore path since we are attempting to lookup a specific backend by type
|
||||
if (keyIsPath && !type) {
|
||||
return methods.findBy('path', selected);
|
||||
return methods.find((m) => m.path === selected);
|
||||
}
|
||||
return this.authMethods.findBy('type', selected);
|
||||
return this.authMethods.find((m) => m.type === selected);
|
||||
},
|
||||
|
||||
selectedAuthIsPath: match('selectedAuth', /\/$/),
|
||||
|
||||
@@ -33,7 +33,7 @@ export default Component.extend({
|
||||
|
||||
currentUserHasAuthorized: computed('currentUserEntityId', 'model.authorizations.@each.id', function () {
|
||||
const authorizations = this.model.authorizations || [];
|
||||
return Boolean(authorizations.findBy('id', this.currentUserEntityId));
|
||||
return Boolean(authorizations.find((authz) => authz.id === this.currentUserEntityId));
|
||||
}),
|
||||
|
||||
isSuccess: or('currentUserHasAuthorized', 'model.approved'),
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class MfaForm extends Component {
|
||||
super(...arguments);
|
||||
// trigger validation immediately when passcode is not required
|
||||
const passcodeOrSelect = this.constraints.filter((constraint) => {
|
||||
return constraint.methods.length > 1 || constraint.methods.findBy('uses_passcode');
|
||||
return constraint.methods.length > 1 || constraint.methods.find((m) => m.uses_passcode);
|
||||
});
|
||||
if (!passcodeOrSelect.length) {
|
||||
this.validate.perform();
|
||||
@@ -112,7 +112,11 @@ export default class MfaForm extends Component {
|
||||
|
||||
@action onSelect(constraint, id) {
|
||||
set(constraint, 'selectedId', id);
|
||||
set(constraint, 'selectedMethod', constraint.methods.findBy('id', id));
|
||||
set(
|
||||
constraint,
|
||||
'selectedMethod',
|
||||
constraint.methods.find((m) => m.id === id)
|
||||
);
|
||||
}
|
||||
@action submit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -91,11 +91,11 @@ export default class MfaLoginEnforcementForm extends Component {
|
||||
}
|
||||
async fetchAuthMethods() {
|
||||
const mounts = (await this.store.findAll('auth-method')).toArray();
|
||||
this.authMethods = mounts.mapBy('type');
|
||||
this.authMethods = mounts.map((auth) => auth.type);
|
||||
}
|
||||
|
||||
get selectedTarget() {
|
||||
return this.targetTypes.findBy('type', this.selectedTargetType);
|
||||
return this.targetTypes.find((tt) => tt.type === this.selectedTargetType);
|
||||
}
|
||||
get errors() {
|
||||
return this.args.modelErrors || this.modelErrors;
|
||||
|
||||
@@ -52,6 +52,6 @@ export default class MfaLoginEnforcementHeaderComponent extends Component {
|
||||
onEnforcementSelect([name]) {
|
||||
// search select returns array of strings, in this case enforcement name
|
||||
// lookup model and pass to callback
|
||||
this.args.onEnforcementSelect(this._enforcements.findBy('name', name));
|
||||
this.args.onEnforcementSelect(this._enforcements.find((enf) => enf.name === name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export default class OidcProviderForm extends Component {
|
||||
// function passed to search select
|
||||
renderInfoTooltip(selection, dropdownOptions) {
|
||||
// if a client has been deleted it will not exist in dropdownOptions (response from search select's query)
|
||||
const clientExists = !!dropdownOptions.findBy('clientId', selection);
|
||||
const clientExists = !!dropdownOptions.find((opt) => opt.clientId === selection);
|
||||
return !clientExists ? 'The application associated with this client_id no longer exists' : false;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ export default class SecretCreateOrUpdate extends Component {
|
||||
addRow() {
|
||||
const data = this.args.secretData;
|
||||
// fired off on init
|
||||
if (isNone(data.findBy('name', ''))) {
|
||||
if (isNone(data.find((d) => d.name === ''))) {
|
||||
data.pushObject({ name: '', value: '' });
|
||||
this.handleChange();
|
||||
}
|
||||
@@ -191,7 +191,7 @@ export default class SecretCreateOrUpdate extends Component {
|
||||
@action
|
||||
deleteRow(name) {
|
||||
const data = this.args.secretData;
|
||||
const item = data.findBy('name', name);
|
||||
const item = data.find((d) => d.name === name);
|
||||
if (isBlank(item.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export default Component.extend({
|
||||
});
|
||||
|
||||
if (this.showReplication === false) {
|
||||
const feature = this.allFeatures.findBy('key', 'replication');
|
||||
const feature = this.allFeatures.find((f) => f.key === 'replication');
|
||||
feature.show = false;
|
||||
}
|
||||
},
|
||||
@@ -134,7 +134,7 @@ export default Component.extend({
|
||||
showReplication: or('version.hasPerfReplication', 'version.hasDRReplication'),
|
||||
|
||||
selectedFeatures: computed('allFeatures.@each.selected', function () {
|
||||
return this.allFeatures.filterBy('selected').mapBy('key');
|
||||
return this.allFeatures.filter((feature) => feature.selected).map((feature) => feature.key);
|
||||
}),
|
||||
|
||||
cannotStartWizard: not('selectedFeatures.length'),
|
||||
|
||||
2
ui/app/config/environment.d.ts
vendored
2
ui/app/config/environment.d.ts
vendored
@@ -11,7 +11,7 @@ declare const config: {
|
||||
environment: string;
|
||||
modulePrefix: string;
|
||||
podModulePrefix: string;
|
||||
locationType: 'history' | 'hash' | 'none' | 'auto';
|
||||
locationType: 'history' | 'hash' | 'none';
|
||||
rootURL: string;
|
||||
APP: Record<string, unknown>;
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ export default Controller.extend({
|
||||
filterMatchesKey: computed('filter', 'model', 'model.[]', function () {
|
||||
var filter = this.filter;
|
||||
var content = this.model;
|
||||
return !!(content && content.length && content.findBy('id', filter));
|
||||
return !!(content && content.length && content.find((c) => c.id === filter));
|
||||
}),
|
||||
|
||||
firstPartialMatch: computed('filter', 'model', 'model.[]', 'filterMatchesKey', function () {
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class MountSecretBackendController extends Controller {
|
||||
onMountSuccess(type, path, useEngineRoute = false) {
|
||||
let transition;
|
||||
if (SUPPORTED_BACKENDS.includes(type)) {
|
||||
const engineInfo = allEngines().findBy('type', type);
|
||||
const engineInfo = allEngines().find((engine) => engine.type === type);
|
||||
if (useEngineRoute) {
|
||||
transition = this.router.transitionTo(
|
||||
`vault.cluster.secrets.backend.${engineInfo.engineRoute}`,
|
||||
|
||||
@@ -144,7 +144,7 @@ export function allEngines() {
|
||||
|
||||
export function isAddonEngine(type, version) {
|
||||
if (type === 'kv' && version === 1) return false;
|
||||
const engineRoute = allEngines().findBy('type', type)?.engineRoute;
|
||||
const engineRoute = allEngines().find((engine) => engine.type === type)?.engineRoute;
|
||||
return !!engineRoute;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ export default class MfaLoginEnforcementModel extends Model {
|
||||
|
||||
iconForMount(type) {
|
||||
const mountableMethods = methods();
|
||||
const mount = mountableMethods.findBy('type', type);
|
||||
const mount = mountableMethods.find((method) => method.type === type);
|
||||
return mount ? mount.glyph || mount.type : 'token';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ export default class SecretEngineModel extends Model {
|
||||
return 'vault.cluster.secrets.backend.overview';
|
||||
}
|
||||
if (isAddonEngine(this.engineType, this.version)) {
|
||||
const { engineRoute } = allEngines().findBy('type', this.engineType);
|
||||
const { engineRoute } = allEngines().find((engine) => engine.type === this.engineType);
|
||||
return `vault.cluster.secrets.backend.${engineRoute}`;
|
||||
}
|
||||
return `vault.cluster.secrets.backend.list-root`;
|
||||
|
||||
@@ -16,7 +16,7 @@ export default Route.extend({
|
||||
model(params) {
|
||||
const { path } = params;
|
||||
return this.store.findAll('auth-method').then((modelArray) => {
|
||||
const model = modelArray.findBy('id', path);
|
||||
const model = modelArray.find((m) => m.id === path);
|
||||
if (!model) {
|
||||
const error = new AdapterError();
|
||||
set(error, 'httpStatus', 404);
|
||||
|
||||
@@ -69,7 +69,7 @@ export default Route.extend({
|
||||
const secretEngine = this.store.peekRecord('secret-engine', backend);
|
||||
const type = secretEngine?.engineType;
|
||||
assert('secretEngine.engineType is not defined', !!type);
|
||||
const engineRoute = allEngines().findBy('type', type)?.engineRoute;
|
||||
const engineRoute = allEngines().find((engine) => engine.type === type)?.engineRoute;
|
||||
|
||||
if (!type || !SUPPORTED_BACKENDS.includes(type)) {
|
||||
return this.router.transitionTo('vault.cluster.secrets');
|
||||
|
||||
@@ -121,7 +121,7 @@ export default Service.extend({
|
||||
backend: {
|
||||
// add mount path for password reset
|
||||
mountPath: stored.backend.mountPath,
|
||||
...BACKENDS.findBy('type', backend),
|
||||
...BACKENDS.find((b) => b.type === backend),
|
||||
},
|
||||
});
|
||||
}),
|
||||
@@ -267,7 +267,7 @@ export default Service.extend({
|
||||
|
||||
const currentBackend = {
|
||||
mountPath,
|
||||
...BACKENDS.findBy('type', backend),
|
||||
...BACKENDS.find((b) => b.type === backend),
|
||||
};
|
||||
let displayName;
|
||||
if (isArray(currentBackend.displayNamePath)) {
|
||||
|
||||
@@ -56,7 +56,7 @@ export const expandAttributeMeta = function (modelClass, attributeNames) {
|
||||
});
|
||||
}
|
||||
// lookup attr and return meta
|
||||
return modelAttrs[klass.modelName].findBy('name', attrKey);
|
||||
return modelAttrs[klass.modelName].find((attr) => attr.name === attrKey);
|
||||
};
|
||||
|
||||
return fields.map((field) => {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { assert } from '@ember/debug';
|
||||
import flightIconMap from '@hashicorp/flight-icons/catalog.json';
|
||||
const flightIconNames = flightIconMap.assets.mapBy('iconName').uniq();
|
||||
const flightIconNames = flightIconMap.assets.map((asset) => asset.iconName).uniq();
|
||||
|
||||
/**
|
||||
* @module Icon
|
||||
|
||||
@@ -80,7 +80,7 @@ export default class InfoTableItemArray extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
this.allOptions = modelRecords ? modelRecords.mapBy('id') : null;
|
||||
this.allOptions = modelRecords ? modelRecords.map((record) => record.id) : null;
|
||||
if (this.args.renderItemName && modelRecords) {
|
||||
modelRecords.forEach(({ id, name }) => {
|
||||
// create key/value pair { item-id: item-name } for each record
|
||||
|
||||
@@ -63,7 +63,7 @@ export default class KvObjectEditor extends Component {
|
||||
}
|
||||
@action
|
||||
addRow() {
|
||||
if (!isNone(this.kvData.findBy('name', ''))) {
|
||||
if (!isNone(this.kvData.find((datum) => datum.name === ''))) {
|
||||
return;
|
||||
}
|
||||
const newObj = { name: '', value: '' };
|
||||
|
||||
@@ -79,7 +79,7 @@ export default class SearchSelectWithModal extends Component {
|
||||
// inputValues are initially an array of strings from @inputValue
|
||||
// map over so selectedOptions are objects
|
||||
return inputValues.map((option) => {
|
||||
const matchingOption = this.dropdownOptions.findBy('id', option);
|
||||
const matchingOption = this.dropdownOptions.find((opt) => opt.id === option);
|
||||
// remove any matches from dropdown list
|
||||
this.dropdownOptions.removeObject(matchingOption);
|
||||
return {
|
||||
@@ -140,11 +140,10 @@ export default class SearchSelectWithModal extends Component {
|
||||
|
||||
shouldShowCreate(id, searchResults) {
|
||||
if (searchResults && searchResults.length && searchResults.firstObject.groupName) {
|
||||
return !searchResults.some((group) => group.options.findBy('id', id));
|
||||
return !searchResults.some((group) => group.options.find((opt) => opt.id === id));
|
||||
}
|
||||
const existingOption =
|
||||
this.dropdownOptions &&
|
||||
(this.dropdownOptions.findBy('id', id) || this.dropdownOptions.findBy('name', id));
|
||||
this.dropdownOptions && this.dropdownOptions.find((opt) => opt.id === id || opt.name === id);
|
||||
return !existingOption;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ export default class SearchSelect extends Component {
|
||||
// inputValues are initially an array of strings from @inputValue
|
||||
// map over so selectedOptions are objects
|
||||
return inputValues.map((option) => {
|
||||
const matchingOption = this.dropdownOptions.findBy(this.idKey, option);
|
||||
const matchingOption = this.dropdownOptions.find((opt) => opt[this.idKey] === option);
|
||||
// tooltip text comes from return of parent function
|
||||
const addTooltip = this.args.renderInfoTooltip
|
||||
? this.args.renderInfoTooltip(option, this.dropdownOptions)
|
||||
@@ -170,7 +170,7 @@ export default class SearchSelect extends Component {
|
||||
const options = yield this.store.query(modelType, queryParams);
|
||||
|
||||
// store both select + unselected options in tracked property used by wildcard filter
|
||||
this.allOptions = [...this.allOptions, ...options.mapBy('id')];
|
||||
this.allOptions = [...this.allOptions, ...options.map((option) => option.id)];
|
||||
|
||||
// add to dropdown options
|
||||
this.dropdownOptions = [...this.dropdownOptions, ...this.addSearchText(options)];
|
||||
@@ -209,11 +209,10 @@ export default class SearchSelect extends Component {
|
||||
|
||||
shouldShowCreate(id, searchResults) {
|
||||
if (searchResults && searchResults.length && searchResults.firstObject.groupName) {
|
||||
return !searchResults.some((group) => group.options.findBy('id', id));
|
||||
return !searchResults.some((group) => group.options.find((opt) => opt.id === id));
|
||||
}
|
||||
const existingOption =
|
||||
this.dropdownOptions &&
|
||||
(this.dropdownOptions.findBy('id', id) || this.dropdownOptions.findBy('name', id));
|
||||
this.dropdownOptions && this.dropdownOptions.find((opt) => opt.id === id || opt.name === id);
|
||||
if (this.args.disallowNewItems && !existingOption) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export default class StringList extends Component {
|
||||
}
|
||||
|
||||
toVal() {
|
||||
const inputs = this.inputList.filter((x) => x.value).mapBy('value');
|
||||
const inputs = this.inputList.filter((x) => x.value).map((x) => x.value);
|
||||
if (this.args.type === 'string') {
|
||||
return inputs.join(',');
|
||||
}
|
||||
|
||||
@@ -152,8 +152,7 @@ export function optionsForBackend(backend, tab) {
|
||||
const selected = SECRET_BACKENDS[backend];
|
||||
let backendOptions;
|
||||
if (selected && selected.tabs) {
|
||||
const tabData =
|
||||
selected.tabs.findBy('name', tab) || selected.tabs.findBy('modelPrefix', tab) || selected.tabs[0];
|
||||
const tabData = selected.tabs.find((t) => t.name === tab || t.modelPrefix === tab) || selected.tabs[0];
|
||||
backendOptions = { ...selected, ...tabData };
|
||||
} else if (selected) {
|
||||
backendOptions = selected;
|
||||
|
||||
@@ -23,7 +23,7 @@ export default Mixin.create({
|
||||
|
||||
filterMatchesKey: computed('filter', 'model', 'model.[]', function () {
|
||||
const { filter, model: content } = this;
|
||||
return !!(content.length && content.findBy('id', filter));
|
||||
return !!(content.length && content.find((c) => c.id === filter));
|
||||
}),
|
||||
|
||||
firstPartialMatch: computed('filter', 'model', 'model.[]', 'filterMatchesKey', function () {
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function handleHasManySelection(selectedIds, modelCollection, sto
|
||||
}
|
||||
});
|
||||
// now check for selected items that don't exist and add them to the model
|
||||
const modelIds = modelCollection.mapBy('id');
|
||||
const modelIds = modelCollection.map((model) => model.id);
|
||||
selectedIds.forEach((id) => {
|
||||
if (!modelIds.includes(id)) {
|
||||
const model = store.peekRecord(modelRecord, id);
|
||||
|
||||
@@ -99,11 +99,11 @@ export default class CreateAndEditRolePageComponent extends Component {
|
||||
this.selectedTemplateId = '1';
|
||||
|
||||
if (generatedRoleRules) {
|
||||
const template = rulesTemplates.findBy('rules', generatedRoleRules);
|
||||
const template = rulesTemplates.find((t) => t.rules === generatedRoleRules);
|
||||
if (template) {
|
||||
this.selectedTemplateId = template.id;
|
||||
} else {
|
||||
rulesTemplates.findBy('id', '1').rules = generatedRoleRules;
|
||||
rulesTemplates.find((t) => t.id === '1').rules = generatedRoleRules;
|
||||
}
|
||||
}
|
||||
this.roleRulesTemplates = rulesTemplates;
|
||||
@@ -134,7 +134,7 @@ export default class CreateAndEditRolePageComponent extends Component {
|
||||
*save() {
|
||||
try {
|
||||
// set generatedRoleRoles to value of selected template
|
||||
const selectedTemplate = this.roleRulesTemplates?.findBy('id', this.selectedTemplateId);
|
||||
const selectedTemplate = this.roleRulesTemplates?.find((t) => t.id === this.selectedTemplateId);
|
||||
if (selectedTemplate) {
|
||||
this.args.model.generatedRoleRules = selectedTemplate.rules;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ export default class KvSecretPaths extends Component {
|
||||
}
|
||||
|
||||
get commands() {
|
||||
const cliPath = this.paths.findBy('label', 'CLI path').snippet;
|
||||
const apiPath = this.paths.findBy('label', 'API path').snippet;
|
||||
const cliPath = this.paths.find((p) => p.label === 'CLI path').snippet;
|
||||
const apiPath = this.paths.find((p) => p.label === 'API path').snippet;
|
||||
// as a future improvement, it might be nice to use window.location.protocol here:
|
||||
const url = `https://127.0.0.1:8200${apiPath}`;
|
||||
|
||||
|
||||
@@ -93,8 +93,8 @@ export default Component.extend({
|
||||
secretList = result.secret;
|
||||
authList = result.auth;
|
||||
}
|
||||
var currentSecrets = lastOptions && lastOptions.findBy('groupName', 'Secret Engines');
|
||||
var currentAuths = lastOptions && lastOptions.findBy('groupName', 'Auth Methods');
|
||||
var currentSecrets = lastOptions && lastOptions.find((opt) => opt.groupName === 'Secret Engines');
|
||||
var currentAuths = lastOptions && lastOptions.find((opt) => opt.groupName === 'Auth Methods');
|
||||
const formattedNamespaces = namespaces.map((val) => {
|
||||
return {
|
||||
id: val,
|
||||
|
||||
@@ -56,7 +56,7 @@ export default function (server) {
|
||||
server.get('/:path/roles', (schema) => {
|
||||
return {
|
||||
data: {
|
||||
keys: schema.db.kubernetesRoles.where({}).mapBy('name'),
|
||||
keys: schema.db.kubernetesRoles.where({}).map((role) => role.name),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -126,7 +126,11 @@ module('Acceptance | init', function (hooks) {
|
||||
'shows all of the recovery keys'
|
||||
);
|
||||
assert.strictEqual(initPage.buttonText, 'Continue to Authenticate', 'links to authenticate');
|
||||
assertRequest(this.server.handledRequests.findBy('url', '/v1/sys/init'), assert, true);
|
||||
assertRequest(
|
||||
this.server.handledRequests.find((req) => req.url === '/v1/sys/init'),
|
||||
assert,
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
test('shamir seal init', async function (assert) {
|
||||
@@ -139,6 +143,10 @@ module('Acceptance | init', function (hooks) {
|
||||
|
||||
assert.strictEqual(initPage.keys.length, SEAL_RESPONSE.keys.length, 'shows all of the recovery keys');
|
||||
assert.strictEqual(initPage.buttonText, 'Continue to Unseal', 'links to unseal');
|
||||
assertRequest(this.server.handledRequests.findBy('url', '/v1/sys/init'), assert, false);
|
||||
assertRequest(
|
||||
this.server.handledRequests.find((r) => r.url === '/v1/sys/init'),
|
||||
assert,
|
||||
false
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ module('Acceptance | mfa-method', function (hooks) {
|
||||
// ensure methods are tied to an enforcement
|
||||
this.server.get('/identity/mfa/login-enforcement', () => {
|
||||
const record = this.server.create('mfa-login-enforcement', {
|
||||
mfa_method_ids: this.getMethods().mapBy('id'),
|
||||
mfa_method_ids: this.getMethods().map((m) => m.id),
|
||||
});
|
||||
return {
|
||||
data: {
|
||||
|
||||
@@ -81,8 +81,8 @@ module('Integration | Component | search select', function (hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
const mockFunctionFromParent = (selection, dropdownOptions) => {
|
||||
const modelExists =
|
||||
!!dropdownOptions.findBy('id', selection) ||
|
||||
!!dropdownOptions.findBy('uuid', selection) ||
|
||||
!!dropdownOptions.find((opt) => opt.id === selection) ||
|
||||
!!dropdownOptions.find((opt) => opt.uuid === selection) ||
|
||||
isWildcardString([selection]);
|
||||
return !modelExists ? 'The model associated with this id no longer exists' : false;
|
||||
};
|
||||
|
||||
@@ -134,7 +134,11 @@ module('Unit | Service | store', function (hooks) {
|
||||
let result;
|
||||
result = await this.store.fetchPage('transit-key', query);
|
||||
assert.strictEqual(result.get('length'), pageSize, 'returns the correct number of items');
|
||||
assert.deepEqual(result.mapBy('id'), keys.slice(0, pageSize), 'returns the first page of items');
|
||||
assert.deepEqual(
|
||||
result.map((r) => r.id),
|
||||
keys.slice(0, pageSize),
|
||||
'returns the first page of items'
|
||||
);
|
||||
assert.deepEqual(
|
||||
result.get('meta'),
|
||||
{
|
||||
@@ -157,7 +161,7 @@ module('Unit | Service | store', function (hooks) {
|
||||
const pageThreeEnd = 3 * pageSize;
|
||||
const pageThreeStart = pageThreeEnd - pageSize;
|
||||
assert.deepEqual(
|
||||
result.mapBy('id'),
|
||||
result.map((r) => r.id),
|
||||
keys.slice(pageThreeStart, pageThreeEnd),
|
||||
'returns the third page of items'
|
||||
);
|
||||
@@ -169,7 +173,7 @@ module('Unit | Service | store', function (hooks) {
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
result.mapBy('id'),
|
||||
result.map((r) => r.id),
|
||||
keys.slice(keys.length - 1),
|
||||
'returns the last page when the page value is beyond the of bounds'
|
||||
);
|
||||
@@ -180,7 +184,7 @@ module('Unit | Service | store', function (hooks) {
|
||||
responsePath: 'data.keys',
|
||||
});
|
||||
assert.deepEqual(
|
||||
result.mapBy('id'),
|
||||
result.map((r) => r.id),
|
||||
keys.slice(0, pageSize),
|
||||
'returns the first page when page value is under the bounds'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user