Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit 2314ee4

Browse files
committed
Update tests for NULL tests
1 parent 06f862f commit 2314ee4

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed

demo/app/main-page.js

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,66 @@ function setupPreparedTests(callback) {
525525
});
526526
}
527527

528+
function runExtraTests(callback) {
529+
console.log("!--------- Extra Tests");
530+
data.push({name: "-----------------------------", css: 'two'});
531+
532+
db.execSQL('drop table if exists extratests;', function (err) {
533+
if (err) {
534+
console.log("!---- Drop Err", err);
535+
}
536+
db.execSQL('create table extratests (`int_field` integer, `num_field` numeric, `real_field` real, `text_field` text, `blob_field` blob)', function (err) {
537+
if (err) {
538+
data.push({name: 'Failed to create tables and data...', css: 'one'});
539+
console.log("!---- Create Table err", err);
540+
return;
541+
}
542+
543+
// Add value
544+
db.execSQL('insert into extratests values (1, 2, 3, "4", "5")')
545+
.then( () => {
546+
// Verify Value
547+
return db.get('select * from extratests').then((val) => {
548+
if (val.int_field === 1 && val.num_field === 2) {
549+
return Promise.resolve();
550+
} else {
551+
return Promise.reject("Data doesn't match");
552+
}
553+
});
554+
})
555+
// Update Value to null
556+
.then( () => { return db.execSQL("update extratests set num_field=null where int_field=1"); })
557+
.then( () => {
558+
// Verify Value
559+
return db.get('select * from extratests').then((val) => {
560+
if (val.int_field === 1 && val.num_field !== null) {
561+
return Promise.reject("Failed direct null")
562+
}
563+
});
564+
})
565+
.then( () => { return db.execSQL("update extratests set real_field=? where int_field=1", [null]); })
566+
.then( () => {
567+
// Verify Value
568+
return db.get('select * from extratests').then((val) => {
569+
if (val.int_field === 1 && val.real_field !== null) {
570+
return Promise.reject("Failed param as null")
571+
}
572+
data.push({name: 'Passed: Extra Tests...', 'css': 'two'});
573+
callback()
574+
});
575+
})
576+
.catch((err) => {
577+
data.push({name: 'Failed: Extra Tests...'+err, 'css': 'one'});
578+
console.log("!---------- Extra err", err, err.stack);
579+
callback();
580+
})
581+
582+
});
583+
});
584+
585+
586+
}
587+
528588
function runPreparedTests(callback) {
529589
if (!sqlite.HAS_COMMERCIAL) {
530590
callback();
@@ -612,10 +672,12 @@ function runTests() {
612672
runStringArrayTest(function () {
613673
runStringObjectTest(function () {
614674
runPreparedTests(function () {
615-
data.push({name: "-----------------------------", css: 'two'});
616-
data.push({name: 'Tests completed...', css: 'two'});
617-
console.log("-----------------------------");
618-
console.log("Tests completed!");
675+
runExtraTests( function() {
676+
data.push({name: "-----------------------------", css: 'two'});
677+
data.push({name: 'Tests completed...', css: 'two'});
678+
console.log("-----------------------------");
679+
console.log("Tests completed!");
680+
})
619681
});
620682
});
621683
});

demo/app/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</Repeater>
1212
</ScrollView>
1313
<GridLayout row="1" rows="*,auto" columns="*,auto" class="border" >
14-
<TextField class="entry" id="entry" hint="Type a new name" text=""/>
14+
<TextField class="entry" id="entry" hint="Type a new name" text="" returnPress="addNewName"/>
1515
<Button id="go" col="1" text="Add" tap="addNewName"/>
1616
<Label row="1" colSpan="2" text="(c) 2015-2021, Master Technology" class="copyright" android:tap="openMT"/>
1717
</GridLayout>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy