Skip to content

Instantly share code, notes, and snippets.

@darkwebdev
Created August 29, 2018 18:11
Show Gist options
  • Save darkwebdev/23a47a30ea3b24ab42b9412f353f1879 to your computer and use it in GitHub Desktop.
Save darkwebdev/23a47a30ea3b24ab42b9412f353f1879 to your computer and use it in GitHub Desktop.
module.exports = (...args) =>
args.reduce((instance, arg) => ({
...instance,
[arg]: Symbol(arg)
}), {})
const { expect } = require('chai')
const Enum = require('enum')
const DIRECTION = Enum('NORTH', 'SOUTH', 'WEST', 'EAST')
const DIR = Enum('NORTH', 'SOUTH', 'WEST', 'EAST')
describe('Enum()', () => {
it('should diff between different enum instances', () => {
expect(DIRECTION.NORTH).to.equal(DIRECTION.NORTH)
expect(DIRECTION.NORTH).to.not.equal(DIR.NORTH)
})
it('should be able to convert to string', () => {
expect(DIRECTION.NORTH.toString()).to.equal('Symbol(NORTH)')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment