Fix jwt-token
This commit is contained in:
@@ -85,11 +85,11 @@ module.exports = (sequelize) => {
|
|||||||
},
|
},
|
||||||
created_at: {
|
created_at: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
defaultValue: DataTypes.NOW
|
defaultValue: sequelize.Sequelize.NOW
|
||||||
},
|
},
|
||||||
updated_at: {
|
updated_at: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
defaultValue: DataTypes.NOW
|
defaultValue: sequelize.Sequelize.NOW
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
tableName: 'alert_logs',
|
tableName: 'alert_logs',
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ module.exports = (sequelize) => {
|
|||||||
},
|
},
|
||||||
server_timestamp: {
|
server_timestamp: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
defaultValue: DataTypes.NOW,
|
defaultValue: sequelize.Sequelize.NOW,
|
||||||
comment: 'When the detection was received by server'
|
comment: 'When the detection was received by server'
|
||||||
},
|
},
|
||||||
confidence_level: {
|
confidence_level: {
|
||||||
@@ -100,7 +100,7 @@ module.exports = (sequelize) => {
|
|||||||
},
|
},
|
||||||
created_at: {
|
created_at: {
|
||||||
type: DataTypes.DATE,
|
type: DataTypes.DATE,
|
||||||
defaultValue: DataTypes.NOW
|
defaultValue: sequelize.Sequelize.NOW
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
tableName: 'drone_detections',
|
tableName: 'drone_detections',
|
||||||
|
|||||||
@@ -554,9 +554,16 @@ describe('Models', () => {
|
|||||||
|
|
||||||
describe('Heartbeat Model', () => {
|
describe('Heartbeat Model', () => {
|
||||||
it('should create heartbeat with valid data', async () => {
|
it('should create heartbeat with valid data', async () => {
|
||||||
|
const tenant = await createTestTenant();
|
||||||
|
const device = await models.Device.create({
|
||||||
|
id: 123,
|
||||||
|
name: 'Test Device',
|
||||||
|
tenant_id: tenant.id
|
||||||
|
});
|
||||||
|
|
||||||
const heartbeatData = {
|
const heartbeatData = {
|
||||||
key: 'device_123_key',
|
key: 'device_123_key',
|
||||||
device_id: 123,
|
device_id: device.id,
|
||||||
signal_strength: -50,
|
signal_strength: -50,
|
||||||
battery_level: 85,
|
battery_level: 85,
|
||||||
temperature: 22.5
|
temperature: 22.5
|
||||||
@@ -566,18 +573,25 @@ describe('Models', () => {
|
|||||||
|
|
||||||
expect(heartbeat.id).to.exist;
|
expect(heartbeat.id).to.exist;
|
||||||
expect(heartbeat.key).to.equal('device_123_key');
|
expect(heartbeat.key).to.equal('device_123_key');
|
||||||
expect(heartbeat.device_id).to.equal(123);
|
expect(heartbeat.device_id).to.equal(device.id);
|
||||||
expect(heartbeat.battery_level).to.equal(85);
|
expect(heartbeat.battery_level).to.equal(85);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should auto-set timestamp', async () => {
|
it('should auto-set timestamp', async () => {
|
||||||
const heartbeat = await models.Heartbeat.create({
|
const tenant = await createTestTenant();
|
||||||
key: 'device_123_key',
|
const device = await models.Device.create({
|
||||||
device_id: 123
|
id: 124,
|
||||||
|
name: 'Test Device 2',
|
||||||
|
tenant_id: tenant.id
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(heartbeat.timestamp).to.exist;
|
const heartbeat = await models.Heartbeat.create({
|
||||||
expect(heartbeat.timestamp).to.be.a('date');
|
key: 'device_124_key',
|
||||||
|
device_id: device.id
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(heartbeat.created_at).to.exist;
|
||||||
|
expect(heartbeat.created_at).to.be.a('date');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should validate battery level range', async () => {
|
it('should validate battery level range', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user