Files
horizon/horizon/static/framework/util/uuid/uuid.spec.js
Rob Cresswell 0e957dd41a Add Angular Schema Form
This patch adds Angular Schema Form[1] and its requirements to Horizon.
There are a number of advantages to this over the current methods of
defining forms and workflows:

- All fields have an individual template, making theming improvements,
  bug fixes, and bootstrap conformity easier.
- The file and line count, especially for workflows, is dramatically
  reduced. The Create Net workflow, for example, goes from 12+ files to
  2, with a big reduction in boilerplate HTML.
- All field validation messages are standardised, so we can match them
  across Horizon and plugins

What this patch contains:
- Many common form fields, including things like the themable checkboxes
  and selects.
- A basic modal template that can be passed with ui-bootstraps $modal
  service to take advantage of schema-form

Next steps:
- Remove the other modal templates so we can standardise. A single
  template opened from the $modal service is fine, and we shouldn't need
  several directives. In this case, we should deprecate them, as the
  modal forms will be used elsewhere.
- Map commonly used form items, like transfer tables, to a schema form
  type like array (they serve similar purposes, so maybe thats what
  should be replaced)
- Use themable selects instead of regular ones

1. http://schemaform.io/

Co-Authored-By: Tyr Johanson <tyr@hpe.com>
Implements: blueprint angular-schema-form
Change-Id: Ib22b2d0db2c4d4775fdef62a180cc994e8ae6280
2016-08-04 16:53:41 +00:00

71 lines
2.0 KiB
JavaScript

/*
* (c) Copyright 2016 Cisco Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
describe('horizon.framework.util.uuid module', function() {
it('should have been defined', function () {
expect(angular.module('horizon.framework.util.uuid')).toBeDefined();
});
});
describe('uuid', function () {
var uuid;
beforeEach(module('horizon.framework'));
beforeEach(inject(function ($injector) {
uuid = $injector.get('horizon.framework.util.uuid.service');
}));
it('should be defined', function () {
expect(uuid).toBeDefined();
});
it('should generate multiple unique IDs', function() {
var unique = [];
var ids = [];
var i, j, potentialUUID, uniqueLen, isUnique;
// Generate 10 IDs
for (i = 0; i < 10; i += 1) {
ids.push(uuid.generate());
}
// Check that the IDs are unique
// Iterate through the IDs, check that it isn't part of our unique list,
// then append
for (i -= 1; i >= 0; i -= 1) {
potentialUUID = ids[i];
isUnique = true;
for (j = 0, uniqueLen = unique.length; j < uniqueLen; j += 1) {
if (potentialUUID === unique[j]) {
isUnique = false;
}
}
if (isUnique) {
unique.push(potentialUUID);
}
}
// Reverse the array, because Jasmine's "toEqual" won't work otherwise.
unique.reverse();
expect(ids).toEqual(unique);
});
});
}());