2019-03-08 08:56:53 -07:00
|
|
|
const assert = require('chai').assert;
|
2019-02-24 07:49:41 -07:00
|
|
|
const data = require('../lib/util/data.js');
|
2018-08-15 13:19:54 -07:00
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
describe('Data', () => {
|
|
|
|
describe('Get path', () => {
|
|
|
|
it('Should return correct path', () => {
|
|
|
|
const expected = path.normalize(path.join(__dirname, '..', 'data'));
|
2019-02-24 07:49:41 -07:00
|
|
|
const actual = data.getPath();
|
2019-03-08 08:56:53 -07:00
|
|
|
assert.strictEqual(actual, expected);
|
2018-08-15 13:19:54 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should return correct path when ZIGBEE2MQTT_DATA set', () => {
|
|
|
|
const expected = path.join('var', 'zigbee2mqtt');
|
|
|
|
process.env.ZIGBEE2MQTT_DATA = expected;
|
2019-02-24 07:49:41 -07:00
|
|
|
data._reload();
|
|
|
|
const actual = data.getPath();
|
2019-03-08 08:56:53 -07:00
|
|
|
assert.strictEqual(actual, expected);
|
2019-02-24 07:49:41 -07:00
|
|
|
delete process.env.ZIGBEE2MQTT_DATA;
|
|
|
|
data._reload();
|
2018-08-15 13:19:54 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|