mirror of
https://github.com/Permissionless-Software-Foundation/x402-base-facilitator.git
synced 2026-09-21 16:52:01 -07:00
79 lines
2.0 KiB
JavaScript
79 lines
2.0 KiB
JavaScript
// /*
|
|
// Unit tests for the passport library.
|
|
// */
|
|
//
|
|
// // Public npm libraries
|
|
// // const assert = require('chai').assert
|
|
// import sinon from 'sinon';
|
|
//
|
|
// // Local libraries
|
|
// import User from '../../../src/adapters/localdb/models/users.js';
|
|
//
|
|
// import { passport, passportCallback } from '../../../config/passport.js';
|
|
// import adaptersMock from '../mocks/adapters/index.js';
|
|
//
|
|
// describe('#passport', () => {
|
|
// let sandbox
|
|
// let id
|
|
// let done
|
|
//
|
|
// beforeEach(() => {
|
|
// sandbox = sinon.createSandbox()
|
|
//
|
|
// id = 'abc123'
|
|
// done = () => {}
|
|
// })
|
|
//
|
|
// afterEach(() => sandbox.restore())
|
|
//
|
|
// describe('#serializeUser', () => {
|
|
// it('should serialize a user', () => {
|
|
// const user = {
|
|
// id: 'abc123'
|
|
// }
|
|
// const done = () => {}
|
|
//
|
|
// passport.serializeUser(user, done)
|
|
// })
|
|
// })
|
|
//
|
|
// describe('#deserializeUser', () => {
|
|
// it('should deserialize a user', () => {
|
|
// // Mock Users model.
|
|
// sandbox.stub(User, 'findById').resolves({ id })
|
|
//
|
|
// passport.deserializeUser(id, done)
|
|
// })
|
|
//
|
|
// it('should catch and handle errors', () => {
|
|
// // Force an error
|
|
// sandbox.stub(User, 'findById').rejects(new Error('test error'))
|
|
//
|
|
// passport.deserializeUser(id, done)
|
|
// })
|
|
// })
|
|
//
|
|
// describe('#passportCallback', () => {
|
|
// it('should return if user is found', () => {
|
|
// // Mock Users model.
|
|
// sandbox.stub(User, 'findOne').resolves({ id })
|
|
//
|
|
// passportCallback(id, 'password', done)
|
|
// })
|
|
//
|
|
// it('should return if password is validated', () => {
|
|
// // Mock Users model.
|
|
// sandbox.stub(User, 'findOne').resolves(new adaptersMock.localdb.Users())
|
|
//
|
|
// passportCallback(id, 'password', done)
|
|
// })
|
|
//
|
|
// it('should catch a high-level error', () => {
|
|
// // Force an error
|
|
// sandbox.stub(User, 'findOne').rejects(new Error('test error'))
|
|
//
|
|
// passportCallback(id, 'password', done)
|
|
// })
|
|
// })
|
|
// })
|