Skip to content

Commit

Permalink
Merge pull request #979 from rthaut/support/0.x
Browse files Browse the repository at this point in the history
Fix Karma Unit Tests (support/0.x)
  • Loading branch information
Anthropic authored Jul 7, 2018
2 parents e4201b7 + b59ffca commit ba3e5f8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 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
1 change: 0 additions & 1 deletion test/directives/sf-messages-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('directive',function() {

$compile(tmpl)(scope);
$rootScope.$apply();
console.log(tmpl.children().find('div.help-block')[0]);
tmpl.children().find('div.help-block').text().should.equal('foobar');

setTimeout(function() {
Expand Down

0 comments on commit ba3e5f8

Please sign in to comment.