-
Notifications
You must be signed in to change notification settings - Fork 124
/
open_geojson.test.js
49 lines (44 loc) · 1.14 KB
/
open_geojson.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var gdal = require('../lib/gdal.js');
var path = require('path');
var assert = require('chai').assert;
describe('Open', function() {
afterEach(gc);
describe('GeoJSON', function() {
var filename, ds;
it('should not throw', function() {
filename = path.join(__dirname, 'data/park.geo.json');
ds = gdal.open(filename);
});
it('should be able to read layer count', function() {
assert.equal(ds.layers.count(), 1);
});
describe('layer', function() {
var layer;
it('should exist', function() {
layer = ds.layers.get(0);
assert.ok(layer);
assert.instanceOf(layer, gdal.Layer);
});
it('should have all fields defined', function() {
assert.equal(layer.fields.count(), 3);
assert.deepEqual(layer.fields.getNames(), [
'kind',
'name',
'state'
]);
});
describe('features', function() {
it('should be readable', function() {
assert.equal(layer.features.count(), 1);
var feature = layer.features.get(0);
var fields = feature.fields.toObject();
assert.deepEqual(fields, {
'kind': 'county',
'state': 'WY',
'name': 'Park'
});
});
});
});
});
});