summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-02-04 12:21:13 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2014-02-04 12:21:13 -0800
commitced80c6f2743d886143b499013e900f83c6c2b84 (patch)
tree07a77fc7436a58861058db4236d1b78a18fe5fce /core/js
parent6d3b61f3884d6cf7b2eb68cdd60c713620afabbd (diff)
parent63cca35baa14727cdf71f2b109523c28d16f1c58 (diff)
downloadnextcloud-server-ced80c6f2743d886143b499013e900f83c6c2b84.tar.gz
nextcloud-server-ced80c6f2743d886143b499013e900f83c6c2b84.zip
Merge pull request #6969 from owncloud/tests-morecoverage
Fixed unit test scripts + coverage
Diffstat (limited to 'core/js')
-rw-r--r--core/js/core.json43
-rw-r--r--core/js/tests/specs/coreSpec.js99
2 files changed, 118 insertions, 24 deletions
diff --git a/core/js/core.json b/core/js/core.json
index 79cfc42f587..4beab7cf796 100644
--- a/core/js/core.json
+++ b/core/js/core.json
@@ -1,28 +1,23 @@
{
+ "libraries": [
+ "jquery-1.10.0.min.js",
+ "jquery-migrate-1.2.1.min.js",
+ "jquery-ui-1.10.0.custom.js",
+ "jquery-showpassword.js",
+ "jquery.infieldlabel.js",
+ "jquery.placeholder.js",
+ "jquery-tipsy.js"
+ ],
"modules": [
- "jquery-1.10.0.min.js",
- "jquery-migrate-1.2.1.min.js",
- "jquery-ui-1.10.0.custom.js",
- "jquery-showpassword.js",
- "jquery.infieldlabel.js",
- "jquery.placeholder.js",
- "jquery-tipsy.js",
- "compatibility.js",
- "jquery.ocdialog.js",
- "oc-dialogs.js",
- "js.js",
- "octemplate.js",
- "eventsource.js",
- "config.js",
- "multiselect.js",
- "search.js",
- "router.js",
- "oc-requesttoken.js",
- "styles.js",
- "apps.js",
- "fixes.js",
- "jquery-ui-2.10.0.custom.js",
- "jquery-tipsy.js",
- "jquery.ocdialog.js"
+ "compatibility.js",
+ "jquery.ocdialog.js",
+ "oc-dialogs.js",
+ "js.js",
+ "octemplate.js",
+ "eventsource.js",
+ "config.js",
+ "multiselect.js",
+ "router.js",
+ "oc-requesttoken.js"
]
}
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index 28c20a0642e..85fae7567b3 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -18,6 +18,8 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
+/* global OC */
describe('Core base tests', function() {
describe('Base values', function() {
it('Sets webroots', function() {
@@ -25,6 +27,103 @@ describe('Core base tests', function() {
expect(OC.appswebroots).toBeDefined();
});
});
+ describe('basename', function() {
+ it('Returns the nothing if no file name given', function() {
+ expect(OC.basename('')).toEqual('');
+ });
+ it('Returns the nothing if dir is root', function() {
+ expect(OC.basename('/')).toEqual('');
+ });
+ it('Returns the same name if no path given', function() {
+ expect(OC.basename('some name.txt')).toEqual('some name.txt');
+ });
+ it('Returns the base name if root path given', function() {
+ expect(OC.basename('/some name.txt')).toEqual('some name.txt');
+ });
+ it('Returns the base name if double root path given', function() {
+ expect(OC.basename('//some name.txt')).toEqual('some name.txt');
+ });
+ it('Returns the base name if subdir given without root', function() {
+ expect(OC.basename('subdir/some name.txt')).toEqual('some name.txt');
+ });
+ it('Returns the base name if subdir given with root', function() {
+ expect(OC.basename('/subdir/some name.txt')).toEqual('some name.txt');
+ });
+ it('Returns the base name if subdir given with double root', function() {
+ expect(OC.basename('//subdir/some name.txt')).toEqual('some name.txt');
+ });
+ it('Returns the base name if subdir has dot', function() {
+ expect(OC.basename('/subdir.dat/some name.txt')).toEqual('some name.txt');
+ });
+ it('Returns dot if file name is dot', function() {
+ expect(OC.basename('/subdir/.')).toEqual('.');
+ });
+ // TODO: fix the source to make it work like PHP's basename
+ it('Returns the dir itself if no file name given', function() {
+ // TODO: fix the source to make it work like PHP's dirname
+ // expect(OC.basename('subdir/')).toEqual('subdir');
+ expect(OC.basename('subdir/')).toEqual('');
+ });
+ it('Returns the dir itself if no file name given with root', function() {
+ // TODO: fix the source to make it work like PHP's dirname
+ // expect(OC.basename('/subdir/')).toEqual('subdir');
+ expect(OC.basename('/subdir/')).toEqual('');
+ });
+ });
+ describe('dirname', function() {
+ it('Returns the nothing if no file name given', function() {
+ expect(OC.dirname('')).toEqual('');
+ });
+ it('Returns the root if dir is root', function() {
+ // TODO: fix the source to make it work like PHP's dirname
+ // expect(OC.dirname('/')).toEqual('/');
+ expect(OC.dirname('/')).toEqual('');
+ });
+ it('Returns the root if dir is double root', function() {
+ // TODO: fix the source to make it work like PHP's dirname
+ // expect(OC.dirname('//')).toEqual('/');
+ expect(OC.dirname('//')).toEqual('/'); // oh no...
+ });
+ it('Returns dot if dir is dot', function() {
+ expect(OC.dirname('.')).toEqual('.');
+ });
+ it('Returns dot if no root given', function() {
+ // TODO: fix the source to make it work like PHP's dirname
+ // expect(OC.dirname('some dir')).toEqual('.');
+ expect(OC.dirname('some dir')).toEqual('some dir'); // oh no...
+ });
+ it('Returns the dir name if file name and root path given', function() {
+ // TODO: fix the source to make it work like PHP's dirname
+ // expect(OC.dirname('/some name.txt')).toEqual('/');
+ expect(OC.dirname('/some name.txt')).toEqual('');
+ });
+ it('Returns the dir name if double root path given', function() {
+ expect(OC.dirname('//some name.txt')).toEqual('/'); // how lucky...
+ });
+ it('Returns the dir name if subdir given without root', function() {
+ expect(OC.dirname('subdir/some name.txt')).toEqual('subdir');
+ });
+ it('Returns the dir name if subdir given with root', function() {
+ expect(OC.dirname('/subdir/some name.txt')).toEqual('/subdir');
+ });
+ it('Returns the dir name if subdir given with double root', function() {
+ // TODO: fix the source to make it work like PHP's dirname
+ // expect(OC.dirname('//subdir/some name.txt')).toEqual('/subdir');
+ expect(OC.dirname('//subdir/some name.txt')).toEqual('//subdir'); // oh...
+ });
+ it('Returns the dir name if subdir has dot', function() {
+ expect(OC.dirname('/subdir.dat/some name.txt')).toEqual('/subdir.dat');
+ });
+ it('Returns the dir name if file name is dot', function() {
+ expect(OC.dirname('/subdir/.')).toEqual('/subdir');
+ });
+ it('Returns the dir name if no file name given', function() {
+ expect(OC.dirname('subdir/')).toEqual('subdir');
+ });
+ it('Returns the dir name if no file name given with root', function() {
+ expect(OC.dirname('/subdir/')).toEqual('/subdir');
+ });
+ });
describe('Link functions', function() {
var TESTAPP = 'testapp';
var TESTAPP_ROOT = OC.webroot + '/appsx/testapp';