-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added internalName option for spo field commands #6379
base: main
Are you sure you want to change the base?
Conversation
Thank you, we'll try to review it ASAP! |
|
||
it('should call the correct GET url when field internalName and list url specified', async () => { | ||
const getStub = sinon.stub(request, 'get').callsFake(async (opts) => { | ||
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please use full URL's instead of using indexOf please? Please do this for all your tests
const getStub = sinon.stub(request, 'get').callsFake(async (opts) => { | ||
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) { | ||
return { | ||
"Id": "03e45e84-1992-4d42-9116-26f756012634" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let's use single quotes
@@ -320,6 +320,51 @@ describe(commands.FIELD_GET, () => { | |||
assert.strictEqual(getStub.lastCall.args[0].url, 'https://contoso.sharepoint.com/sites/portal/_api/web/lists(guid\'03e45e84-1992-4d42-9116-26f756012634\')/fields/getbyinternalnameortitle(\'Title\')'); | |||
}); | |||
|
|||
it('should call the correct GET url when field internalName and list title specified (verbose)', async () => { | |||
const getStub = sinon.stub(request, 'get').callsFake(async (opts) => { | |||
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, let's use full url's
@@ -117,6 +122,9 @@ class SpoFieldGetCommand extends SpoCommand { | |||
if (args.options.id) { | |||
fieldRestUrl = `/getbyid('${formatting.encodeQueryParameter(args.options.id)}')`; | |||
} | |||
else if (args.options.internalName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not do something like:
else if (args.options.internalName) { | |
else { | |
fieldRestUrl = `/getbyinternalnameortitle('${formatting.encodeQueryParameter(args.options.internalName || args.options.title)}')`; | |
} |
@@ -454,6 +466,51 @@ describe(commands.FIELD_REMOVE, () => { | |||
assert.strictEqual(getStub.lastCall.args[0].url, 'https://contoso.sharepoint.com/sites/portal/_api/web/lists(guid\'03e45e84-1992-4d42-9116-26f756012634\')/fields/getbyinternalnameortitle(\'Title\')'); | |||
}); | |||
|
|||
it('calls the correct get url when field internalName and list title specified (verbose)', async () => { | |||
const getStub = sinon.stub(request, 'post').callsFake(async (opts) => { | |||
if ((opts.url as string).indexOf(`/_api/web/lists`) > -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, let's use full URLs
@@ -112,6 +112,44 @@ describe(commands.FIELD_SET, () => { | |||
assert(loggerLogSpy.notCalled); | |||
}); | |||
|
|||
it('updates site column specified by internalName', async () => { | |||
sinon.stub(request, 'post').callsFake(async (opts) => { | |||
if ((opts.url as string).indexOf(`/_vti_bin/client.svc/ProcessQuery`) > -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use full urls
Closes #6249
In this PR, i have added
internalName
option to below commandsspo field get
spo field set
spo field remove