Skip to content

Commit

Permalink
feat(google): add space to JSON format
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarulg committed Oct 18, 2024
1 parent 264b9c5 commit 0f6d8cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ angular
return JSON.parse(input);
}
function out(data) {
return JSON.stringify(data);
return JSON.stringify(data, null, 2);
}
ngModel.$parsers.push(into);
ngModel.$formatters.push(out);
Expand All @@ -47,7 +47,7 @@ angular
const modelKeys = () => Object.keys(this.model);

this.addField = () => {
this.backingModel.push({ key: '', value: '', checkUnique: modelKeys() });
this.backingModel.push({ key: '', value: {}, checkUnique: modelKeys() });
// do not fire the onChange event, since no values have been committed to the object
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,6 @@ describe('Component: mapObjectEditor', function () {
expect(dom.find('textarea').get(1).value).toBe('11');
});

describe('empty value handling', function () {
it('ignores empty values when synchronizing to the model', function () {
scope.model = { foo: { bar: 'baz' }, bah: 11 };
let dom = this.compile('<map-object-editor model="model"></map-object-editor>')(scope);
scope.$digest();

$(dom.find('textarea')[1]).val('').change();
scope.$digest();

expect(scope.model.foo).toEqual({ bar: 'baz' });
expect(scope.model.bah).toBeUndefined();
});

it('writes empty values when allowEmpty flag is set', function () {
scope.model = { foo: { bar: 'baz' }, bah: 11 };
let dom = this.compile('<map-object-editor model="model" allow-empty="true"></map-object-editor>')(scope);
scope.$digest();

$(dom.find('textarea')[1]).val('').change();
scope.$digest();

expect(scope.model.foo).toEqual({ bar: 'baz' });
expect(scope.model.bah).toBe('');
});
});

describe('adding new entries', function () {
it('creates a new row in the table, but does not synchronize to model', function () {
scope.model = {};
Expand Down

0 comments on commit 0f6d8cf

Please sign in to comment.