UNPKG

whodis-sdk

Version:

A simple sdk for easy, secure authentication with the whodis platform. Setup secure authentication for your app in seconds.

51 lines 2.37 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const dotenv_1 = __importDefault(require("dotenv")); const domain_1 = require("../../domain"); const addUserContactMethod_1 = require("./addUserContactMethod"); const removeUserContactMethod_1 = require("./removeUserContactMethod"); dotenv_1.default.config(); if (!process.env.API_PUBLIC_KEY) throw new Error('public key not defined'); if (!process.env.API_PRIVATE_KEY) throw new Error('private key not defined'); describe('removeUserContactMethod', () => { it('should be able to remove a contact method', async () => { // add it to ensure it exists const userBefore = await (0, addUserContactMethod_1.addUserContactMethod)({ userUuid: 'a403997e-f727-45ad-8afc-d4a99137f821', contactMethod: { type: domain_1.WhodisContactMethodType.EMAIL, address: 'bobdog@snailmail.com', }, }, { credentials: { publicKey: process.env.API_PUBLIC_KEY, privateKey: process.env.API_PRIVATE_KEY, }, }); expect(userBefore).toHaveProperty('contactMethods'); expect(userBefore?.contactMethods.length).toBeGreaterThan(0); expect(userBefore?.contactMethods.map((method) => method.address)).toContain('bobdog@snailmail.com'); // and remove it to make sure the method works const userAfter = await (0, removeUserContactMethod_1.removeUserContactMethod)({ userUuid: 'a403997e-f727-45ad-8afc-d4a99137f821', contactMethod: { type: domain_1.WhodisContactMethodType.EMAIL, address: 'bobdog@snailmail.com', }, }, { credentials: { publicKey: process.env.API_PUBLIC_KEY, privateKey: process.env.API_PRIVATE_KEY, }, }); expect(userAfter).toHaveProperty('contactMethods'); expect(userAfter?.contactMethods.length).toBeGreaterThan(0); expect(userAfter?.contactMethods.map((method) => method.address)).not.toContain('bobdog@snailmail.com'); }); }); //# sourceMappingURL=removeUserContactMethod.integration.test.js.map