File size: 1,752 Bytes
1abfaca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
/* Test requires a pg database test with a table including data
 ** from fixtures/test-point.geojson.
 */

const test = require('tape');
const gm = require('../../geomangler');
const connection = require('../fixtures/mssql-conf');

test('mssql-0', (assert) => {
  const message = 'Should return feature with valid coordinates';

  gm.add('mssql', 'test_point', {
    connection
  })
    .then((features) => {
      const actual = features[0].getGeometry().getCoordinates().map(feature => feature.toFixed());
      const expected = [1841734.1101797, 8313842.60728307].map(feature => feature.toFixed());
      assert.same(actual, expected, message);
      assert.end();
    });
});

test('mssql-1', (assert) => {
  const message = 'Should return feature with valid coordinates';
  const query = `
    select name, geometry.STAsText() AS geometry
    from "test_point";
  `;

  gm.read('mssql', query, {
    connection
  })
    .then((features) => {
      const actual = features[0].getGeometry().getCoordinates().map(feature => feature.toFixed());
      const expected = [1841734.1101797, 8313842.60728307].map(feature => feature.toFixed());
      assert.same(actual, expected, message);
      assert.end();
    });
});

test('mssql-2', (assert) => {
  const message = 'Should return feature with valid coordinates';

  const conn = gm.db('mssql', {
    connection
  });
  gm.add('mssql', 'test_point', {
    connectionPool: conn
  })
    .then((features) => {
      const actual = features[0].getGeometry().getCoordinates().map(feature => feature.toFixed());
      const expected = [1841734.1101797, 8313842.60728307].map(feature => feature.toFixed());
      conn.destroy();
      assert.same(actual, expected, message);
      assert.end();
    });
});