Skip to content

Commit

Permalink
Remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
fsmanuel committed Jun 24, 2022
1 parent 1da2b3c commit 4625bca
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 32 deletions.
3 changes: 1 addition & 2 deletions addon/-private/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import EmberObject, {
set,
get,
} from '@ember/object';
import { readOnly } from '@ember/object/computed';
import ResultCollection from '../validations/result-collection';
import WarningResultCollection from '../validations/warning-result-collection';
import InternalResultObject from './internal-result-object';

const { readOnly } = computed;

/**
* __PRIVATE__
*
Expand Down
9 changes: 7 additions & 2 deletions tests/dummy/app/components/validated-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export default class ValidatedInput extends Component {
return this.showValidations || this.args.didValidate || this.hasContent;
}
get showErrorClass() {
return this.notValidating && this.showErrorMessage && this.hasContent && this.validation;
return (
this.notValidating &&
this.showErrorMessage &&
this.hasContent &&
this.validation
);
}
get showErrorMessage() {
return this.shouldDisplayValidations && this.validation.isInvalid;
Expand All @@ -34,7 +39,7 @@ export default class ValidatedInput extends Component {
return this.args.model.get(`validations.attrs.${this.args.valuePath}`);
}
get value() {
return this.args.model.get(this.args.valuePath)
return this.args.model.get(this.args.valuePath);
}

get classes() {
Expand Down
22 changes: 10 additions & 12 deletions tests/dummy/app/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ export default class extends Controller {

@action
validate() {
this.model
.validate()
.then(({ validations }) => {
this.didValidate = true;
this.model.validate().then(({ validations }) => {
this.didValidate = true;

if (validations.get('isValid')) {
this.showAlert = false;
this.isRegistered = true;
this.showCode = false;
} else {
this.showAlert = true;
}
});
if (validations.get('isValid')) {
this.showAlert = false;
this.isRegistered = true;
this.showCode = false;
} else {
this.showAlert = true;
}
});
}

@action
Expand Down
1 change: 0 additions & 1 deletion tests/dummy/app/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';

export default class extends Route {
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
{{#bs-navbar fluid=true collapsed=true as |navbar|}}
<div class="navbar-header">
{{navbar.toggle}}
{{#link-to 'index' class='navbar-brand'}}
<LinkTo @route='index' class='navbar-brand'>
<img src='images/ember-logo.png' alt=''>
<span>CP Validations</span>
{{/link-to}}
</LinkTo>
</div>

{{#navbar.content}}
Expand Down
24 changes: 12 additions & 12 deletions tests/integration/helpers/v-get-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ module('Integration | Helper | v-get', function (hooks) {
test('it renders', async function (assert) {
assert.expect(1);

await render(hbs`{{v-get model 'isValid'}}`);
await render(hbs`{{v-get this.model 'isValid'}}`);
assert.dom(this.element).hasText('false');
});

test('access attribute validations', async function (assert) {
assert.expect(3);

await render(hbs`{{v-get model 'username' 'isValid'}}`);
await render(hbs`{{v-get this.model 'username' 'isValid'}}`);
assert.dom(this.element).hasText('false');

await render(hbs`{{v-get model 'username' 'message'}}`);
await render(hbs`{{v-get this.model 'username' 'message'}}`);
assert.dom(this.element).hasText('This field is invalid');

await render(hbs`{{v-get model 'email' 'isValid'}}`);
await render(hbs`{{v-get this.model 'email' 'isValid'}}`);
assert.dom(this.element).hasText('true');
});

test('updating validation should rerender', async function (assert) {
assert.expect(2);

await render(hbs`{{v-get model 'username' 'isValid'}}`);
await render(hbs`{{v-get this.model 'username' 'isValid'}}`);
assert.dom(this.element).hasText('false');

this.set('model.validations.attrs.username.isValid', true);
Expand All @@ -62,16 +62,16 @@ module('Integration | Helper | v-get', function (hooks) {
assert.expect(2);

await render(hbs`
{{#if (v-get model 'email' 'isValid')}}
{{#if (v-get this.model 'email' 'isValid')}}
Email address is valid
{{/if}}
`);

assert.dom(this.element).hasText('Email address is valid');

await render(hbs`
{{#unless (v-get model 'username' 'isValid')}}
{{v-get model 'username' 'message'}}
{{#unless (v-get this.model 'username' 'isValid')}}
{{v-get this.model 'username' 'message'}}
{{/unless}}
`);

Expand All @@ -82,7 +82,7 @@ module('Integration | Helper | v-get', function (hooks) {
assert.expect(2);

await render(
hbs`<button type="button" disabled={{v-get model 'isInvalid'}}>Button</button>`
hbs`<button type="button" disabled={{v-get this.model 'isInvalid'}}>Button</button>`
);

assert.dom(this.element).hasText('Button');
Expand All @@ -93,7 +93,7 @@ module('Integration | Helper | v-get', function (hooks) {
assert.expect(3);

await render(
hbs`<span class="base {{if (v-get model 'isInvalid') 'has-error'}}">Text</span>`
hbs`<span class="base {{if (v-get this.model 'isInvalid') 'has-error'}}">Text</span>`
);

assert.dom(this.element).hasText('Text');
Expand All @@ -108,11 +108,11 @@ module('Integration | Helper | v-get', function (hooks) {
test('access validations with named args', async function (assert) {
assert.expect(2);

await render(hbs`{{named-v-get model=model field='isValid'}}`);
await render(hbs`<NamedVGet @model={{this.model}} @field='isValid' />`);
assert.dom(this.element).hasText('false');

await render(
hbs`{{named-v-get model=model attr='username' field='isValid'}}`
hbs`<NamedVGet @model={{this.model}} @attr='username' @field='isValid' />`
);
assert.dom(this.element).hasText('false');
});
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validators/base-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { htmlSafe } from '@ember/string';
import { htmlSafe } from '@ember/template';
import EmberObject from '@ember/object';
import { alias } from '@ember/object/computed';
import BaseValidator from 'ember-cp-validations/validators/base';
Expand Down

0 comments on commit 4625bca

Please sign in to comment.