-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fb4aad
commit a2084ad
Showing
15 changed files
with
458 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { AttachmentsParameters } from '../../../src/common/iServer'; | ||
describe('AttachmentsParameters', () => { | ||
it('constructor destroy', () => { | ||
var option = { | ||
dataSourceName: 'testDataSourceName', | ||
dataSetName: 'testDataSetName', | ||
featureId: '1', | ||
}; | ||
var parametersNull = new AttachmentsParameters(); | ||
expect(parametersNull).not.toBeNull(); | ||
var parameter = new AttachmentsParameters(option); | ||
expect(parameter.dataSourceName).toEqual('testDataSourceName'); | ||
expect(parameter.dataSetName).toEqual('testDataSetName'); | ||
expect(parameter.featureId).toEqual('1'); | ||
parameter.destroy(); | ||
expect(parameter.dataSourceName).toBeNull(); | ||
expect(parameter.dataSetName).toBeNull(); | ||
expect(parameter.featureId).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { EditAttachmentsParameters } from '../../../src/common/iServer'; | ||
describe('EditAttachmentsParameters', () => { | ||
it('constructor destroy', () => { | ||
var option = { | ||
file: new File(['file1 contents'], 'file1.txt', { type: 'text/plain' }), | ||
IDs: [1,2], | ||
editType: 'ADD', | ||
}; | ||
var parametersNull = new EditAttachmentsParameters(); | ||
expect(parametersNull).not.toBeNull(); | ||
var parameter = new EditAttachmentsParameters(option); | ||
expect(parameter.file).not.toBeNull(); | ||
expect(parameter.IDs).toEqual([1,2]); | ||
expect(parameter.editType).toEqual('ADD'); | ||
parameter.destroy(); | ||
expect(parameter.file).toBeNull(); | ||
expect(parameter.IDs).toBeNull(); | ||
expect(parameter.editType).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FeatureService } from '../../../src/leaflet/services/FeatureService'; | ||
import { EditAttachmentsParameters } from '../../../src/common/iServer/EditAttachmentsParameters'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
|
||
var url = GlobeParameter.dataServiceURL; | ||
describe('leaflet_GetFeatureAttachments', () => { | ||
var originalTimeout; | ||
beforeEach(() => { | ||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; | ||
}); | ||
afterEach(() => { | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; | ||
}); | ||
|
||
it('incomplete parameters', done => { | ||
let params = new EditAttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
}); | ||
var editFeatureAttachmentsService = new FeatureService(url, {}); | ||
spyOn(FetchRequest, 'commit'); | ||
editFeatureAttachmentsService.editFeatureAttachments(params); | ||
expect(FetchRequest.commit).not.toHaveBeenCalled(); | ||
done(); | ||
}); | ||
it('complete parameters and add a file', done => { | ||
let file = new File(['file1 contents'], 'file1.txt', { type: 'text/plain' }); | ||
let params = new EditAttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
featureId: 1, | ||
file:file | ||
}); | ||
let myService = new FeatureService(url) | ||
spyOn(FetchRequest, 'commit').and.callFake((method, url, params, options) => { | ||
expect(params.get('file') instanceof File).toBeTruthy(); | ||
expect(method).toEqual('POST'); | ||
expect(url).toEqual('http://localhost:9876/iserver/services/data-world/rest/data/datasources/World/datasets/Countries/features/1/attachments'); | ||
expect(params).not.toBeNull(); | ||
expect(options).not.toBeNull(); | ||
return Promise.resolve( | ||
new Response(`{"size":56,"name":"1.txt","id":-1403040659,"contentType":"text/plain"}`) | ||
) | ||
}) | ||
myService.editFeatureAttachments(params).then(res => { | ||
let serviceResult = res; | ||
expect(serviceResult.result.succeed).toBeTruthy(); | ||
expect(serviceResult.result.name).toBe('1.txt'); | ||
expect(serviceResult.result.contentType).toBe('text/plain'); | ||
expect(serviceResult.result.size).toBe(56); | ||
done(); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { FeatureService } from '../../../src/leaflet/services/FeatureService'; | ||
import { AttachmentsParameters } from '../../../src/common/iServer/AttachmentsParameters'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
|
||
var url = GlobeParameter.dataServiceURL; | ||
describe('leaflet_GetFeatureAttachments', () => { | ||
var originalTimeout; | ||
beforeEach(() => { | ||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; | ||
}); | ||
afterEach(() => { | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; | ||
}); | ||
|
||
it('incomplete parameters', done => { | ||
let params = new AttachmentsParameters({ | ||
dataSourceName: "World" | ||
}); | ||
var getFeatureAttachmentsService = new FeatureService(url, {}); | ||
spyOn(FetchRequest, 'commit'); | ||
getFeatureAttachmentsService.getFeatureAttachments(params); | ||
expect(FetchRequest.commit).not.toHaveBeenCalled(); | ||
done(); | ||
}); | ||
it('complete parameters', done => { | ||
let params = new AttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
featureId: 1, | ||
}); | ||
let resInfo = [{ "size": 56, "name": "1.txt", "id": 1966180689, "contentType": "text/plain" }, { "size": 34991, "name": "test.png", "id": 1590279732, "contentType": "image/png" }]; | ||
let myService = new FeatureService(url) | ||
spyOn(FetchRequest, 'commit').and.callFake((method, url, params, options) => { | ||
expect(method).toEqual('GET'); | ||
expect(params).toBeUndefined(); | ||
expect(options).not.toBeNull(); | ||
expect(url).toEqual('http://localhost:9876/iserver/services/data-world/rest/data/datasources/World/datasets/Countries/features/1/attachments'); | ||
return Promise.resolve(new Response(JSON.stringify(resInfo))); | ||
}) | ||
myService.getFeatureAttachments(params).then(res => { | ||
let serviceResult = res; | ||
expect(serviceResult.result.length).toBe(2); | ||
done(); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FeatureService } from '../../../src/mapboxgl/services/FeatureService'; | ||
import { EditAttachmentsParameters } from '../../../src/common/iServer/EditAttachmentsParameters'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
|
||
var url = GlobeParameter.dataServiceURL; | ||
describe('mapboxgl_GetFeatureAttachments', () => { | ||
var originalTimeout; | ||
beforeEach(() => { | ||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; | ||
}); | ||
afterEach(() => { | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; | ||
}); | ||
|
||
it('incomplete parameters', done => { | ||
let params = new EditAttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
}); | ||
var editFeatureAttachmentsService = new FeatureService(url, {}); | ||
spyOn(FetchRequest, 'commit'); | ||
editFeatureAttachmentsService.editFeatureAttachments(params); | ||
expect(FetchRequest.commit).not.toHaveBeenCalled(); | ||
done(); | ||
}); | ||
it('complete parameters and add a file', done => { | ||
let file = new File(['file1 contents'], 'file1.txt', { type: 'text/plain' }); | ||
let params = new EditAttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
featureId: 1, | ||
file:file | ||
}); | ||
let myService = new FeatureService(url) | ||
spyOn(FetchRequest, 'commit').and.callFake((method, url, params, options) => { | ||
expect(params.get('file') instanceof File).toBeTruthy(); | ||
expect(method).toEqual('POST'); | ||
expect(url).toEqual('http://localhost:9876/iserver/services/data-world/rest/data/datasources/World/datasets/Countries/features/1/attachments'); | ||
expect(params).not.toBeNull(); | ||
expect(options).not.toBeNull(); | ||
return Promise.resolve( | ||
new Response(`{"size":56,"name":"1.txt","id":-1403040659,"contentType":"text/plain"}`) | ||
) | ||
}) | ||
myService.editFeatureAttachments(params).then(res => { | ||
let serviceResult = res; | ||
expect(serviceResult.result.succeed).toBeTruthy(); | ||
expect(serviceResult.result.name).toBe('1.txt'); | ||
expect(serviceResult.result.contentType).toBe('text/plain'); | ||
expect(serviceResult.result.size).toBe(56); | ||
done(); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { FeatureService } from '../../../src/mapboxgl/services/FeatureService'; | ||
import { AttachmentsParameters } from '../../../src/common/iServer/AttachmentsParameters'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
|
||
var url = GlobeParameter.dataServiceURL; | ||
describe('mapboxgl_GetFeatureAttachments', () => { | ||
var originalTimeout; | ||
beforeEach(() => { | ||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; | ||
}); | ||
afterEach(() => { | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; | ||
}); | ||
|
||
it('incomplete parameters', done => { | ||
let params = new AttachmentsParameters({ | ||
dataSourceName: "World" | ||
}); | ||
var getFeatureAttachmentsService = new FeatureService(url, {}); | ||
spyOn(FetchRequest, 'commit'); | ||
getFeatureAttachmentsService.getFeatureAttachments(params); | ||
expect(FetchRequest.commit).not.toHaveBeenCalled(); | ||
done(); | ||
}); | ||
it('complete parameters', done => { | ||
let params = new AttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
featureId: 1, | ||
}); | ||
let resInfo = [{ "size": 56, "name": "1.txt", "id": 1966180689, "contentType": "text/plain" }, { "size": 34991, "name": "test.png", "id": 1590279732, "contentType": "image/png" }]; | ||
let myService = new FeatureService(url) | ||
spyOn(FetchRequest, 'commit').and.callFake((method, url, params, options) => { | ||
expect(method).toEqual('GET'); | ||
expect(params).toBeUndefined(); | ||
expect(options).not.toBeNull(); | ||
expect(url).toEqual('http://localhost:9876/iserver/services/data-world/rest/data/datasources/World/datasets/Countries/features/1/attachments'); | ||
return Promise.resolve(new Response(JSON.stringify(resInfo))); | ||
}) | ||
myService.getFeatureAttachments(params).then(res => { | ||
let serviceResult = res; | ||
expect(serviceResult.result.length).toBe(2); | ||
done(); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FeatureService } from '../../../src/maplibregl/services/FeatureService'; | ||
import { EditAttachmentsParameters } from '../../../src/common/iServer/EditAttachmentsParameters'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
|
||
var url = GlobeParameter.dataServiceURL; | ||
describe('maplibregl_GetFeatureAttachments', () => { | ||
var originalTimeout; | ||
beforeEach(() => { | ||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; | ||
}); | ||
afterEach(() => { | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; | ||
}); | ||
|
||
it('incomplete parameters', done => { | ||
let params = new EditAttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
}); | ||
var editFeatureAttachmentsService = new FeatureService(url, {}); | ||
spyOn(FetchRequest, 'commit'); | ||
editFeatureAttachmentsService.editFeatureAttachments(params); | ||
expect(FetchRequest.commit).not.toHaveBeenCalled(); | ||
done(); | ||
}); | ||
it('complete parameters and add a file', done => { | ||
let file = new File(['file1 contents'], 'file1.txt', { type: 'text/plain' }); | ||
let params = new EditAttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
featureId: 1, | ||
file:file | ||
}); | ||
let myService = new FeatureService(url) | ||
spyOn(FetchRequest, 'commit').and.callFake((method, url, params, options) => { | ||
expect(params.get('file') instanceof File).toBeTruthy(); | ||
expect(method).toEqual('POST'); | ||
expect(url).toEqual('http://localhost:9876/iserver/services/data-world/rest/data/datasources/World/datasets/Countries/features/1/attachments'); | ||
expect(params).not.toBeNull(); | ||
expect(options).not.toBeNull(); | ||
return Promise.resolve( | ||
new Response(`{"size":56,"name":"1.txt","id":-1403040659,"contentType":"text/plain"}`) | ||
) | ||
}) | ||
myService.editFeatureAttachments(params).then(res => { | ||
let serviceResult = res; | ||
expect(serviceResult.result.succeed).toBeTruthy(); | ||
expect(serviceResult.result.name).toBe('1.txt'); | ||
expect(serviceResult.result.contentType).toBe('text/plain'); | ||
expect(serviceResult.result.size).toBe(56); | ||
done(); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { FeatureService } from '../../../src/maplibregl/services/FeatureService'; | ||
import { AttachmentsParameters } from '../../../src/common/iServer/AttachmentsParameters'; | ||
import { FetchRequest } from '../../../src/common/util/FetchRequest'; | ||
|
||
var url = GlobeParameter.dataServiceURL; | ||
describe('maplibregl_GetFeatureAttachments', () => { | ||
var originalTimeout; | ||
beforeEach(() => { | ||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; | ||
}); | ||
afterEach(() => { | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; | ||
}); | ||
|
||
it('incomplete parameters', done => { | ||
let params = new AttachmentsParameters({ | ||
dataSourceName: "World" | ||
}); | ||
var getFeatureAttachmentsService = new FeatureService(url, {}); | ||
spyOn(FetchRequest, 'commit'); | ||
getFeatureAttachmentsService.getFeatureAttachments(params); | ||
expect(FetchRequest.commit).not.toHaveBeenCalled(); | ||
done(); | ||
}); | ||
it('complete parameters', done => { | ||
let params = new AttachmentsParameters({ | ||
dataSourceName: "World", | ||
dataSetName: "Countries", | ||
featureId: 1, | ||
}); | ||
let resInfo = [{ "size": 56, "name": "1.txt", "id": 1966180689, "contentType": "text/plain" }, { "size": 34991, "name": "test.png", "id": 1590279732, "contentType": "image/png" }]; | ||
let myService = new FeatureService(url) | ||
spyOn(FetchRequest, 'commit').and.callFake((method, url, params, options) => { | ||
expect(method).toEqual('GET'); | ||
expect(params).toBeUndefined(); | ||
expect(options).not.toBeNull(); | ||
expect(url).toEqual('http://localhost:9876/iserver/services/data-world/rest/data/datasources/World/datasets/Countries/features/1/attachments'); | ||
return Promise.resolve(new Response(JSON.stringify(resInfo))); | ||
}) | ||
myService.getFeatureAttachments(params).then(res => { | ||
let serviceResult = res; | ||
expect(serviceResult.result.length).toBe(2); | ||
done(); | ||
}); | ||
}) | ||
}); |
Oops, something went wrong.