-
Notifications
You must be signed in to change notification settings - Fork 303
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
Showing
1 changed file
with
80 additions
and
0 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,80 @@ | ||
import assert from 'assert'; | ||
import fs from 'fs'; | ||
import Path from 'path'; | ||
import Source from '../../src/Source/Source'; | ||
import WMTSSource from '../../src/Source/WMTSSource'; | ||
import WMSSource from '../../src/Source/WMSSource'; | ||
import TMSSource from '../../src/Source/TMSSource'; | ||
import fileSource from '../../src/Source/fileSource'; | ||
import StaticSource from '../../src/Source/StaticSource'; | ||
import Fetcher from '../../src/Provider/Fetcher'; | ||
|
||
function defer() { | ||
var deferredPromise = {}; | ||
deferredPromise.promise = new Promise(function (resolve) { | ||
deferredPromise.resolve = resolve; | ||
}); | ||
return deferredPromise; | ||
} | ||
|
||
const geojson = defer(); | ||
|
||
// To load geojson without parse the file content | ||
const urlGeojson = Path.resolve(__dirname, '../data/geojson/holes.geojson.json'); | ||
fs.readFile(urlGeojson, 'utf8', function (err, content) { | ||
geojson.resolve(content); | ||
}); | ||
|
||
global.window = {}; | ||
|
||
describe('Source', function () { | ||
it('Should instance Source', function () { | ||
const source = new Source({ | ||
url: 'http://', | ||
protocol: 'unknow' }); | ||
assert.ok(source.protocol); | ||
}); | ||
it('Should instance WMTSSource', function () { | ||
const source = new WMTSSource({ | ||
url: 'http://', | ||
protocol: 'wmts', | ||
format: 'image/png', | ||
}); | ||
assert.ok(source.protocol); | ||
}); | ||
it('Should instance WMSSource', function () { | ||
const source = new WMSSource({ | ||
url: 'http://', | ||
name: 'name', | ||
protocol: 'wms', | ||
format: 'image/png', | ||
extent: [-90, 90, -45, 45], | ||
projection: 'EPSG:4326', | ||
}); | ||
assert.ok(source.protocol); | ||
}); | ||
it('Should instance TMSSource', function () { | ||
const source = new TMSSource({ | ||
url: 'http://', | ||
protocol: 'tms', | ||
}); | ||
assert.ok(source.protocol); | ||
}); | ||
it('Should instance FileSource', function () { | ||
Fetcher.text = function () { return geojson.promise; }; | ||
const source = new fileSource({ | ||
url: '..', | ||
protocol: 'file', | ||
}, 'EPSG:4326'); | ||
assert.ok(source.protocol); | ||
}); | ||
it('Should instance StaticSource', function () { | ||
Fetcher.json = function () { return Promise.resolve({}); }; | ||
const source = new StaticSource({ | ||
url: 'http://itowns.org', | ||
protocol: 'file', | ||
extent: [-90, 90, -45, 45], | ||
}); | ||
assert.ok(source.protocol); | ||
}); | ||
}); |