Skip to content

Commit 0e35534

Browse files
committed
Improve tests
1 parent 373ae4c commit 0e35534

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

test/audio_channel_layout_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,24 @@ void main() {
1616
expect(layout, isNotNull);
1717
expect('Surround 7.1.4', layout!.toStringWithPrefix());
1818
});
19+
20+
test("Invalid/edge inputs return null", () {
21+
expect(AudioChannelLayout.parse(null), isNull);
22+
expect(AudioChannelLayout.parse(''), isNull);
23+
expect(AudioChannelLayout.parse(' '), isNull);
24+
expect(AudioChannelLayout.parse('abc'), isNull);
25+
expect(AudioChannelLayout.parse('2.'), isNull);
26+
expect(AudioChannelLayout.parse('.1'), isNull);
27+
});
28+
29+
test("toString without aux channel prints 'main.sub'", () {
30+
final layout = AudioChannelLayout.parse('2.1')!;
31+
expect(layout.toString(), '2.1');
32+
});
33+
34+
test("Prefix boundary: 3.x => Stereo, 4.x => Surround", () {
35+
expect(AudioChannelLayout.parse('3.0')!.toStringWithPrefix(), 'Stereo 3.0');
36+
expect(AudioChannelLayout.parse('4.0')!.toStringWithPrefix(), 'Surround 4.0');
37+
});
1938
});
2039
}

test/pipelines_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import 'package:running_on_dart/src/util/pipelines.dart';
2+
import 'package:test/test.dart';
3+
4+
void main() {
5+
group('pipelines helpers', () {
6+
test('getEmbedTitle returns "Task i of n"', () {
7+
expect(getEmbedTitle(1, 3), 'Task 1 of 3');
8+
expect(getEmbedTitle(3, 3), 'Task 3 of 3');
9+
});
10+
11+
test('getInitialEmbed initializes title/description/author', () {
12+
final embed = getInitialEmbed(2, 'Build');
13+
14+
expect(embed.title, 'Task 1 of 2');
15+
expect(embed.description, 'Starting...');
16+
expect(embed.author?.name, 'Pipeline Build');
17+
});
18+
});
19+
}

test/query_builder_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ void main() {
4545

4646
expect(buf.toStringClean(), 'SELECT * FROM t;');
4747
});
48+
test("toStringClean collapses multiple spaces across query (no tabs/newlines)", () {
49+
final buf = StringBuffer('SELECT a FROM t WHERE x = 1 ;');
50+
expect(buf.toStringClean(), 'SELECT a FROM t WHERE x = 1;');
51+
});
52+
53+
test("toStringClean keeps single spaces between tokens and removes space before semicolon", () {
54+
final buf = StringBuffer('INSERT INTO t (a,b) VALUES (1,2) ;');
55+
expect(buf.toStringClean(), 'INSERT INTO t (a,b) VALUES (1,2);');
56+
});
4857
});
4958

5059
group("RawQuery", () {

test/utils_test.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,26 @@ void main() {
166166
expect(result, {'a': '1', 'b': '2', 'c': null});
167167
});
168168
});
169+
170+
group("Additional utils edge cases", () {
171+
test('spliceEmbedsForMessageBuilders with empty list yields no messages', () {
172+
final result = spliceEmbedsForMessageBuilders(const <EmbedBuilder>[]).toList();
173+
expect(result, isEmpty);
174+
});
175+
176+
test('getDurationFromStringOrDefault invalid string returns default', () {
177+
expect(
178+
getDurationFromStringOrDefault('not a duration', const Duration(seconds: 5)),
179+
const Duration(seconds: 5),
180+
);
181+
});
182+
183+
test('valueOrNull returns original non-empty string (not trimmed)', () {
184+
expect(valueOrNull(' value '), ' value ');
185+
});
186+
187+
test('generateRandomString supports zero length', () {
188+
expect(generateRandomString(0), '');
189+
});
190+
});
169191
}

0 commit comments

Comments
 (0)