Conditions | 1 |
Paths | 1 |
Total Lines | 80 |
Lines | 80 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /*! |
||
8 | describe('read 4-bit file from disk and write to new file', function() { |
||
9 | |||
10 | let fs = require("fs"); |
||
11 | let wavefile = require("../index.js"); |
||
12 | let path = "test/files/"; |
||
13 | |||
14 | let wBytes = fs.readFileSync(path + "4bit-imaadpcm-8kHz-noBext-mono.wav"); |
||
15 | let wav = new wavefile.WaveFile(wBytes); |
||
16 | let wav2 = new wavefile.WaveFile(wav.toBytes()); |
||
17 | fs.writeFileSync(path + "/out/4bit-imaadpcm-8kHz-noBext-mono.wav", wav2.toBytes()); |
||
18 | |||
19 | it("chunkId should be 'RIFF'", |
||
20 | function() { |
||
21 | assert.equal(wav2.chunkId, "RIFF"); |
||
22 | }); |
||
23 | it("subChunk1Id should be 'fmt '", |
||
24 | function() { |
||
25 | assert.equal(wav2.subChunk1Id, "fmt "); |
||
26 | }); |
||
27 | it("format should be 'WAVE'", |
||
28 | function() { |
||
29 | assert.equal(wav2.format, "WAVE"); |
||
30 | }); |
||
31 | it("subChunk1Size should be 20", |
||
32 | function() { |
||
33 | assert.equal(wav2.subChunk1Size, 20); |
||
34 | }); |
||
35 | it("audioFormat should be 17 (IMA ADPCM)", |
||
36 | function() { |
||
37 | assert.equal(wav2.audioFormat, 17); |
||
38 | }); |
||
39 | it("numChannels should be 1", |
||
40 | function() { |
||
41 | assert.equal(wav2.numChannels, 1); |
||
42 | }); |
||
43 | it("sampleRate should be 8000", |
||
44 | function() { |
||
45 | assert.equal(wav2.sampleRate, 8000); |
||
46 | }); |
||
47 | it("byteRate should be 4055", |
||
48 | function() { |
||
49 | assert.equal(wav2.byteRate, 4055); |
||
50 | }); |
||
51 | it("blockAlign should be 256", |
||
52 | function() { |
||
53 | assert.equal(wav2.blockAlign, 256); |
||
54 | }); |
||
55 | it("bitsPerSample should be 4", |
||
56 | function() { |
||
57 | assert.equal(wav2.bitsPerSample, 4); |
||
58 | }); |
||
59 | it("factChunkId should be 'fact'", |
||
60 | function() { |
||
61 | assert.equal(wav2.factChunkId, 'fact'); |
||
62 | }); |
||
63 | it("factChunkSize should be 4", |
||
64 | function() { |
||
65 | assert.equal(wav2.factChunkSize, 4); |
||
66 | }); |
||
67 | it("subChunk2Id should be 'data'", |
||
68 | function() { |
||
69 | assert.equal(wav2.subChunk2Id, 'data'); |
||
70 | }); |
||
71 | it("subChunk2Size should be > 0", |
||
72 | function() { |
||
73 | assert.ok(wav2.subChunk2Size > 0); |
||
74 | }); |
||
75 | it("samples.length should be > 0", |
||
76 | function() { |
||
77 | assert.ok(wav2.samples_.length > 0); |
||
78 | }); |
||
79 | it("samples_ on the new file should have the same length as in the original file", |
||
80 | function() { |
||
81 | assert.equal(wav2.samples_.length, wav.samples_.length); |
||
82 | }); |
||
83 | it("samples_ on the new file should be same as the original file", |
||
84 | function() { |
||
85 | assert.deepEqual(wav2.samples_, wav.samples_); |
||
86 | }); |
||
87 | }); |
||
88 |