Test coverage on Ruby side

pull/527/head
Rick Carlino 2017-11-10 15:55:30 -06:00
parent c0ae56651e
commit 5a8e3f2eb9
4 changed files with 43 additions and 14 deletions

View File

@ -25,21 +25,21 @@ class Device < ApplicationRecord
logs.all.last(max_log_count || DEFAULT_MAX_LOGS)
end
def auth_token
SessionToken.as_json(self.users.first)[:token].encoded
end
# def auth_token
# SessionToken.as_json(self.users.first)[:token].encoded
# end
# Send a realtime message to a logged in user.
def tell(message, chan = "toast")
log = Log.new({ device: self,
message: message,
created_at: Time.now,
channels: [chan],
meta: { type: "info" } })
json = LogSerializer.new(log).as_json.to_json
# # Send a realtime message to a logged in user.
# def tell(message, chan = "toast")
# log = Log.new({ device: self,
# message: message,
# created_at: Time.now,
# channels: [chan],
# meta: { type: "info" } })
# json = LogSerializer.new(log).as_json.to_json
Transport.amqp_send(json, self.id, "logs")
end
# Transport.amqp_send(json, self.id, "logs")
# end
def self.current
RequestStore.store[:device]

View File

@ -0,0 +1,9 @@
require 'spec_helper'
describe TokenExpiration do
let(:regimen) { FactoryBot.create(:regimen) }
it "Never broadcasts changes and isnt even used right now" do
expect(TokenExpiration.new.broadcast?).to be false
end
end

View File

@ -0,0 +1,20 @@
import * as React from "react";
import { EncoderType, EncoderTypeProps } from "../encoder_type";
import { shallow } from "enzyme";
import { FBSelect } from "../../../ui/new_fb_select";
describe("<EncoderType/>", () => {
it("renders default content", () => {
const props: EncoderTypeProps = {
hardware: {
encoder_type_x: 1,
encoder_type_y: 1,
encoder_type_z: 1
},
onChange: jest.fn()
};
const el = shallow(<EncoderType {...props} />);
expect(el.find(FBSelect).length).toEqual(3);
// EncoderType
});
});

View File

@ -4,7 +4,7 @@ import { t } from "i18next";
import { FBSelect } from "../../ui/new_fb_select";
import { DropDownItem } from "../../ui/fb_select";
interface EncoderTypeProps {
export interface EncoderTypeProps {
hardware: McuParams;
onChange(key: McuParamName, value: Encoder): void;
}