Skip to content

Instantly share code, notes, and snippets.

@gunar
Last active March 12, 2019 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gunar/9851b191e48315296ed3626d78e28c77 to your computer and use it in GitHub Desktop.
Save gunar/9851b191e48315296ed3626d78e28c77 to your computer and use it in GitHub Desktop.
// Property-based test
describe('properties', () => {
it('is a bijection', () => {
fc.assert(fc.property(
fc.integer(1, Number.MAX_SAFE_INTEGER),
seed => decode(encode(seed)) === seed
))
});
})
// Example-based test
describe('record locator module', () => {
it('should encode integers into record locator strings', () => {
recordLocator.encode(270600).should.equal('AAAA');
recordLocator.encode(1048575).should.equal('ZZZZ');
recordLocator.encode(345560).should.equal('DKHR');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment