Skip to content

Commit

Permalink
normal push for ED 5
Browse files Browse the repository at this point in the history
  • Loading branch information
esbanarango committed Aug 1, 2023
1 parent 4d08051 commit 83f25cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/dummy/app/models/fake-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class FakeModel extends Model {
@attr() declare images: any;
@attr('string') declare condType: string;

@hasMany('other-model', { async: true, inverse: null }) declare otherFakes: AsyncHasMany<OtherModel>;
@hasMany('other-model', { async: true, inverse: 'fakeModel' }) declare otherFakes: AsyncHasMany<OtherModel>;
@belongsTo('other-model', { async: true, inverse: null }) declare otherFake: AsyncBelongsTo<OtherModel>;
@belongsTo('async-model', { async: true, inverse: 'fakeModel' }) declare asyncModel: AsyncModel;

Expand Down
5 changes: 3 additions & 2 deletions tests/dummy/app/models/other-model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Model, { attr } from '@ember-data/model';

import Model, { attr, belongsTo, type AsyncBelongsTo } from '@ember-data/model';
import { modelValidator, type ValidationsConfig, type ValidatedModel } from 'ember-model-validator';

interface OtherModel extends ValidatedModel, Model {}

@modelValidator
class OtherModel extends Model {
@belongsTo('fake-model', { async: true, inverse: 'otherFakes' }) declare fakeModel: AsyncBelongsTo<OtherModel>;

@attr('string') declare name: string;

validations: ValidationsConfig = {
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/models/fake-model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,11 @@ module('Unit | Model | fake-model', function (hooks) {

let otherFakes = model.get('otherFakes');
const otherFake = store.createRecord('other-model');
otherFakes.pushObject(otherFake);
if (otherFakes.push) {
otherFakes.push(otherFake);
} else {
otherFakes.pushObject(otherFake);
}

assert.false(model.validate({ only: ['otherFakes'] }));
});
Expand Down

0 comments on commit 83f25cc

Please sign in to comment.