Skip to content

Commit

Permalink
final cleanup
Browse files Browse the repository at this point in the history
* confirmed demo app works (even prior to publishing package)
* switched to clearly fake feature service urls in tests
* fixed my own typo
  • Loading branch information
jgravois committed Jul 19, 2018
1 parent fb6efcc commit ab93f25
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 98 deletions.
2 changes: 0 additions & 2 deletions demos/attachments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
1. Make sure you run `npm run bootstrap` in the root folder to setup the dependencies
1. `npm start`
1. Visit http://localhost:8080

this demo with not work with http-server until attachment methods are included in a release and script src is updated in index.html
10 changes: 3 additions & 7 deletions demos/attachments/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ <h3>Attachments</h3>
<form id="getForm">
<div class="form-group">
<label for="serviceUrl">Service URL</label>
<input type="text" id="serviceUrl" name="serviceUrl" class="form-control" placeholder="https://myserver/arcgis/rest/services/Service/2" required>
<input type="text" id="serviceUrl" name="serviceUrl" class="form-control" value="http://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/0/" required>
</div>
<div class="form-group">
<label for="featureId">Feature ID</label>
<input type="number" min="0" step="1" id="featureId" name="featureId" class="form-control" placeholder="Integer >= 0" required>
<input type="number" min="0" step="1" id="featureId" name="featureId" class="form-control" value="3339970" required>
</div>
<div class="form-group">
<button type="submit" class="btn"><span class="glyphicon glyphicon-paperclip" aria-hidden="true"></span> Get Attachments</button>
Expand Down Expand Up @@ -55,11 +55,7 @@ <h3>Attachments</h3>

<script src="https://rawgit.com/kriszyp/put-selector/master/put.js"></script>
<script src="node_modules/@esri/arcgis-rest-request/dist/umd/request.umd.js"></script>

<!-- this demo with not work with http-server until attachment methods are included in a release -->
<!-- update package.json and swap out scripts when included in a release -->
<script src="../../packages/arcgis-rest-feature-service/dist/umd/feature-service.umd.js"></script>
<!-- <script src="node_modules/@esri/arcgis-rest-feature-service/dist/umd/feature-service.umd.js"></script> -->
<script src="node_modules/@esri/arcgis-rest-feature-service/dist/umd/feature-service.umd.js"></script>

<script>
let serviceUrl, featureId;
Expand Down
105 changes: 39 additions & 66 deletions demos/attachments/package-lock.json

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

20 changes: 9 additions & 11 deletions packages/arcgis-rest-feature-service/test/attachments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ function attachmentFile() {
}
}

const serviceUrl =
"https://services.arcgis.com/f8b/arcgis/rest/services/Custom/FeatureServer/0";

describe("attachment methods", () => {
afterEach(fetchMock.restore);

it("should return an array of attachmentInfos for a feature by id", done => {
const requestOptions = {
url:
"https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
url: serviceUrl,
featureId: 42,
params: {
gdbVersion: "SDE.DEFAULT"
Expand All @@ -61,8 +63,7 @@ describe("attachment methods", () => {

it("should return objectId of the added attachment and a truthy success", done => {
const requestOptions = {
url:
"https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
url: serviceUrl,
featureId: 42,
attachment: attachmentFile(),
params: {
Expand All @@ -79,7 +80,7 @@ describe("attachment methods", () => {
expect(options.method).toBe("POST");
expect(options.body instanceof FormData).toBeTruthy();
const params = options.body as FormData;
// figured out how to instrospect FormData in Chrome, but not Node.js
// we could introspect FormData in Chrome this way, but not Node.js
// more info: https://github.com/form-data/form-data/issues/124
// expect(params.get("returnEditMoment")).toEqual("true");
expect(addAttachmentResponse.addAttachmentResult.objectId).toEqual(1001);
Expand All @@ -91,7 +92,7 @@ describe("attachment methods", () => {
it("should return an error for a service/feature which does not have attachments", done => {
const requestOptions = {
url:
"https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/4",
"https://services.arcgis.com/f8b/arcgis/rest/services/NoAttachments/FeatureServer/0",
featureId: 654,
attachment: attachmentFile(),
params: {
Expand Down Expand Up @@ -121,8 +122,7 @@ describe("attachment methods", () => {

it("should return objectId of the updated attachment and a truthy success", done => {
const requestOptions = {
url:
"https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
url: serviceUrl,
featureId: 42,
attachmentId: 1001,
attachment: attachmentFile(),
Expand All @@ -138,7 +138,6 @@ describe("attachment methods", () => {
`${requestOptions.url}/${requestOptions.featureId}/updateAttachment`
);
expect(options.method).toBe("POST");
// expect(options.body).toContain("returnEditMoment=true");
expect(updateAttachmentResponse.updateAttachmentResult.objectId).toEqual(
1001
);
Expand All @@ -151,8 +150,7 @@ describe("attachment methods", () => {

it("should return objectId of the deleted attachment and a truthy success", done => {
const requestOptions = {
url:
"https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
url: serviceUrl,
featureId: 42,
attachmentIds: [1001],
params: {
Expand Down
Loading

0 comments on commit ab93f25

Please sign in to comment.