Skip to content

Commit 9c7c98c

Browse files
committed
1 parent db58c4b commit 9c7c98c

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

src/directives/sf-array.directive.spec.js

+39-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ describe('sf-array.directive.js', function() {
2222
"type": "array",
2323
"description": "foobar",
2424
"items": {
25-
"title": "Name",
26-
"type": "string",
27-
"default": 6
25+
"type": "object",
26+
"properties": {
27+
"name": {
28+
"title": "Name",
29+
"type": "string",
30+
"default": 6
31+
}
32+
}
2833
}
2934
}
3035
}
@@ -63,4 +68,35 @@ describe('sf-array.directive.js', function() {
6368

6469
});
6570
});
71+
72+
it('should not delete innocent items on delete', function(done) {
73+
74+
tmpl = angular.element('<form name="testform" sf-schema="schema" sf-form="form" sf-model="model" json="{{model | json}}"></form>');
75+
76+
inject(function($compile, $rootScope) {
77+
var scope = $rootScope.$new();
78+
scope.model = {names: [{name: "0"}, {name: "1"}, {name: "2"}, {name: "3"}]};
79+
80+
scope.schema = exampleSchema;
81+
82+
scope.form = ["*"];
83+
84+
$compile(tmpl)(scope);
85+
runSync(scope, tmpl);
86+
87+
tmpl.find('div.help-block').text().should.equal('foobar');
88+
89+
var close = tmpl.find('button.close');
90+
close.eq(1).click();
91+
92+
$rootScope.$apply();
93+
94+
setTimeout(function() {
95+
scope.model.names[0].name.should.equal("0");
96+
scope.model.names[1].name.should.equal("2");
97+
scope.model.names[2].name.should.equal("3");
98+
done();
99+
}, 0)
100+
});
101+
});
66102
});

0 commit comments

Comments
 (0)