summaryrefslogtreecommitdiffhomepage
path: root/test/enum.spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/enum.spec.js')
-rw-r--r--test/enum.spec.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/enum.spec.js b/test/enum.spec.js
new file mode 100644
index 0000000000..dec15b219c
--- /dev/null
+++ b/test/enum.spec.js
@@ -0,0 +1,22 @@
+import { expect } from 'chai';
+import Enum from '../app/lib/enum';
+
+describe('enum', () => {
+ it('should be able to compare values', () => {
+ const e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST');
+ expect(e.NORTH).to.be.equal('NORTH');
+ });
+
+ it('should not be able to modify enum', () => {
+ let e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST');
+ expect(() => e.ANYWHERE = 'ANYWHERE').to.throw();
+ });
+
+ it('should be able to validate enum keys', () => {
+ let e = Enum('NORTH', 'SOUTH', 'WEST', 'EAST');
+ expect(e.isValid('SOUTH')).to.be.true;
+ expect(e.isValid('ANYWHERE')).to.be.false;
+ expect(e.isValid()).to.be.false;
+ expect(e.isValid(null)).to.be.false;
+ });
+});