config.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { DebuggerConfig } from '../src/config';
  2. describe('DebuggerConfig', () => {
  3. const kernel = 'python';
  4. let config: DebuggerConfig;
  5. beforeEach(() => {
  6. config = new DebuggerConfig();
  7. });
  8. describe('#getCodeId', () => {
  9. it('should compute a valid code id when the parameters are set', () => {
  10. const [prefix, suffix] = ['foo', 'bar'];
  11. config.setHashParams({ method: 'Murmur2', seed: 'bar', kernel });
  12. config.setTmpFileParams({ prefix, suffix, kernel });
  13. const codeId = config.getCodeId('i = 0', kernel);
  14. expect(codeId.startsWith(prefix)).toBe(true);
  15. expect(codeId.endsWith(suffix)).toBe(true);
  16. });
  17. it('should throw if the kernel does not have hash parameters', () => {
  18. config.setTmpFileParams({ prefix: 'foo', suffix: 'bar', kernel });
  19. expect(() => {
  20. config.getCodeId('i = 0', kernel);
  21. }).toThrow('has no hashing params');
  22. });
  23. it('should throw if the kernel does not have tmp file parameters', () => {
  24. config.setHashParams({ method: 'Murmur2', seed: 'bar', kernel });
  25. expect(() => {
  26. config.getCodeId('i = 0', kernel);
  27. }).toThrow('has no tmp file params');
  28. });
  29. });
  30. });