From 78d04104008a14f410bcf3ee7b15ae928f085fb1 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 9 Nov 2021 12:56:47 -0500 Subject: [PATCH] test: migration from Python to JavaScript --- Tests/lib/ManageSieve.js | 10 +++++----- Tests/spec/CalDAVPreventInvitationsSpec.js | 13 ++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Tests/lib/ManageSieve.js b/Tests/lib/ManageSieve.js index 006fd8037..4becf94da 100644 --- a/Tests/lib/ManageSieve.js +++ b/Tests/lib/ManageSieve.js @@ -10,7 +10,7 @@ class ManageSieve { this.params = { host: config.sieve_server, port: config.sieve_port, - shellPrompt: /\bOK "/, + shellPrompt: /\bOK/, timeout: 1500 } this.connection = new Telnet() @@ -23,7 +23,7 @@ class ManageSieve { if (!this.ready) { await this.connection.connect(this.params) - response = await this.connection.send('CAPABILITY', { waitfor: /\b(OK|NO) "/ }) + response = await this.connection.send('CAPABILITY', { waitfor: /\b(OK|NO)/ }) // console.debug(`ManageSieve.connect => ${response}`) parsedResponse = this.parseResponse(response) if (!parsedResponse['OK']) { @@ -43,7 +43,7 @@ class ManageSieve { buff = Buffer.from(`${this.login}\0${this.authname}\0${this.password}`) base64 = buff.toString('base64') - response = await this.connection.send(`AUTHENTICATE "PLAIN" {${base64.length}+}\n${base64}`, { waitfor: /\b(OK|NO) "/ }) + response = await this.connection.send(`AUTHENTICATE "PLAIN" {${base64.length}+}\n${base64}`, { waitfor: /\b(OK|NO)/ }) // console.debug(`ManageSieve.authenticate => ${response}`) parsedResponse = this.parseResponse(response) if (!parsedResponse['OK']) { @@ -56,7 +56,7 @@ class ManageSieve { await this.connect() - response = await this.connection.send(`LISTSCRIPTS`, { waitfor: /\b(OK|NO) "/ }) + response = await this.connection.send(`LISTSCRIPTS`, { waitfor: /\b(OK|NO)/ }) parsedResponse = this.parseResponse(response) // console.debug(`ManageSieve.listScripts => ${JSON.stringify(parsedResponse, undefined, 2)}`) if (!parsedResponse['OK']) { @@ -70,7 +70,7 @@ class ManageSieve { await this.connect() - response = await this.connection.send(`GETSCRIPT "${scriptname}"`, { waitfor: /\b(OK|NO) "/ }) + response = await this.connection.send(`GETSCRIPT "${scriptname}"`, { waitfor: /\b(OK|NO)/ }) // console.debug(`ManageSieve.getScript(${scriptname}) => |${response}|`) const lengthMatch = response.match(/{([0-9]+)}\r?\n/) if (lengthMatch) { diff --git a/Tests/spec/CalDAVPreventInvitationsSpec.js b/Tests/spec/CalDAVPreventInvitationsSpec.js index fed79b117..f316ba4ea 100644 --- a/Tests/spec/CalDAVPreventInvitationsSpec.js +++ b/Tests/spec/CalDAVPreventInvitationsSpec.js @@ -107,17 +107,13 @@ describe('PreventInvitations', function() { }) beforeEach(async function() { - const calendarPrefs = prefs.get('Calendar') - if (!calendarPrefs.PreventInvitationsWhitelist) - calendarPrefs.PreventInvitationsWhitelist = {} - await prefs.set('PreventInvitationsWhitelist', {}) - if (!calendarPrefs.PreventInvitations) - calendarPrefs.PreventInvitations = 0 - await prefs.set('PreventInvitations', 0) + await prefs.setOrCreate('PreventInvitationsWhitelist', {}, ['settings', 'Calendar']) + await prefs.setOrCreate('PreventInvitations', 0, ['settings', 'Calendar']) + await prefs.save() }) afterAll(async function() { - await prefs.set('PreventInvitationsWhitelist', {}) + await prefs.setNoSave('PreventInvitationsWhitelist', {}) await prefs.set('PreventInvitations', 0) // delete all created events from all users' calendar for (const ics of icsList) { @@ -129,7 +125,6 @@ describe('PreventInvitations', function() { it(`Disable, accept the invitation`, async function() { // First accept the invitation - await prefs.set('PreventInvitations', 0) const settings = await prefs.getSettings() const { Calendar: { PreventInvitations } = {} } = settings expect(PreventInvitations)