@@ -831,18 +831,6 @@ suite('session extension', () => {
831831 } ) ;
832832 } ) ;
833833
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-
846834 test ( 'setting options.table causes only one table to be tracked' , ( t ) => {
847835 const database1 = new DatabaseSync ( ':memory:' ) ;
848836 const database2 = new DatabaseSync ( ':memory:' ) ;
@@ -974,9 +962,9 @@ suite('session extension', () => {
974962 const data1Rows = database2 . prepare ( 'SELECT * FROM data1' ) . all ( ) ;
975963 const data2Rows = database2 . prepare ( 'SELECT * FROM data2' ) . all ( ) ;
976964
977- // Expect no rows since all changes where filtered out
965+ // Expect no rows since all changes were filtered out
978966 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
980968 t . assert . strictEqual ( data2Rows . length , 5 ) ;
981969 } ) ;
982970
@@ -997,8 +985,24 @@ suite('session extension', () => {
997985 t . assert . strictEqual ( sessionTest . changeset ( ) . length , 0 ) ;
998986 } ) ;
999987
1000- test ( 'wrong argument name of other database' , ( t ) => {
988+ test ( 'wrong arguments database.createSession() ' , ( t ) => {
1001989 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+
10021006 t . assert . throws ( ( ) => {
10031007 database . createSession ( {
10041008 db : 123
@@ -1009,6 +1013,42 @@ suite('session extension', () => {
10091013 } ) ;
10101014 } ) ;
10111015
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 a number.'
1049+ } ) ;
1050+ } ) ;
1051+
10121052 test ( 'generate patchset' , ( t ) => {
10131053 const database = new DatabaseSync ( ':memory:' ) ;
10141054 database . exec ( 'CREATE TABLE data(key INTEGER PRIMARY KEY, value TEXT)' ) ;
0 commit comments