Skip to content

Instantly share code, notes, and snippets.

@allain
Created April 17, 2019 17:14
Show Gist options
  • Save allain/762ee11f2217152d687e99feba6e36aa to your computer and use it in GitHub Desktop.
Save allain/762ee11f2217152d687e99feba6e36aa to your computer and use it in GitHub Desktop.
Amazing things with pikapkg and tree shaking
import AgentRepo from './AgentRepo'
class AgentMemoryRepo extends AgentRepo {
load() {
}
}
import AgentRepo, {contract} from './AgentRepo'
import AgentMemoryRepo from './AgentMemoryRepo'
describe('AgentMemoryRepo', () => {
contract(() => new AgentMemoryRepo())
it('can be created', () => expect(new AgentMemoryRepo()).toBeInstanceOf(AgentMemoryRepo))
})
export default class AgentRepo {}
export function contract(builder) {
it('can be created', () => expect(builder()).toBeInstanceOf(AgentRepo))
it('exposes load method', () => {
const a = builder()
expect(a.load).toBeInstanceOf(Function)
})
}
import AgentMemoryRepo from './AgentMemoryRepo.js'
const r = new AgentMemoryRepo()
console.log(r.load(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment