Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MathijsVerbeeck committed Jul 25, 2023
1 parent 6d4e885 commit 15b568e
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe(commands.LISTITEM_ATTACHMENT_ADD, () => {
});

it('adds attachment to listitem in list retrieved by id while specifying fileName', async () => {
sinon.stub(fs, 'existsSync').returns(true);
sinon.stub(request, 'post').callsFake(async (args) => {
if (args.url === `${webUrl}/_api/web/lists(guid'${listId}')/items(${listItemId})/AttachmentFiles/add(FileName='${fileName}')`) {
return response;
Expand All @@ -128,6 +129,7 @@ describe(commands.LISTITEM_ATTACHMENT_ADD, () => {
});

it('adds attachment to listitem in list retrieved by url while not specifying fileName', async () => {
sinon.stub(fs, 'existsSync').returns(true);
sinon.stub(request, 'post').callsFake(async (args) => {
if (args.url === `${webUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')/items(${listItemId})/AttachmentFiles/add(FileName='${filePath.replace(/^.*[\\\/]/, '')}')`) {
return response;
Expand All @@ -141,6 +143,7 @@ describe(commands.LISTITEM_ATTACHMENT_ADD, () => {
});

it('adds attachment to listitem in list retrieved by url while specifying fileName without extension', async () => {
sinon.stub(fs, 'existsSync').returns(true);
const fileNameWithoutExtension = fileName.split('.')[0];
const fileNameWithExtension = `${fileNameWithoutExtension}.${filePath.split('.').pop()}`;
sinon.stub(request, 'post').callsFake(async (args) => {
Expand All @@ -156,6 +159,7 @@ describe(commands.LISTITEM_ATTACHMENT_ADD, () => {
});

it('handles error when file with specific name already exists', async () => {
sinon.stub(fs, 'existsSync').returns(true);
const error = {
error: {
'odata.error': {
Expand Down

0 comments on commit 15b568e

Please sign in to comment.