whodis-sdk
Version:
A simple sdk for easy, secure authentication with the whodis platform. Setup secure authentication for your app in seconds.
52 lines • 2.11 kB
JavaScript
;
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 deps_1 = require("../../deps");
const domain_1 = require("../../domain");
const getUser_1 = require("./getUser");
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('getUser', () => {
it('should get null for a non-existent user', async () => {
const user = await (0, getUser_1.getUser)({ userUuid: (0, deps_1.uuid)() }, {
credentials: {
publicKey: process.env.API_PUBLIC_KEY,
privateKey: process.env.API_PRIVATE_KEY,
},
});
expect(user).toEqual(null);
});
it('should get user data for a real user by uuid', async () => {
const user = await (0, getUser_1.getUser)({ userUuid: 'a403997e-f727-45ad-8afc-d4a99137f821' }, {
credentials: {
publicKey: process.env.API_PUBLIC_KEY,
privateKey: process.env.API_PRIVATE_KEY,
},
});
expect(user).toHaveProperty('contactMethods');
expect(user?.contactMethods.length).toBeGreaterThan(0);
console.log(user);
});
it('should get user data for a real user by contact method', async () => {
const user = await (0, getUser_1.getUser)({
contactMethod: {
type: domain_1.WhodisContactMethodType.EMAIL,
address: 'bobbert@snailmail.com',
},
}, {
credentials: {
publicKey: process.env.API_PUBLIC_KEY,
privateKey: process.env.API_PRIVATE_KEY,
},
});
expect(user).toHaveProperty('contactMethods');
expect(user?.contactMethods.length).toBeGreaterThan(0);
});
});
//# sourceMappingURL=getUser.integration.test.js.map