@@ -831,18 +831,6 @@ suite('session extension', () => {
831
831
} ) ;
832
832
} ) ;
833
833
834
- test ( 'set table with wrong type when creating session' , ( t ) => {
835
- const database = new DatabaseSync ( ':memory:' ) ;
836
- t . assert . throws ( ( ) => {
837
- database . createSession ( {
838
- table : true
839
- } ) ;
840
- } , {
841
- name : 'TypeError' ,
842
- message : 'The "options.table" argument must be a string.'
843
- } ) ;
844
- } ) ;
845
-
846
834
test ( 'setting options.table causes only one table to be tracked' , ( t ) => {
847
835
const database1 = new DatabaseSync ( ':memory:' ) ;
848
836
const database2 = new DatabaseSync ( ':memory:' ) ;
@@ -974,9 +962,9 @@ suite('session extension', () => {
974
962
const data1Rows = database2 . prepare ( 'SELECT * FROM data1' ) . all ( ) ;
975
963
const data2Rows = database2 . prepare ( 'SELECT * FROM data2' ) . all ( ) ;
976
964
977
- // Expect no rows since all changes where filtered out
965
+ // Expect no rows since all changes were filtered out
978
966
t . assert . strictEqual ( data1Rows . length , 0 ) ;
979
- // Expect 5 rows since these changes where not filtered out
967
+ // Expect 5 rows since these changes were not filtered out
980
968
t . assert . strictEqual ( data2Rows . length , 5 ) ;
981
969
} ) ;
982
970
@@ -997,8 +985,24 @@ suite('session extension', () => {
997
985
t . assert . strictEqual ( sessionTest . changeset ( ) . length , 0 ) ;
998
986
} ) ;
999
987
1000
- test ( 'wrong argument name of other database' , ( t ) => {
988
+ test ( 'wrong arguments database.createSession() ' , ( t ) => {
1001
989
const database = new DatabaseSync ( ':memory:' ) ;
990
+ t . assert . throws ( ( ) => {
991
+ database . createSession ( null ) ;
992
+ } , {
993
+ name : 'TypeError' ,
994
+ message : 'The "options" argument must be an object.'
995
+ } ) ;
996
+
997
+ t . assert . throws ( ( ) => {
998
+ database . createSession ( {
999
+ table : 123
1000
+ } ) ;
1001
+ } , {
1002
+ name : 'TypeError' ,
1003
+ message : 'The "options.table" argument must be a string.'
1004
+ } ) ;
1005
+
1002
1006
t . assert . throws ( ( ) => {
1003
1007
database . createSession ( {
1004
1008
db : 123
@@ -1009,6 +1013,42 @@ suite('session extension', () => {
1009
1013
} ) ;
1010
1014
} ) ;
1011
1015
1016
+ test ( 'wrong arguments database.applyChangeset()' , ( t ) => {
1017
+ const database = new DatabaseSync ( ':memory:' ) ;
1018
+ const session = database . createSession ( ) ;
1019
+ t . assert . throws ( ( ) => {
1020
+ database . applyChangeset ( null ) ;
1021
+ } , {
1022
+ name : 'TypeError' ,
1023
+ message : 'The "changeset" argument must be a Uint8Array.'
1024
+ } ) ;
1025
+
1026
+ t . assert . throws ( ( ) => {
1027
+ database . applyChangeset ( session . changeset ( ) , null ) ;
1028
+ } , {
1029
+ name : 'TypeError' ,
1030
+ message : 'The "options" argument must be an object.'
1031
+ } ) ;
1032
+
1033
+ t . assert . throws ( ( ) => {
1034
+ database . applyChangeset ( session . changeset ( ) , {
1035
+ filter : null
1036
+ } , null ) ;
1037
+ } , {
1038
+ name : 'TypeError' ,
1039
+ message : 'The "options.filter" argument must be a function.'
1040
+ } ) ;
1041
+
1042
+ t . assert . throws ( ( ) => {
1043
+ database . applyChangeset ( session . changeset ( ) , {
1044
+ onConflict : null
1045
+ } , null ) ;
1046
+ } , {
1047
+ name : 'TypeError' ,
1048
+ message : 'The "options.onConflict" argument must be an number.'
1049
+ } ) ;
1050
+ } ) ;
1051
+
1012
1052
test ( 'generate patchset' , ( t ) => {
1013
1053
const database = new DatabaseSync ( ':memory:' ) ;
1014
1054
database . exec ( 'CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)' ) ;
0 commit comments