This repository was archived by the owner on Nov 23, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathtests.js
More file actions
87 lines (77 loc) · 2.59 KB
/
Copy pathtests.js
File metadata and controls
87 lines (77 loc) · 2.59 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(function () {
'use strict';
/* global describe */
/* global it */
/* global before */
var flowdata = require('../');
var assert = require('assert');
var testServiceUrl = 'http://services.odata.org/V4/(S(xloriihm0m3y04qekvvc3xg3))/TripPinServiceRW';
describe('Create a new service', function () {
it('require a service url', function (done) {
flowdata.init().catch(function (err) {
assert.strictEqual(err, 'Must provide a serviceUrl');
done();
});
});
it('require a service url via options', function (done) {
flowdata.init({
metadata: {}
}).catch(function (err) {
assert.strictEqual(err, 'Must provide a serviceUrl');
done();
});
});
describe('fetch metadata', function () {
var service;
before(function (done) {
flowdata.init(testServiceUrl).then(function (_service_) {
service = _service_;
done();
});
});
it('service exposes serviceUrl', function () {
assert.notStrictEqual(service, null);
assert.notStrictEqual(typeof service, 'undefined');
assert.strictEqual(service.serviceUrl, testServiceUrl);
});
it('service exposes metadata', function () {
assert.notStrictEqual(service, null);
assert.notStrictEqual(typeof service, 'undefined');
assert.strictEqual(typeof service.metadata, 'object');
});
});
it('fetch metadata via options', function (done) {
flowdata.init({
serviceUrl: testServiceUrl
}).then(function (service) {
assert.notStrictEqual(service, null);
assert.notStrictEqual(typeof service, 'undefined');
assert.strictEqual(typeof service.metadata, 'object');
done();
});
});
it('accept pre-fetched metadata object', function (done) {
flowdata.init({
serviceUrl: testServiceUrl,
metadata: {
test: 'hi'
}
}).then(function (service) {
assert.notStrictEqual(service, null);
assert.notStrictEqual(typeof service, 'undefined');
assert.strictEqual(typeof service.metadata, 'object');
assert.strictEqual(service.metadata.test, 'hi');
done();
});
});
});
describe('logging facility', function () {
it('expose logging property', function () {
assert.strictEqual(typeof flowdata.logging, 'object');
});
it('can change log level', function () {
flowdata.logging.logLevel = flowdata.logging.logLevels.debug;
assert.equal(flowdata.logging.logLevel, flowdata.logging.logLevels.debug);
});
});
})();