Created
August 29, 2018 18:11
-
-
Save darkwebdev/23a47a30ea3b24ab42b9412f353f1879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (...args) => | |
args.reduce((instance, arg) => ({ | |
...instance, | |
[arg]: Symbol(arg) | |
}), {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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