Skip to content

Instantly share code, notes, and snippets.

@MCarlomagno
Created April 14, 2022 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MCarlomagno/434564499b2a7ea3a4640d3005544155 to your computer and use it in GitHub Desktop.
Save MCarlomagno/434564499b2a7ea3a4640d3005544155 to your computer and use it in GitHub Desktop.
it("uploads a valid file", async () => {
// checks filecount variable
// before uploading the file
const countBeforeUpload = await this.contract.fileCount();
await this.contract.uploadFile('path', 1, 'type', 'name');
// checks filecount increased
// by one after upload
const countAfterUpload = await this.contract.fileCount();
assert.equal(Number(countAfterUpload), Number(countBeforeUpload) + 1, "count increased to 1 after upload")
// checks last file contains the same
// info than the uploaded file
const lastFile = await this.contract.files(countAfterUpload);
assert.equal(lastFile.fileName, 'name', "last file has the filename of the previous uploaded file")
assert.equal(lastFile.filePath, 'path', "last file has the path of the previous uploaded file")
assert.equal(lastFile.fileSize, 1, "last file has the size of the previous uploaded file")
assert.equal(lastFile.fileType, 'type', "last file has the type of the previous uploaded file")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment