Adding tests file and adjusting meshblu definitions

This commit is contained in:
Felipe Nipo
2015-09-19 23:59:04 -03:00
parent b562f0ac0d
commit 291f69d01c
2 changed files with 132 additions and 9 deletions

123
meshblu/meshblu-tests.ts Normal file
View File

@@ -0,0 +1,123 @@
/// <reference path="meshblu.d.ts" />
import Meshblu = require('meshblu');
var UUID = "26de691f-8068-4cdc-907a-4cb5961a1aba";
var TOKEN = "4cb5961a1aba26de691f80684cdc907a";
var meshblu = Meshblu.createConnection({
uuid: UUID,
token: TOKEN
});
meshblu.data({
uuid: UUID,
online: true,
x: -53,
y: 234
}, function(result) {
console.log(result);
});
meshblu.device({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.devices({
color: "green"
}, function(result) {
console.log(result);
});
meshblu.generateAndStoreToken({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.getdata({
uuid: UUID,
start: "2015-04-23T18:25:43.511Z",
finish: "2015-04-24T18:25:43.511Z",
limit: 10
}, function(result) {
console.log(result);
});
meshblu.identify();
meshblu.message({
devices: [UUID],
topic: "status",
payload: {
online: true
}
}, function(result) {
console.log(result);
});
meshblu.register({
type: "drone"
}, function(result) {
console.log(result);
});
meshblu.revokeToken({
uuid: UUID,
token: TOKEN
}, function(result) {
console.log(result);
});
meshblu.subscribe({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.subscribe({
uuid: UUID,
types: ["sent", "received"]
}, function(result) {
console.log(result);
});
meshblu.subscribe({
uuid: UUID,
types: ["sent", "received"],
topics: ["device*", "-*status"]
}, function(result) {
console.log(result);
});
meshblu.unsubscribe({
uuid: UUID
}, function(result) {
console.log(result);
});
meshblu.unsubscribe({
uuid: UUID,
types: ["sent", "broadcast"]
}, function(result) {
console.log(result);
});
meshblu.update({
uuid: UUID,
color: "blue"
}, function(result) {
console.log(result);
});
meshblu.whoami({}, function(result) {
console.log(result);
});
meshblu.unregister({
uuid: UUID
}, function(result) {
console.log(result);
});

18
meshblu/meshblu.d.ts vendored
View File

@@ -26,15 +26,6 @@ declare module Meshblu {
interface Connection {
/**
*
* @param uuid
* @param fn The callback to be called. It should take one parameter, err,
* which will be null if there was no problem, and one parameter, publicKey,
* of type NodeRSA.
*/
getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void;
/**
* Authenticate with Meshblu.
* @returns This Connection.
@@ -166,6 +157,15 @@ declare module Meshblu {
*/
revokeToken(data: ConnectionOptions, fn:(result: Device) => void): void
/**
*
* @param uuid
* @param fn The callback to be called. It should take one parameter, err,
* which will be null if there was no problem, and one parameter, publicKey,
* of type NodeRSA.
*/
getPublicKey(uuid: string, fn:(err: Error, publicKey: any) => void): void;
/*
* Lack of documentation about these api functions.
*/