11import { ApplicationSettings as appSettings } from '@nativescript/core' ;
22import * as TKUnit from '../tk-unit' ;
33
4- var stringKey : string = 'stringKey' ;
5- var boolKey : string = 'boolKey' ;
6- var numberKey : string = 'numberKey' ;
7- var noStringKey : string = 'noStringKey' ;
8- var noBoolKey : string = 'noBoolKey' ;
9- var noNumberKey : string = 'noNumberKey' ;
10-
11- export var testBoolean = function ( ) {
4+ const stringKey : string = 'stringKey' ;
5+ const boolKey : string = 'boolKey' ;
6+ const numberKey : string = 'numberKey' ;
7+ const noStringKey : string = 'noStringKey' ;
8+ const noBoolKey : string = 'noBoolKey' ;
9+ const noNumberKey : string = 'noNumberKey' ;
10+
11+ export const testBoolean = function ( ) {
1212 appSettings . setBoolean ( boolKey , false ) ;
13- var boolValueBefore = appSettings . getBoolean ( boolKey ) ;
13+ const boolValueBefore = appSettings . getBoolean ( boolKey ) ;
1414 TKUnit . assert ( false === boolValueBefore , 'Cannot set boolean to false, currently it is: ' + appSettings . getBoolean ( boolKey ) ) ;
1515
1616 appSettings . setBoolean ( 'boolKey' , true ) ;
17- var boolValue = appSettings . getBoolean ( 'boolKey' , false ) ;
17+ const boolValue = appSettings . getBoolean ( 'boolKey' , false ) ;
1818
1919 TKUnit . assert ( true === boolValue , 'Cannot set boolean to true' ) ;
2020
2121 TKUnit . assert ( true === appSettings . getBoolean ( boolKey ) , 'Cannot set boolean to true (no default)' ) ;
2222} ;
2323
24- export var testString = function ( ) {
24+ export const testString = function ( ) {
2525 appSettings . setString ( 'stringKey' , 'String value' ) ;
26- var stringValue = appSettings . getString ( 'stringKey' ) ;
26+ const stringValue = appSettings . getString ( 'stringKey' ) ;
2727
2828 TKUnit . assert ( 'String value' === stringValue , 'Cannot set string value' ) ;
2929} ;
3030
31- export var testNumber = function ( ) {
31+ export const testNumber = function ( ) {
3232 appSettings . setNumber ( 'numberKey' , 54.321 ) ;
33- var value = parseFloat ( appSettings . getNumber ( 'numberKey' ) . toFixed ( 3 ) ) ;
33+ const value = parseFloat ( appSettings . getNumber ( 'numberKey' ) . toFixed ( 3 ) ) ;
3434
3535 TKUnit . assert ( 54.321 === value , 'Cannot set number value 54.321 != ' + value ) ;
3636} ;
3737
38- export var testDefaults = function ( ) {
39- var defaultValue = appSettings . getString ( 'noStringKey' , 'No string value' ) ;
38+ export const testDefaults = function ( ) {
39+ const defaultValue = appSettings . getString ( 'noStringKey' , 'No string value' ) ;
4040 // will return "No string value" if there is no value for "noStringKey"
4141
4242 TKUnit . assert ( 'No string value' === defaultValue , 'Bad default string value' ) ;
4343 TKUnit . assert ( true === appSettings . getBoolean ( noBoolKey , true ) , 'Bad default boolean value' ) ;
4444 TKUnit . assert ( 123.45 === appSettings . getNumber ( noNumberKey , 123.45 ) , 'Bad default number value' ) ;
4545} ;
4646
47- export var testDefaultsWithNoDefaultValueProvided = function ( ) {
48- var defaultValue = appSettings . getString ( 'noStringKey' ) ;
47+ export const testDefaultsWithNoDefaultValueProvided = function ( ) {
48+ const defaultValue = appSettings . getString ( 'noStringKey' ) ;
4949 // will return undefined if there is no value for "noStringKey"
5050
5151 TKUnit . assertEqual ( defaultValue , undefined , 'Default string value is not undefined' ) ;
@@ -54,8 +54,8 @@ export var testDefaultsWithNoDefaultValueProvided = function () {
5454 TKUnit . assertEqual ( appSettings . getNumber ( noNumberKey ) , undefined , 'Default number value is not undefined' ) ;
5555} ;
5656
57- export var testHasKey = function ( ) {
58- var hasKey = appSettings . hasKey ( 'noBoolKey' ) ;
57+ export const testHasKey = function ( ) {
58+ const hasKey = appSettings . hasKey ( 'noBoolKey' ) ;
5959 // will return false if there is no value for "noBoolKey"
6060
6161 TKUnit . assert ( ! hasKey , 'There is a key: ' + noBoolKey ) ;
@@ -67,7 +67,7 @@ export var testHasKey = function () {
6767 TKUnit . assert ( ! appSettings . hasKey ( numberKey ) , 'There is no key: ' + numberKey ) ;
6868} ;
6969
70- export var testRemove = function ( ) {
70+ export const testRemove = function ( ) {
7171 appSettings . remove ( 'boolKey' ) ;
7272
7373 TKUnit . assert ( ! appSettings . hasKey ( boolKey ) , 'Failed to remove key: ' + boolKey ) ;
@@ -79,36 +79,36 @@ export var testRemove = function () {
7979 TKUnit . assert ( ! appSettings . hasKey ( numberKey ) , 'Failed to remove key: ' + numberKey ) ;
8080} ;
8181
82- export var testClear = function ( ) {
82+ export const testClear = function ( ) {
8383 appSettings . clear ( ) ;
8484
8585 TKUnit . assert ( ! appSettings . hasKey ( boolKey ) , 'Failed to remove key: ' + boolKey ) ;
8686 TKUnit . assert ( ! appSettings . hasKey ( stringKey ) , 'Failed to remove key: ' + stringKey ) ;
8787 TKUnit . assert ( ! appSettings . hasKey ( numberKey ) , 'Failed to remove key: ' + numberKey ) ;
8888} ;
8989
90- export var testFlush = function ( ) {
90+ export const testFlush = function ( ) {
9191 appSettings . setString ( stringKey , 'String value' ) ;
9292
93- var flushed = appSettings . flush ( ) ;
93+ const flushed = appSettings . flush ( ) ;
9494 // will return boolean indicating whether flush to disk was successful
9595
9696 TKUnit . assert ( flushed , 'Flush failed: ' + flushed ) ;
9797 TKUnit . assert ( appSettings . hasKey ( stringKey ) , 'There is no key: ' + stringKey ) ;
9898} ;
9999
100- export var testAllKeys = function ( ) {
100+ export const testAllKeys = function ( ) {
101101 appSettings . setString ( stringKey , 'String value' ) ;
102102 appSettings . setBoolean ( boolKey , true ) ;
103103 appSettings . setNumber ( numberKey , 22 ) ;
104104
105- var allKeys = appSettings . getAllKeys ( ) ;
105+ const allKeys = appSettings . getAllKeys ( ) ;
106106 TKUnit . assert ( allKeys . indexOf ( stringKey ) !== - 1 , `${ stringKey } is missing from .allKeys()` ) ;
107107 TKUnit . assert ( allKeys . indexOf ( boolKey ) !== - 1 , `${ boolKey } is missing from .allKeys()` ) ;
108108 TKUnit . assert ( allKeys . indexOf ( numberKey ) !== - 1 , `${ numberKey } is missing from .allKeys()` ) ;
109109} ;
110110
111- export var testInvalidKey = function ( ) {
111+ export const testInvalidKey = function ( ) {
112112 try {
113113 appSettings . hasKey ( undefined ) ;
114114 TKUnit . assert ( false , 'There is a key undefined' ) ;
@@ -134,7 +134,7 @@ export var testInvalidKey = function () {
134134 appSettings . hasKey ( 'string' ) ;
135135} ;
136136
137- export var testInvalidValue = function ( ) {
137+ export const testInvalidValue = function ( ) {
138138 try {
139139 // @ts -ignore
140140 appSettings . setBoolean ( boolKey , 'str' ) ;
0 commit comments