File size: 1,407 Bytes
7aec436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import optimizeSb3 from '../../src/packager/minify/sb3';

const clone = (obj) => JSON.parse(JSON.stringify(obj));

const emptyTarget = () => ({
  name: '',
  blocks: {},
  comments: {},
  variables: {},
  lists: {},
  broadcasts: {},
});

test('does not throw if project does not have monitors', () => {
  const data = {
    targets: [],
    meta: {}
  };
  optimizeSb3(clone(data));
});

test('removes comments', () => {
  const data = {
    targets: [
      {
        ...emptyTarget(),
        comments: {
          "a": {
            "text": "wregoiujji"
          },
          "b": {
            "text": "Configuration for https://turbowarp.org/\nDo not edit by hand\n{\"framerate\":30,\"runtimeOptions\":{\"maxClones\":300,\"miscLimits\":false,\"fencing\":true},\"interpolation\":false,\"turbo\":false,\"hq\":true} // _twconfig_"
          },
          "c": {
            "text": " // _gamepad_"
          }
        }
      }
    ]
  };
  const optimized = optimizeSb3(clone(data));
  expect(Object.values(optimized.targets[0].comments)).toEqual([
    {
      "text": "Configuration for https://turbowarp.org/\nDo not edit by hand\n{\"framerate\":30,\"runtimeOptions\":{\"maxClones\":300,\"miscLimits\":false,\"fencing\":true},\"interpolation\":false,\"turbo\":false,\"hq\":true} // _twconfig_"
    },
    {
      text: " // _gamepad_"
    }
  ]);
});