Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ orca.fields.delete('sheet-id', 'field-key').then(function(result) {
| `readonlyMobile` | `boolean` | Prevent user input on mobile *(default: false)* |
| `useInMobileSearch` | `boolean` | Include value in mobile search *(default: false)* |
| `useValueInList` | `boolean` | Show field value in mobile list *(default: false)* |
| `index` | `integer` | Display order of the field *(default: -1)* |

#### Field formats

Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ function OrcaScanNode(apiKey, options) {
* @param {boolean} [payload.readonlyMobile=false] - if true, field is read-only on mobile
* @param {boolean} [payload.useInMobileSearch=true] - if true, field is searchable in mobile list
* @param {boolean} [payload.useValueInList=true] - if true, field is visible in mobile list
* @param {number} [payload.index] - if provided, sets the display order of the field
* @returns {Promise<object>} promise resolving to result
* {object} data - created field with all properties
*/
Expand Down Expand Up @@ -444,6 +445,7 @@ function OrcaScanNode(apiKey, options) {
* @param {boolean} [payload.readonlyMobile] - if true, field is read-only on mobile
* @param {boolean} [payload.useInMobileSearch] - if true, field is searchable in mobile list
* @param {boolean} [payload.useValueInList] - if true, field is visible in mobile list
* @param {number} [payload.index] - if provided, sets the display order of the field
* @returns {Promise<object>} promise resolving to result
* {object} data - updated field with all properties
*/
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orca-scan/orca-scan-node",
"version": "1.1.0",
"version": "1.1.1",
"engines": {
"node": ">=14.16.0"
},
Expand Down
23 changes: 23 additions & 0 deletions tests/e2e/03-fields-e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,29 @@ describe('e2e: fields', function () {
expect(found.label).toBe('E2E Notes Updated');
});

it('should create a field with a specific index', async function () {
var field = await client.fields.create(setup.getSheetId(), {
label: 'E2E Indexed Field',
format: 'text',
index: 2
});

expect(field).toBeDefined();
expect(field.label).toBe('E2E Indexed Field');
expect(field.index).toBe(2);

// clean up
await client.fields.delete(setup.getSheetId(), field.key);
});

it('should update a field index', async function () {
var updated = await client.fields.update(setup.getSheetId(), fieldKey, {
index: 1
});

expect(updated.index).toBe(1);
});

it('should delete the field', async function () {
await client.fields.delete(setup.getSheetId(), fieldKey);

Expand Down
30 changes: 30 additions & 0 deletions tests/fields-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,21 @@ describe('Fields', function() {
});
});

it('should create a field with index in payload', function() {
var payload = { label: 'Test Field', format: 'text', index: 2 };

return client.fields.create('test-sheet-id', payload).then(function(result) {
expect(mockFetch).toHaveBeenCalledWith(
'https://api.orcascan.com/v1/sheets/test-sheet-id/fields',
jasmine.objectContaining({
method: 'POST',
body: JSON.stringify(payload)
})
);
expect(result).toBeDefined();
});
});

it('should create a field with all optional properties', function() {
var sheetId = 'test-sheet-id';
var payload = {
Expand Down Expand Up @@ -198,6 +213,21 @@ describe('Fields', function() {
});
});

it('should update a field with index in payload', function() {
var payload = { label: 'Updated Field Label', index: 1 };

return client.fields.update('test-sheet-id', 'test-field', payload).then(function(result) {
expect(mockFetch).toHaveBeenCalledWith(
'https://api.orcascan.com/v1/sheets/test-sheet-id/fields/test-field',
jasmine.objectContaining({
method: 'PUT',
body: JSON.stringify(payload)
})
);
expect(result).toBeDefined();
});
});

it('should throw error when updating field without sheetId', function() {
expect(function() {
client.fields.update();
Expand Down
Loading