Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("site.features.add", async function () {
// Check if feature is already active.
const res = await sp.site.features.getById(siteFeatureId)();
if (res["odata.null"]) {
// Feature not active already
return expect(sp.site.features.add(siteFeatureId)).to.be.eventually.fulfilled;
} else {
// Feature already active. Call should fail
return expect(sp.site.features.add(siteFeatureId)).to.be.eventually.rejected;
}
});
.then((res: any): void => {
if (res['odata.null'] !== true) {
cmd.log(JSON.parse(res.value));
}
else {
if (this.verbose) {
cmd.log(`${args.options.webUrl} is not connected to a hub site and is not a hub site itself`);
}
}
if (this.verbose) {
cmd.log(vorpal.chalk.green('DONE'));
}
cb();
}, (err: any): void => this.handleRejectedODataJsonPromise(err, cmd, cb));
}
.then((res: any): void => {
if (res['odata.null'] === true) {
cb(new CommandError(`Content type with ID ${args.options.id} not found`));
return;
}
cmd.log(res);
if (this.verbose) {
cmd.log(vorpal.chalk.green('DONE'));
}
cb();
}, (err: any): void => this.handleRejectedODataJsonPromise(err, cmd, cb));
}
.then((res: SiteDesignTask): void => {
if (!res["odata.null"]) {
cmd.log(res);
}
if (this.verbose) {
cmd.log(vorpal.chalk.green('DONE'));
}
cb();
}, (err: any): void => this.handleRejectedODataJsonPromise(err, cmd, cb));
}
.then((property: TenantProperty): void => {
if (property["odata.null"] === true) {
if (this.verbose) {
cmd.log(`Property with key ${args.options.key} not found`);
}
}
else {
cmd.log({
Key: args.options.key,
Value: property.Value,
Description: property.Description,
Comment: property.Comment
});
}
cb();
}, (err: any): void => this.handleRejectedPromise(err, cmd, cb));
}
.then((webResult: CustomAction): void => {
if (webResult["odata.null"] !== true) {
return resolve(webResult);
}
options.scope = "Site";
this
.getCustomAction(options)
.then((siteResult: CustomAction): void => {
return resolve(siteResult);
}, (err: any): void => {
reject(err);
});
}, (err: any): void => {
reject(err);
.then((res: FieldLink): Promise<{ SchemaXmlWithResourceTokens: string; }> => {
if (res["odata.null"] !== true) {
if (this.verbose) {
cmd.log('Field link found');
}
this.fieldLink = res;
return Promise.resolve(undefined as any);
}
if (this.verbose) {
cmd.log('Field link not found. Creating...');
cmd.log(`Retrieving information about site column ${args.options.fieldId}...`);
}
const requestOptions: any = {
url: `${args.options.webUrl}/_api/web/fields('${args.options.fieldId}')?$select=SchemaXmlWithResourceTokens`,
headers: {
accept: 'application/json;odata=nometadata'
.then((webResult: CustomAction | undefined): void => {
if (webResult === undefined || webResult["odata.null"] !== true) {
return resolve(webResult);
}
options.scope = "Site";
this
.updateCustomAction(options)
.then((siteResult: CustomAction | undefined): void => {
return resolve(siteResult);
}, (err: any): void => {
reject(err);
});
}, (err: any): void => {
reject(err);
.then((res): void => {
if (res && res["odata.null"] === true) {
cb(new CommandError(`Content type not found`));
return;
}
else {
if (this.verbose) {
cmd.log(vorpal.chalk.green('DONE'));
}
}
cb();
}, (err: any): void => {
this.handleRejectedODataJsonPromise(err, cmd, cb);
.then((customAction: CustomAction | undefined): void => {
if (this.verbose) {
if (customAction && customAction["odata.null"] === true) {
cmd.log(`Custom action with id ${args.options.id} not found`);
} else {
cmd.log(vorpal.chalk.green('DONE'));
}
}
cb();
}, (err: any): void => this.handleRejectedPromise(err, cmd, cb));
}