Skip to content

Commit

Permalink
Used await for readFileSync
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed May 29, 2020
1 parent 7f2933d commit 4b31030
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions tests/acceptance/stepDefinitions/generalContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,39 +84,36 @@ Then('no message should be displayed on the webUI', function() {
return client.page.phoenixPage().expect.element('@message').to.not.be.present
})

Then('as {string} the content of {string} should be the same as the local {string}', function(
Then('as {string} the content of {string} should be the same as the local {string}', async function(
userId,
remoteFile,
localFile
) {
const fullPathOfLocalFile = client.globals.filesForUpload + localFile
return webdavHelper
.download(userId, remoteFile)
.then(body => assertContentOFLocalFileIs(fullPathOfLocalFile, body))
const body = await webdavHelper.download(userId, remoteFile)
return assertContentOFLocalFileIs(fullPathOfLocalFile, body)
})

Then('as {string} the content of {string} should not be the same as the local {string}', function(
userId,
remoteFile,
localFile
) {
const fullPathOfLocalFile = client.globals.filesForUpload + localFile
return webdavHelper
.download(userId, remoteFile)
.then(body => assertContentOFLocalFileIsNot(fullPathOfLocalFile, body))
})
Then(
'as {string} the content of {string} should not be the same as the local {string}',
async function(userId, remoteFile, localFile) {
const fullPathOfLocalFile = client.globals.filesForUpload + localFile
const body = await webdavHelper.download(userId, remoteFile)
return assertContentOFLocalFileIsNot(fullPathOfLocalFile, body)
}
)

const assertContentOFLocalFileIs = function(fullPathOflocalFile, expectedContent) {
const actualContent = fs.readFileSync(fullPathOflocalFile, { encoding: 'utf-8' })
const assertContentOFLocalFileIs = async function(fullPathOflocalFile, expectedContent) {
const actualContent = await fs.readFileSync(fullPathOflocalFile, { encoding: 'utf-8' })
return client.assert.strictEqual(
actualContent,
expectedContent,
'asserting content of local file "' + fullPathOflocalFile + '"'
)
}

const assertContentOFLocalFileIsNot = function(fullPathOflocalFile, expectedContent) {
const actualContent = fs.readFileSync(fullPathOflocalFile, { encoding: 'utf-8' })
const assertContentOFLocalFileIsNot = async function(fullPathOflocalFile, expectedContent) {
const actualContent = await fs.readFileSync(fullPathOflocalFile, { encoding: 'utf-8' })
return client.assert.notEqual(
actualContent,
expectedContent,
Expand Down

0 comments on commit 4b31030

Please sign in to comment.