From c78a099aae0f0e3cb9ffba3b3603502cfbdd78e1 Mon Sep 17 00:00:00 2001 From: Ivar Nakken Date: Fri, 20 Jan 2023 00:07:41 +0100 Subject: [PATCH] Format code according to Pretteir v2.8.3 --- client/controllers/showQRCtrl.js | 13 ++-- client/login.js | 13 ++-- features/step_definitions/electionSteps.js | 88 +++++++++++----------- features/support/hooks.js | 22 +++--- 4 files changed, 71 insertions(+), 65 deletions(-) diff --git a/client/controllers/showQRCtrl.js b/client/controllers/showQRCtrl.js index 405c8108..2b2dc966 100644 --- a/client/controllers/showQRCtrl.js +++ b/client/controllers/showQRCtrl.js @@ -20,12 +20,13 @@ module.exports = [ const cardKey = urlParams.get('cardKey'); const [, , code] = token.split(':'); const link = `${window.location.origin}/auth/login/?token=${token}`; - QRCode.toDataURL(link, { type: 'image/png', width: 1000 }, function ( - err, - url - ) { - $scope.qrdata = url; - }); + QRCode.toDataURL( + link, + { type: 'image/png', width: 1000 }, + function (err, url) { + $scope.qrdata = url; + } + ); socketIOService.listen('qr-opened', function (socketCode) { if (socketCode === code) { $scope.$apply(() => { diff --git a/client/login.js b/client/login.js index 8d4ba6be..dff9bd8f 100644 --- a/client/login.js +++ b/client/login.js @@ -54,12 +54,13 @@ if ('addEventListener' in document) { }; fetch('/api/qr/open/?code=' + code); - QRCode.toDataURL(url, { type: 'image/png', width: 300 }, function ( - err, - url - ) { - document.querySelector('[id=qrImg]').setAttribute('src', url); - }); + QRCode.toDataURL( + url, + { type: 'image/png', width: 300 }, + function (err, url) { + document.querySelector('[id=qrImg]').setAttribute('src', url); + } + ); } } catch (e) { alert('Det skjedde en feil. Prøv på nytt'); diff --git a/features/step_definitions/electionSteps.js b/features/step_definitions/electionSteps.js index 1a68f350..72bb72b6 100644 --- a/features/step_definitions/electionSteps.js +++ b/features/step_definitions/electionSteps.js @@ -14,24 +14,25 @@ by.addLocator( ); module.exports = function () { - this.Given(/^There is an active "([^"]*)" election$/, async function ( - electionType - ) { - this.normalElection.active = false; - await this.normalElection.save(); - this.stvElection.active = false; - await this.stvElection.save(); - - if (electionType === ElectionTypes.STV) { - this.election = this.stvElection; - } else if (electionType === ElectionTypes.NORMAL) { - this.election = this.normalElection; + this.Given( + /^There is an active "([^"]*)" election$/, + async function (electionType) { + this.normalElection.active = false; + await this.normalElection.save(); + this.stvElection.active = false; + await this.stvElection.save(); + + if (electionType === ElectionTypes.STV) { + this.election = this.stvElection; + } else if (electionType === ElectionTypes.NORMAL) { + this.election = this.normalElection; + } + this.election.active = true; + await this.election.save(); + const driver = browser.driver; + driver.get('http://localhost:3000/'); } - this.election.active = true; - await this.election.save(); - const driver = browser.driver; - driver.get('http://localhost:3000/'); - }); + ); this.Given(/^There is an inactive election$/, async function () { this.normalElection.active = false; @@ -153,24 +154,25 @@ module.exports = function () { ); }); - this.Then(/^I see "([^"]*)" as priority (\d+)$/, function ( - alternative, - position - ) { - const priorities = element.all(by.sortableListItems('priorities')); + this.Then( + /^I see "([^"]*)" as priority (\d+)$/, + function (alternative, position) { + const priorities = element.all(by.sortableListItems('priorities')); - return expect( - priorities.get(Number(position) - 1).getText() - ).to.eventually.contain(alternative.toUpperCase()); - }); + return expect( + priorities.get(Number(position) - 1).getText() + ).to.eventually.contain(alternative.toUpperCase()); + } + ); - this.Then(/^I have (\d+) alternative on the confirmation ballot$/, function ( - count - ) { - const priorities = element.all(by.repeater('alternative in priorities')); + this.Then( + /^I have (\d+) alternative on the confirmation ballot$/, + function (count) { + const priorities = element.all(by.repeater('alternative in priorities')); - return expect(priorities.count()).to.eventually.equal(Number(count)); - }); + return expect(priorities.count()).to.eventually.equal(Number(count)); + } + ); this.Then( /^I see "([^"]*)" as priority (\d+) on the confirmation ballot$/, @@ -183,16 +185,16 @@ module.exports = function () { } ); - this.Then(/^I see "([^"]*)" as priority (\d+) on the receipt$/, function ( - alternative, - position - ) { - const priorities = element.all( - by.repeater('alternative in vote.priorities') - ); + this.Then( + /^I see "([^"]*)" as priority (\d+) on the receipt$/, + function (alternative, position) { + const priorities = element.all( + by.repeater('alternative in vote.priorities') + ); - return expect( - priorities.get(Number(position) - 1).getText() - ).to.eventually.contain(alternative.toUpperCase()); - }); + return expect( + priorities.get(Number(position) - 1).getText() + ).to.eventually.contain(alternative.toUpperCase()); + } + ); }; diff --git a/features/support/hooks.js b/features/support/hooks.js index b2484587..f93712ec 100644 --- a/features/support/hooks.js +++ b/features/support/hooks.js @@ -68,17 +68,19 @@ module.exports = function () { mongoose.connection.on('connected', () => server(callback)); }); - this.registerHandler('AfterStep', ( - event, - callback // To make sure all tests run correctly we force - ) => - // waiting for Angular after each step. + this.registerHandler( + 'AfterStep', + ( + event, + callback // To make sure all tests run correctly we force + ) => + // waiting for Angular after each step. - browser.waitForAngular().then(callback, (err) => { - const message = err.message || err; - if (message.includes('window.angular')) callback(); - else callback(err); - }) + browser.waitForAngular().then(callback, (err) => { + const message = err.message || err; + if (message.includes('window.angular')) callback(); + else callback(err); + }) ); this.registerHandler('AfterFeatures', async (event, callback) => {