aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJyoti Deka <dekajp@gmail.com>2015-07-06 07:18:57 -0400
committerJörn Zaefferer <joern.zaefferer@gmail.com>2015-10-17 16:08:29 -0400
commit4c5cd2018d88392871cfc93d3fb6f71a0bc510ff (patch)
tree77394aa56c8c3e5772af9589e427ee0f792ea41d
parent1007ee811cea93485bc2a60435ec1bf2a728f129 (diff)
downloadjquery-ui-4c5cd2018d88392871cfc93d3fb6f71a0bc510ff.tar.gz
jquery-ui-4c5cd2018d88392871cfc93d3fb6f71a0bc510ff.zip
Slider: Add missing unit test cases for values method
Closes gh-1573
-rw-r--r--tests/unit/slider/methods.js52
1 files changed, 49 insertions, 3 deletions
diff --git a/tests/unit/slider/methods.js b/tests/unit/slider/methods.js
index 15b2e8726..5c0cbb7bd 100644
--- a/tests/unit/slider/methods.js
+++ b/tests/unit/slider/methods.js
@@ -111,8 +111,54 @@ test( "value", function() {
equal( element.slider( "value" ), 460, "value is restricted to maximum valid step" );
} );
-//test( "values", function() {
-// ok(false, "missing test - untested code is broken code." );
-//});
+test( "values, single step", function() {
+ expect( 8 );
+
+ var element = $( "<div></div>" ).slider( {
+ range: false,
+ min: 10,
+ max: 100,
+ step: 1,
+ values: [ 20 ]
+ } );
+
+ deepEqual( element.slider( "values" ), [ 20 ], "range: false, values - get value for handle" );
+ equal( element.slider( "values", 0 ), 20, "values (index) - get value of handle" );
+
+ element.slider( "values", 0, 5 );
+ equal( element.slider( "values", 0 ), 10, "values (index) - restrict against min" );
+
+ element.slider( "values", 0, 110 );
+ equal( element.slider( "values", 0 ), 100, "values (index) - restrict against max" );
+
+ element.slider( "option", "range", true );
+ element.slider( "values", [ 20, 90 ] );
+
+ deepEqual( element.slider( "values" ), [ 20, 90 ], "range: true, values - get value for all handles" );
+ equal( element.slider( "values", 0 ), 20, "values (index) - 1st handle" );
+ equal( element.slider( "values", 1 ), 90, "values (index) - 2nd handle" );
+
+ element.slider( "values", [ 5, 110 ] );
+ deepEqual( element.slider( "values" ), [ 10, 100 ], "values - restricted against min and max" );
+ element.slider( "destroy" );
+} );
+
+test( "values, multi step", function() {
+ expect( 2 );
+
+ var element = $( "<div></div>" ).slider( {
+ range: false,
+ min: 9,
+ max: 20,
+ step: 3,
+ values: [ 9, 12 ]
+ } );
+ deepEqual( element.slider( "values" ), [ 9, 12 ], "values - evenly divisible by step" );
+
+ element.slider( "values", [ 10, 20 ] );
+ deepEqual( element.slider( "values" ), [ 9, 18 ], "values - not evenly divisible by step" );
+
+ element.slider( "destroy" );
+} );
} );
ate-code-signing-crl'>automated/noid/stable23-update-code-signing-crl Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller/SettingsController.php
blob: 00d627095b826003d0cca8ebae332ef28fdb045b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

declare(strict_types=1);

/**
 * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
 *
 * @author Roeland Jago Douma <roeland@famdouma.nl>
 * @author Hinrich Mahler <nextcloud@mahlerhome.de>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
namespace OCA\Files_Sharing\Controller;

use OCA\Files_Sharing\AppInfo\Application;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IConfig;
use OCP\IRequest;

class SettingsController extends Controller {

	/** @var IConfig */
	private $config;

	/** @var string */
	private $userId;

	public function __construct(IRequest $request,
								IConfig $config,
								string $userId) {
		parent::__construct(Application::APP_ID, $request);

		$this->config = $config;
		$this->userId = $userId;
	}

	/**
	 * @NoAdminRequired
	 */
	public function setDefaultAccept(bool $accept): JSONResponse {
		$this->config->setUserValue($this->userId, Application::APP_ID, 'default_accept', $accept ? 'yes' : 'no');
		return new JSONResponse();
	}

	/**
	 * @NoAdminRequired
	 */
	public function setUserShareFolder(string $shareFolder): JSONResponse {
		$this->config->setUserValue($this->userId, Application::APP_ID, 'share_folder', $shareFolder);
		return new JSONResponse();
	}

	/**
	 * @NoAdminRequired
	 */
	public function resetUserShareFolder(): JSONResponse {
		$this->config->deleteUserValue($this->userId, Application::APP_ID, 'share_folder');
		return new JSONResponse();
	}
}