OverviewFilesCommitsIssuesDocsReleasesPeers

ap-bridge / test / records-contract.test.js

30 lines · javascript ref:
import '../lib/bare-globals.js'
// RecordSource (the DID path) must satisfy the same contract FavelaSource does. Stating it for both
// is the point — a contract only one side is held to is a comment.
import test from 'brittle'
import { recordSourceContract } from './record-source-contract.js'
import { RecordSource } from '../lib/records.js'

const NOW = '2026-09-08T00:00:00.000Z'
const peer = () => ({
  async listRecords (collection) {
    if (collection !== 'app.bsky.feed.post') return { records: [], cursor: null }
    return {
      records: [{ rkey: '3abc', value: { text: 'hello world', createdAt: NOW } }],
      cursor: null
    }
  },
  async getRecord (collection, rkey) {
    if (rkey !== '3abc') return null
    return { rkey, value: { text: 'hello world', createdAt: NOW } }
  }
})

recordSourceContract(test, 'RecordSource', async () => new RecordSource({
  peer: peer(),
  host: 'ap.7rnx.net',
  did: 'did:plc:test',
  actorId: 'https://ap.7rnx.net/ap/actor',
  followersId: 'https://ap.7rnx.net/ap/followers'
}))