Fix jwt-token
This commit is contained in:
@@ -554,9 +554,16 @@ describe('Models', () => {
|
||||
|
||||
describe('Heartbeat Model', () => {
|
||||
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 = {
|
||||
key: 'device_123_key',
|
||||
device_id: 123,
|
||||
device_id: device.id,
|
||||
signal_strength: -50,
|
||||
battery_level: 85,
|
||||
temperature: 22.5
|
||||
@@ -566,18 +573,25 @@ describe('Models', () => {
|
||||
|
||||
expect(heartbeat.id).to.exist;
|
||||
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);
|
||||
});
|
||||
|
||||
it('should auto-set timestamp', async () => {
|
||||
const heartbeat = await models.Heartbeat.create({
|
||||
key: 'device_123_key',
|
||||
device_id: 123
|
||||
const tenant = await createTestTenant();
|
||||
const device = await models.Device.create({
|
||||
id: 124,
|
||||
name: 'Test Device 2',
|
||||
tenant_id: tenant.id
|
||||
});
|
||||
|
||||
expect(heartbeat.timestamp).to.exist;
|
||||
expect(heartbeat.timestamp).to.be.a('date');
|
||||
const heartbeat = await models.Heartbeat.create({
|
||||
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 () => {
|
||||
|
||||
Reference in New Issue
Block a user