Skip to content

Commit 10cb655

Browse files
Support model reference invert property
1 parent 39e566e commit 10cb655

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
Generates unit test specs from ExtJs classes
33

44
How to publish to NPM
5+
1. Update Version in package.json.
6+
2. Push to repository.
7+
3. Create and push new git tag.
8+
4. `npm publish`.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extjs-spec-generator",
3-
"version": "1.2.14",
3+
"version": "1.2.15",
44
"description": "Generates unit test specs from ExtJs classes",
55
"scripts": {
66
"test": "karma start config/karma.conf.js",

src/UnitTestEngine.js

+25-9
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,32 @@ Ext.define('UnitTestEngine', {
1616
+ ' does not exists. The field name or data type might have been changed.');
1717
},
1818

19-
shouldHaveReference: function (fields, name, reference, inverse) {
19+
shouldHaveReference: function (fields, reference) {
2020
var field = _.find(fields, function (field) {
21-
return field.name === name
21+
return field.name === reference.name
2222
&& field.reference
23-
&& field.reference.type === reference;
23+
&& field.reference.type === reference.type;
2424
});
25-
should.exist(field, "Reference model '" + reference + "' for '" + name + "' does not exists.");
26-
if (inverse && reference) {
27-
field.reference.inverse.role.should.be.equal(inverse, "The inverse role '"
28-
+ inverse + "' is not equal to '" + field.reference.inverse.role + "'.")
25+
26+
it("should exists", function() {
27+
should.exist(field, "Model reference '" + reference.type + "' for '" + reference.name + "' does not exists.");
28+
})
29+
30+
if(field) {
31+
describe("Inverse & Store Config for model reference of " + field.name, function() {
32+
if (_.has(reference, 'inverse')) {
33+
if(_.has(reference.inverse, 'role')) {
34+
field.reference.inverse.role.should.be.equal(reference.inverse.role, "The inverse role '"
35+
+ reference.inverse.role + "' is not equal to '" + field.reference.inverse.role + "'.")
36+
}
37+
38+
if(_.has(reference.inverse, 'storeConfig')) {
39+
it('should have a "complete" property in storeConfig', function() {
40+
_.has(field.reference.inverse.storeConfig, 'complete').should.be.true("Can't find the 'complete' property.");
41+
})
42+
}
43+
}
44+
})
2945
}
3046
},
3147

@@ -106,10 +122,10 @@ Ext.define('UnitTestEngine', {
106122
should.exist(model, "Model does not exists.");
107123
});
108124

109-
it('should have reference model(s)', function () {
125+
describe('Model reference(s)', function () {
110126
if(isValid) {
111127
_.each(referenceList, function (ref) {
112-
UnitTestEngine.shouldHaveReference(fields, ref.name, ref.type, ref.role);
128+
UnitTestEngine.shouldHaveReference(model.fields, ref);
113129
})
114130
} else
115131
should.exist(model, "Model does not exists.");

0 commit comments

Comments
 (0)