UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

57 lines (56 loc) 2.52 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const nock_1 = __importDefault(require("nock")); const profile_1 = __importDefault(require("../profile")); const responses_1 = require("./__static__/responses"); const opts = { url: 'http://127.0.0.1', port: 40600, version: 0 }; const ROOT = `${opts.url}:${opts.port}`; const profile = new profile_1.default(opts); describe('profile set name', () => { it('should resolve to boolean', () => __awaiter(void 0, void 0, void 0, function* () { nock_1.default(ROOT) .post('/api/v0/profile/name') .reply(201); expect(yield profile.setName('displayname')).toEqual(true); })); }); describe('profile get name', () => { it('should resolve to name string', () => __awaiter(void 0, void 0, void 0, function* () { nock_1.default(ROOT) .get('/api/v0/profile') .reply(200, responses_1.profile.get); expect(yield profile.name()).toEqual('displayname'); })); }); describe('profile get avatar', () => { it('should resolve to avatar hash string', () => __awaiter(void 0, void 0, void 0, function* () { nock_1.default(ROOT) .get('/api/v0/profile') .reply(200, responses_1.profile.get); expect(yield profile.avatar()).toEqual(responses_1.profile.get.avatar); })); }); describe('profile get', () => { it('should resolve to full profile', () => __awaiter(void 0, void 0, void 0, function* () { nock_1.default(ROOT) .get('/api/v0/profile') .reply(200, responses_1.profile.get); expect(yield profile.get()).toEqual(responses_1.profile.get); })); });