Skip to content

Commit a3cb342

Browse files
committed
Add unit test
1 parent 91d6c0b commit a3cb342

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/components/cylc/log/index.js

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
import { shallowMount } from '@vue/test-utils'
19+
import Log from '@/components/cylc/log/Log.vue'
20+
21+
describe('Log component', () => {
22+
const wrapper = shallowMount(Log, {
23+
props: {
24+
logs: [],
25+
},
26+
})
27+
28+
describe.each([
29+
{ line: '' },
30+
{ line: ' ' },
31+
{ line: 'Hello, Mr. Thompson' },
32+
{ line: '1969-07-20T20:17:00 the eagle has landed', expected: 'the eagle has landed' },
33+
{ line: '2038-01-19T03:14:07Z INFO - oops!', expected: 'INFO - oops!' },
34+
{ line: '2038-01-19T03:14:07+02:15 ', expected: '' },
35+
{ line: '2038-01-19T03:14:07-12:03 meow', expected: ' meow' },
36+
{ line: 'INIT_TIME=2023-04-27T13:53:09+01:00' },
37+
38+
])('stripTimestamp($line)', ({ line, expected }) => {
39+
expected ??= line
40+
it(`returns '${expected}'`, () => {
41+
expect(wrapper.vm.stripTimestamp(line)).toEqual(expected)
42+
})
43+
})
44+
})

0 commit comments

Comments
 (0)