config.spec.ts 1.3 KB

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