IdGeneratorSpec.js 672 B

123456789101112131415161718192021222324252627282930313233
  1. import IdGenerator from 'lib/util/IdGenerator';
  2. describe('util/IdGenerator', function() {
  3. it('should configure with prefix', function() {
  4. // when
  5. var foos = new IdGenerator('foo');
  6. // then
  7. expect(foos.next()).to.match(/^foo-(\d+)-1$/);
  8. expect(foos.next()).to.match(/^foo-(\d+)-2$/);
  9. expect(foos.next()).to.match(/^foo-(\d+)-3$/);
  10. });
  11. it('should configure without prefix', function() {
  12. // when
  13. var foos = new IdGenerator();
  14. // then
  15. expect(foos._prefix).to.exist;
  16. expect(foos.next()).to.match(/^(\d+)-1$/);
  17. expect(foos.next()).to.match(/^(\d+)-2$/);
  18. expect(foos.next()).to.match(/^(\d+)-3$/);
  19. });
  20. });