Skip to content

Commit

Permalink
fix tests for has-error and has-success` classes
Browse files Browse the repository at this point in the history
  • Loading branch information
rthaut committed Jul 7, 2018
1 parent e4201b7 commit 02f6448
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions test/directives/schema-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,25 +817,25 @@ describe('directive',function(){
});
});

it('should not clear the model when using multiple checkboxes targeting the same model array', function () {
it('should not clear the model when using multiple checkboxes targeting the same model array', function () {

inject(function ($compile, $rootScope) {
inject(function ($compile, $rootScope) {
var scope = $rootScope.$new();
scope.person = {
"names": ["foo"]
scope.person = {
"names": ["foo"]
};

scope.schema = {
scope.schema = {
"type": "object",
"properties": {
"names": {
"properties": {
"names": {
"type": "array",
"items": {
"items": {
"type": "string",
"enum": ["foo", "bar"]
}
}
}
"enum": ["foo", "bar"]
}
}
}
};

scope.form = [
Expand All @@ -848,24 +848,24 @@ describe('directive',function(){
var tmpl = angular.element('<form sf-schema="schema" sf-form="form" sf-model="person"></form>');

$compile(tmpl)(scope);
$rootScope.$apply();

$rootScope.$apply();

var foo = tmpl.children().eq(0).find('input[type=checkbox]').eq(0);
var bar = tmpl.children().eq(3).find('input[type=checkbox]').eq(1);

foo.prop('checked').should.be.true;
bar.prop('checked').should.be.false;
scope.person.names.length.should.be.equal(1);
scope.person.names.join(',').should.be.equal('foo');

bar.click()
scope.person.names.length.should.be.equal(2);
scope.person.names.join(',').should.be.equal('foo,bar');

var bar = tmpl.children().eq(3).find('input[type=checkbox]').eq(1);

foo.prop('checked').should.be.true;
bar.prop('checked').should.be.false;
scope.person.names.length.should.be.equal(1);
scope.person.names.join(',').should.be.equal('foo');

bar.click()
scope.person.names.length.should.be.equal(2);
scope.person.names.join(',').should.be.equal('foo,bar');

foo.click();
scope.person.names.length.should.be.equal(1);
scope.person.names.join(',').should.be.equal('bar');
});
scope.person.names.join(',').should.be.equal('bar');
});
});

it('should use radio buttons when they are wanted',function(){
Expand Down Expand Up @@ -2144,10 +2144,10 @@ describe('directive',function(){
ngModelCtrl.$valid = true;
ngModelCtrl.$pristine = false;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-success').should.be.true;
tmpl.children().eq(0).hasClass('has-success').should.be.true;
scope.form[0].disableSuccessState = true;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-success').should.be.false;
tmpl.children().eq(0).hasClass('has-success').should.be.false;
});
});

Expand Down Expand Up @@ -2194,10 +2194,10 @@ describe('directive',function(){
ngModelCtrl.$invalid = true;
ngModelCtrl.$pristine = false;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-error').should.be.true;
tmpl.children().eq(0).hasClass('has-error').should.be.true;
scope.form[0].disableErrorState = true;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-error').should.be.false;
tmpl.children().eq(0).hasClass('has-error').should.be.false;
});
});

Expand Down Expand Up @@ -2242,10 +2242,10 @@ describe('directive',function(){
ngModelCtrl.$valid = true;
ngModelCtrl.$pristine = false;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-success').should.be.true;
tmpl.children().eq(0).hasClass('has-success').should.be.true;
scope.form[0].disableSuccessState = true;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-success').should.be.false;
tmpl.children().eq(0).hasClass('has-success').should.be.false;
});
});

Expand Down Expand Up @@ -2292,10 +2292,10 @@ describe('directive',function(){
ngModelCtrl.$invalid = true;
ngModelCtrl.$pristine = false;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-error').should.be.true;
tmpl.children().eq(0).hasClass('has-error').should.be.true;
scope.form[0].disableErrorState = true;
$rootScope.$apply();
tmpl.children().eq(0).children().eq(0).hasClass('has-error').should.be.false;
tmpl.children().eq(0).hasClass('has-error').should.be.false;
});
});

Expand Down

0 comments on commit 02f6448

Please sign in to comment.