Skip to content

Commit ce5eff4

Browse files
committed
add failing test
1 parent 1a7eb4d commit ce5eff4

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/api/api.test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,35 @@ describe('api', () => {
9898
const result = await downloadInput(2022, 1, 'ASDF');
9999
expect(result).toBe(expected);
100100
});
101+
102+
test('does not trim start of input', async () => {
103+
const expected = '\t1234\n5678\n9101112';
104+
mockFetch.mockImplementation(() =>
105+
Promise.resolve({
106+
ok: true,
107+
status: 200,
108+
text: () => Promise.resolve(expected),
109+
})
110+
);
111+
const result = await downloadInput(2022, 1, 'ASDF');
112+
expect(result).toBe(expected);
113+
});
114+
115+
test('trims end of input', async () => {
116+
const expected = '1234\n5678\n9101112';
117+
mockFetch.mockImplementation(() =>
118+
Promise.resolve({
119+
ok: true,
120+
status: 200,
121+
text: () => Promise.resolve(`${expected}\t\n`),
122+
})
123+
);
124+
const result = await downloadInput(2022, 1, 'ASDF');
125+
expect(result).toBe(expected);
126+
});
101127
});
102128

103-
describe('submitSolution', () => {
129+
describe('submitSolution()', () => {
104130
test.each([undefined, null, ''])(
105131
'throws if authentication token is: "%s"',
106132
async (value) => {

0 commit comments

Comments
 (0)