diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2013-04-08 16:49:56 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2013-05-06 16:22:23 +0200 |
commit | fcbf5cc411de2f6195f53fe70c54458386fc588a (patch) | |
tree | eccc5171fd882af4d4b47b9fceb2bdeffddd313a /install/ui/test | |
parent | abdb5455d1954f2fab4d5def42c6b99590067eae (diff) | |
download | freeipa-fcbf5cc411de2f6195f53fe70c54458386fc588a.tar.gz freeipa-fcbf5cc411de2f6195f53fe70c54458386fc588a.tar.xz freeipa-fcbf5cc411de2f6195f53fe70c54458386fc588a.zip |
Spec modification by diff object
https://fedorahosted.org/freeipa/ticket/3235
Diffstat (limited to 'install/ui/test')
-rw-r--r-- | install/ui/test/all_tests.html | 6 | ||||
-rw-r--r-- | install/ui/test/build_tests.html | 22 | ||||
-rw-r--r-- | install/ui/test/build_tests.js | 119 | ||||
-rw-r--r-- | install/ui/test/index.html | 1 | ||||
-rw-r--r-- | install/ui/test/jsl.conf | 3 |
5 files changed, 148 insertions, 3 deletions
diff --git a/install/ui/test/all_tests.html b/install/ui/test/all_tests.html index 0acd8b76d..dc4e6c832 100644 --- a/install/ui/test/all_tests.html +++ b/install/ui/test/all_tests.html @@ -23,8 +23,9 @@ 'test/aci_tests', 'test/widget_tests', 'test/ip_tests', - 'test/utils_tests' - ], function(om, ipa, details, entity, as, nav, cert, aci, wid, ip, ut){ + 'test/utils_tests', + 'test/build_tests' + ], function(om, ipa, details, entity, as, nav, cert, aci, wid, ip, ut, bt){ om(); ipa(); details(); @@ -36,6 +37,7 @@ wid(); ip(); ut(); + bt(); }); </script> </head> diff --git a/install/ui/test/build_tests.html b/install/ui/test/build_tests.html new file mode 100644 index 000000000..7b61a9ce5 --- /dev/null +++ b/install/ui/test/build_tests.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html> +<head> + <title>IPA utils test suite</title> + <link rel="stylesheet" href="qunit.css" type="text/css" media="screen"> + <script type="text/javascript" src="qunit.js"></script> + <script type="text/javascript" src="config.js"></script> + <script type="text/javascript" src="../js/dojo/dojo.js"></script> + + <script type="text/javascript"> + require(['test/build_tests'], function(tests){ tests() }); + </script> +</head> +<body> + <h1 id="qunit-header">IPA Build test suite</h1> + <h2 id="qunit-banner"></h2> + <div id="qunit-testrunner-toolbar"></div> + <h2 id="qunit-userAgent"></h2> + <ol id="qunit-tests"></ol> + <div id="qunit-fixture"></div> +</body> +</html>
\ No newline at end of file diff --git a/install/ui/test/build_tests.js b/install/ui/test/build_tests.js new file mode 100644 index 000000000..11c5a03e5 --- /dev/null +++ b/install/ui/test/build_tests.js @@ -0,0 +1,119 @@ +/* Authors: + * Petr Vobornik <pvoborni@redhat.com> + * + * Copyright (C) 2013 Red Hat + * see file 'COPYING' for use and warranty information + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +define([ + 'freeipa/_base/Spec_mod'], + function(Spec_mod) { return function() { + + +module('build',{ + + setup: function() { + }, + teardown: function() { + } +}); + +test('Testing builder', function() { +}); + +test('Testing Spec_mod', function() { + + var sm = new Spec_mod(); + + var spec = { + foo: { + arr1: [ + { name: 'i1', a: 'b' }, + { name: 'i2', a: 'b' }, + { name: 'i3', a: 'c' }, + { name: 'i4', a: 'c' }, + { name: 'i5', a: 'a' } + ], + arr2: ['item1'] + }, + baz: { + bar: 'a' + }, + bar: 'b' + }; + + var diff = { + $add: [ + ['foo.arr1', { name: 'foo', a: 'c' }], + ['foo.arr2', 'item2'], + ['foo.arr2', { name: 'foo' }], + ['arr3', 'a'] //creates new array + ], + $del: [ + [ + 'foo.arr1', + [ + { name: 'i1' }, //match + { a: 'c'}, // 2 matches + { name: 'i2', a:'c' }, //no match + { name: 'i5', a:'a' } // match + ] + ], + [ 'foo.arr2', ['item1'] ] //match + ], + $set: [ + [ 'arr4', ['b'] ], // new array in spec + [ 'baz.bar', 'c'], //overwrite 'a' + [ 'baz.baz.baz', 'a'], // new property + [ 'bar', { foo: 'baz' }] // replace string by object + ] + }; + + var ref = { + foo: { + arr1: [ + { name: 'i2', a: 'b' }, + { name: 'foo', a: 'c'} + ], + arr2: [ + 'item2', { name: 'foo' } + ] + }, + arr3: [ 'a' ], + baz: { + bar: 'c', + baz: { baz: 'a' } + }, + bar: { foo: 'baz' }, + arr4: ['b'] + }; + + sm.mod(spec, diff); + + deepEqual(spec, ref, 'Complex Modification'); + + spec = { + a: [ 'a1', 'a2', 'a3' ] + }; + var rules = [[ 'a', 'new', 1]]; + sm.add(spec, rules); + + deepEqual(spec, { a: ['a1', 'new', 'a2', 'a3'] }, 'Add on position'); +}); + + + +};});
\ No newline at end of file diff --git a/install/ui/test/index.html b/install/ui/test/index.html index 0a135188e..948f9a448 100644 --- a/install/ui/test/index.html +++ b/install/ui/test/index.html @@ -35,6 +35,7 @@ <li><a href="widget_tests.html">Widget Test Suite</a> <li><a href="ip_tests.html">IP Addresses Test Suite</a> <li><a href="utils_tests.html">Utils Test Suite</a> + <li><a href="build_tests.html">Build Test Suite</a> </ul> </div> diff --git a/install/ui/test/jsl.conf b/install/ui/test/jsl.conf index 94ac10c50..ba5bb2079 100644 --- a/install/ui/test/jsl.conf +++ b/install/ui/test/jsl.conf @@ -148,4 +148,5 @@ +process ordered_map_tests.js +process widget_tests.js +process ip_tests.js -+process utils_tests.js
\ No newline at end of file ++process utils_tests.js ++process build_tests.js
\ No newline at end of file |