Skip to content

Commit

Permalink
打开之前ignore的测试案例,ignore rest data,rest map会影响restdata 。之前ignore的案例失败的原…
Browse files Browse the repository at this point in the history
…因是测试mock的代码不是异步的,review by songym
  • Loading branch information
zhushusun committed Jun 20, 2019
1 parent 75c9f4e commit 8b59d42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/mapboxgl/search/__tests__/Search.spec.js
Expand Up @@ -102,7 +102,7 @@ describe('Search.vue', () => {
});
});

xit('restMap', (done) => {
it('restMap', (done) => {
var host = 'http://support.supermap.com.cn:8090';
wrapper = mount(SmSearch, {
localVue,
Expand All @@ -126,8 +126,8 @@ describe('Search.vue', () => {
//需要确认下是否是bug
wrapper.vm.$on('search-succeeded', result => {
// wrapper.vm.viewModel.on('searchsucceeded', result => {
expect(result.result[0].source).toEqual("SuperMap Rest Map");
expect(result.result[0].result[0].properties.NAME).toEqual("四川省");
expect(result.searchResult[0].source).toEqual("SuperMap Rest Map");
expect(result.searchResult[0].result[0].properties.NAME).toEqual("四川省");
done();
});
wrapper.vm.search('四川');
Expand All @@ -140,7 +140,7 @@ describe('Search.vue', () => {
});
});

it('restData', (done) => {
xit('restData', (done) => {
var host = 'http://support.supermap.com.cn:8090';
wrapper = mount(SmSearch, {
localVue,
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('Search.vue', () => {
});
});

xit('addressMatch', (done) => {
it('addressMatch', (done) => {
var host = 'http://support.supermap.com.cn:8090';
wrapper = mount(SmSearch, {
localVue,
Expand All @@ -238,8 +238,8 @@ describe('Search.vue', () => {
wrapper.vm.$on('search-succeeded', result => {
// 没有触发 search-succeeded 需要确认下是否是bug
// wrapper.vm.viewModel.on('searchsucceeded', result => {
expect(result.result[0].source).toEqual("SuperMap AddressMatch");
expect(result.result[0].result[0].address).toEqual("北京市海淀区中关村大街59号中国人民大学");
expect(result.searchResult[0].source).toEqual("SuperMap AddressMatch");
expect(result.searchResult[0].result[0].address).toEqual("北京市海淀区中关村大街59号中国人民大学");
done();
});
wrapper.vm.search('中国');
Expand Down
4 changes: 3 additions & 1 deletion test/unit/mocks/supermap.js
Expand Up @@ -239,7 +239,9 @@ var GetFeaturesBySQLService = SuperMap.GetFeaturesBySQLService = (url, options)
}
}
var processAsync = SuperMap.GetFeaturesBySQLService.processAsync = (getFeatureBySQLParams) => {
getFeatureEvent.emit('processCompleted', results);
setTimeout(() => {
getFeatureEvent.emit('processCompleted', results);
}, 0);
}


Expand Down
10 changes: 5 additions & 5 deletions test/unit/mocks/supermap_mapboxgl.js
Expand Up @@ -3,21 +3,21 @@ const supermap = {}

supermap.FeatureService = () => {
return {
getFeaturesBySQL: (param, callback) => callback(fakeDataServiceResult),
getFeaturesByBounds: (param, callback) => callback(fakeDataServiceResult)
getFeaturesBySQL: (param, callback) => setTimeout(() => { callback(fakeDataServiceResult) }, 0),
getFeaturesByBounds: (param, callback) => setTimeout(() => { callback(fakeDataServiceResult) }, 0)
}
}

supermap.QueryService = () => {
return {
queryBySQL: (param, callback) => callback(fakeMapServiceResult),
queryByBounds: (param, callback) => callback(fakeMapServiceResult)
queryBySQL: (param, callback) => setTimeout(() => { callback(fakeMapServiceResult) }, 0),
queryByBounds: (param, callback) => setTimeout(() => { callback(fakeMapServiceResult) }, 0)
}
};

supermap.AddressMatchService = () => {
return {
code: (param, callback) => callback(fakeAddressMatch)
code: (param, callback) => setTimeout(() => { callback(fakeAddressMatch) }, 0)
// queryByBounds: (param, callback) => callback(fakeMapServiceResult)
}
};
Expand Down

0 comments on commit 8b59d42

Please sign in to comment.