Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodecleyre committed Jul 18, 2023
1 parent d1d97b4 commit 84006ac
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions src/utils/spo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,32 @@ describe('utils/spo', () => {
let log: string[];
let loggerLogSpy: sinon.SinonSpy;
const contentTypeResponse = {
value: [
{
Description: 'Create a new list item.',
DisplayFormTemplateName: 'ListForm',
DisplayFormUrl: '',
DocumentTemplate: '',
DocumentTemplateUrl: '',
EditFormTemplateName: 'ListForm',
EditFormUrl: '',
Group: 'PnP Content Types',
Hidden:
false,
Id: {
StringValue: '0x0100558D85B7216F6A489A499DB361E1AE2F'
},
JSLink: '',
MobileDisplayFormUrl: '',
MobileEditFormUrl: '',
MobileNewFormUrl: '',
Name: 'PnP Alert',
NewFormTemplateName: 'ListForm',
NewFormUrl: '',
ReadOnly: false,
SchemaXml:
'<ContentType ID=\'0x0100558D85B7216F6A489A499DB361E1AE2F\' Name=\'PnP Alert\' Group=\'PnP Content Types\' Description=\'Create a new list item.\' Version=\'1\'><Folder TargetName=\'_cts/PnP Alert\' /><Fields><Field ID=\'{c042a256-787d-4a6f-8a8a-cf6ab767f12d}\' Name=\'ContentType\' SourceID=\'http://schemas.microsoft.com/sharepoint/v3\' StaticName=\'ContentType\' Group=\'_Hidden\' Type=\'Computed\' DisplayName=\'Content Type\' Sealed=\'TRUE\' Sortable=\'FALSE\' RenderXMLUsingPattern=\'TRUE\' PITarget=\'MicrosoftWindowsSharePointServices\' PIAttribute=\'ContentTypeID\' DelayActivateTemplateBinding=\'GROUP,SPSPERS,SITEPAGEPUBLISHING\' Customization=\'\'><FieldRefs><FieldRef ID=\'{03e45e84-1992-4d42-9116-26f756012634}\' Name=\'ContentTypeId\' /></FieldRefs><DisplayPattern><MapToContentType><Column Name=\'ContentTypeId\' /></MapToContentType></DisplayPattern></Field><Field ID=\'{fa564e0f-0c70-4ab9-b863-0177e6ddd247}\' Name=\'Title\' SourceID=\'http://schemas.microsoft.com/sharepoint/v3\' StaticName=\'Title\' Group=\'_Hidden\' Type=\'Text\' DisplayName=\'Title\' Required=\'TRUE\' FromBaseType=\'TRUE\' DelayActivateTemplateBinding=\'GROUP,SPSPERS,SITEPAGEPUBLISHING\' Customization=\'\' ShowInNewForm=\'TRUE\' ShowInEditForm=\'TRUE\'></Field></Fields><XmlDocuments><XmlDocument NamespaceURI=\'http://schemas.microsoft.com/sharepoint/v3/contenttype/forms\'><FormTemplates xmlns=\'http://schemas.microsoft.com/sharepoint/v3/contenttype/forms\'><Display>ListForm</Display><Edit>ListForm</Edit><New>ListForm</New></FormTemplates></XmlDocument></XmlDocuments></ContentType>',
Scope: '/sites/portal',
Sealed: false,
StringId: '0x0100558D85B7216F6A489A499DB361E1AE2F'
}
]
Description: 'Create a new list item.',
DisplayFormTemplateName: 'ListForm',
DisplayFormUrl: '',
DocumentTemplate: '',
DocumentTemplateUrl: '',
EditFormTemplateName: 'ListForm',
EditFormUrl: '',
Group: 'PnP Content Types',
Hidden:
false,
Id: {
StringValue: '0x0100558D85B7216F6A489A499DB361E1AE2F'
},
JSLink: '',
MobileDisplayFormUrl: '',
MobileEditFormUrl: '',
MobileNewFormUrl: '',
Name: 'PnP Alert',
NewFormTemplateName: 'ListForm',
NewFormUrl: '',
ReadOnly: false,
SchemaXml:
'<ContentType ID=\'0x0100558D85B7216F6A489A499DB361E1AE2F\' Name=\'PnP Alert\' Group=\'PnP Content Types\' Description=\'Create a new list item.\' Version=\'1\'><Folder TargetName=\'_cts/PnP Alert\' /><Fields><Field ID=\'{c042a256-787d-4a6f-8a8a-cf6ab767f12d}\' Name=\'ContentType\' SourceID=\'http://schemas.microsoft.com/sharepoint/v3\' StaticName=\'ContentType\' Group=\'_Hidden\' Type=\'Computed\' DisplayName=\'Content Type\' Sealed=\'TRUE\' Sortable=\'FALSE\' RenderXMLUsingPattern=\'TRUE\' PITarget=\'MicrosoftWindowsSharePointServices\' PIAttribute=\'ContentTypeID\' DelayActivateTemplateBinding=\'GROUP,SPSPERS,SITEPAGEPUBLISHING\' Customization=\'\'><FieldRefs><FieldRef ID=\'{03e45e84-1992-4d42-9116-26f756012634}\' Name=\'ContentTypeId\' /></FieldRefs><DisplayPattern><MapToContentType><Column Name=\'ContentTypeId\' /></MapToContentType></DisplayPattern></Field><Field ID=\'{fa564e0f-0c70-4ab9-b863-0177e6ddd247}\' Name=\'Title\' SourceID=\'http://schemas.microsoft.com/sharepoint/v3\' StaticName=\'Title\' Group=\'_Hidden\' Type=\'Text\' DisplayName=\'Title\' Required=\'TRUE\' FromBaseType=\'TRUE\' DelayActivateTemplateBinding=\'GROUP,SPSPERS,SITEPAGEPUBLISHING\' Customization=\'\' ShowInNewForm=\'TRUE\' ShowInEditForm=\'TRUE\'></Field></Fields><XmlDocuments><XmlDocument NamespaceURI=\'http://schemas.microsoft.com/sharepoint/v3/contenttype/forms\'><FormTemplates xmlns=\'http://schemas.microsoft.com/sharepoint/v3/contenttype/forms\'><Display>ListForm</Display><Edit>ListForm</Edit><New>ListForm</New></FormTemplates></XmlDocument></XmlDocuments></ContentType>',
Scope: '/sites/portal',
Sealed: false,
StringId: '0x0100558D85B7216F6A489A499DB361E1AE2F'
};

before(() => {
Expand Down Expand Up @@ -1097,8 +1093,9 @@ describe('utils/spo', () => {

throw 'Invalid request';
});
const actual = await spo.getContentTypeById('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9');
assert.strictEqual(actual, contentTypeResponse.value[0]);

const actual = await spo.getContentTypeById('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9', logger, true);
assert.strictEqual(actual, contentTypeResponse);
});

it('gets information about a list content type by id and list title', async () => {
Expand All @@ -1109,8 +1106,9 @@ describe('utils/spo', () => {

throw 'Invalid request';
});
const actual = await spo.getContentTypeByListTitleAndId('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9', 'Events');
assert.strictEqual(actual, contentTypeResponse.value[0]);

const actual = await spo.getContentTypeByListTitleAndId('https://contoso.sharepoint.com/sites/portal', 'Events', '0x010200973548ACFFDA0948BE80AF607C4E28F9', logger, true);
assert.strictEqual(actual, contentTypeResponse);
});

it(`retrieves roledefinition by name sucessfully`, async () => {
Expand Down Expand Up @@ -1173,8 +1171,8 @@ describe('utils/spo', () => {
throw 'Invalid request';
});

const actual = await spo.getContentTypeByListIdAndId('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9', '9153a1f5-22f7-49e8-a854-06bb4477c2a2');
assert.strictEqual(actual, contentTypeResponse.value[0]);
const actual = await spo.getContentTypeByListIdAndId('https://contoso.sharepoint.com/sites/portal', '9153a1f5-22f7-49e8-a854-06bb4477c2a2', '0x010200973548ACFFDA0948BE80AF607C4E28F9', logger, true);
assert.strictEqual(actual, contentTypeResponse);
});

it('gets information about a list content type by id and list url', async () => {
Expand All @@ -1186,8 +1184,8 @@ describe('utils/spo', () => {
throw 'Invalid request';
});

const actual = await spo.getContentTypeByListUrlAndId('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9', 'documents');
assert.strictEqual(actual, contentTypeResponse.value[0]);
const actual = await spo.getContentTypeByListUrlAndId('https://contoso.sharepoint.com/sites/portal', 'documents', '0x010200973548ACFFDA0948BE80AF607C4E28F9', logger, true);
assert.strictEqual(actual, contentTypeResponse);
});

it('correctly handles site content type not found by id', async () => {
Expand Down Expand Up @@ -1218,7 +1216,7 @@ describe('utils/spo', () => {
});

try {
await spo.getContentTypeByListTitleAndId('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9', 'Events');
await spo.getContentTypeByListTitleAndId('https://contoso.sharepoint.com/sites/portal', 'Events', '0x010200973548ACFFDA0948BE80AF607C4E28F9');
assert.fail('No error message thrown.');
}
catch (ex) {
Expand All @@ -1236,7 +1234,7 @@ describe('utils/spo', () => {
});

try {
await spo.getContentTypeByListIdAndId('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9', '9153a1f5-22f7-49e8-a854-06bb4477c2a2');
await spo.getContentTypeByListIdAndId('https://contoso.sharepoint.com/sites/portal', '9153a1f5-22f7-49e8-a854-06bb4477c2a2', '0x010200973548ACFFDA0948BE80AF607C4E28F9');
assert.fail('No error message thrown.');
}
catch (ex) {
Expand All @@ -1254,7 +1252,7 @@ describe('utils/spo', () => {
});

try {
await spo.getContentTypeByListUrlAndId('https://contoso.sharepoint.com/sites/portal', '0x010200973548ACFFDA0948BE80AF607C4E28F9', 'documents');
await spo.getContentTypeByListUrlAndId('https://contoso.sharepoint.com/sites/portal', 'documents', '0x010200973548ACFFDA0948BE80AF607C4E28F9');
assert.fail('No error message thrown.');
}
catch (ex) {
Expand Down

0 comments on commit 84006ac

Please sign in to comment.