Skip to content

Commit 551ad2f

Browse files
committed
Add testing of unsubscribe
1 parent b6c597f commit 551ad2f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ t('subscribe', { timeout: 2 }, async() => {
17121712

17131713
const result = []
17141714

1715-
await sql.subscribe('*', (row, { command, old }) =>
1715+
const { unsubscribe } = await sql.subscribe('*', (row, { command, old }) =>
17161716
result.push(command, row.name || row.id, old && old.name)
17171717
)
17181718

@@ -1723,6 +1723,7 @@ t('subscribe', { timeout: 2 }, async() => {
17231723
)
17241724
`
17251725

1726+
await sql`alter table test replica identity default`
17261727
await sql`insert into test (name) values ('Murray')`
17271728
await sql`update test set name = 'Rothbard'`
17281729
await sql`delete from test`
@@ -1731,6 +1732,9 @@ t('subscribe', { timeout: 2 }, async() => {
17311732
await sql`update test set name = 'Rothbard'`
17321733
await sql`delete from test`
17331734
await delay(100)
1735+
await unsubscribe()
1736+
await sql`insert into test (name) values ('Oh noes')`
1737+
await delay(100)
17341738
return [
17351739
'insert,Murray,,update,Rothbard,,delete,1,,insert,Murray,,update,Rothbard,Murray,delete,Rothbard,',
17361740
result.join(','),

0 commit comments

Comments
 (0)