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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
;;; complete-test.el --- ERT for ledger-mode -*- lexical-binding: t; -*-
;; Copyright (C) 2003-2017 John Wiegley <johnw AT gnu DOT org>
;; Author: Thierry <thdox AT free DOT fr>
;; Keywords: languages
;; Homepage: https://github.com/ledger/ledger-mode
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free Software
;; Foundation; either version 2 of the License, or (at your option) any later
;; version.
;;
;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
;; details.
;;
;; You should have received a copy of the GNU General Public License along with
;; this program; if not, write to the Free Software Foundation, Inc., 51
;; Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;; Regression tests for ledger-complete
;;; Code:
(require 'test-helper)
(ert-deftest ledger-complete/test-001 ()
"Regress test for Bug 969+582
http://bugs.ledger-cli.org/show_bug.cgi?id=969
http://bugs.ledger-cli.org/show_bug.cgi?id=582"
:tags '(complete regress)
(ledger-tests-with-temp-file
"2013/05/19 Retrait
Dépense:Alimentation:Épicerie 35 € ; Marché
Dépense:Alimentation:Épicerie 8,1 € ; Arum café
Dépense:Liquide
* Passif:Crédit:BanqueAccord -60,00 €"
(forward-line 1)
(move-end-of-line 1)
(newline)
(insert " Dé")
(call-interactively #'ledger-magic-tab)
(should
(equal (buffer-string)
"2013/05/19 Retrait
Dépense:Alimentation:Épicerie 35 € ; Marché
Dépense:
Dépense:Alimentation:Épicerie 8,1 € ; Arum café
Dépense:Liquide
* Passif:Crédit:BanqueAccord -60,00 €"))))
(ert-deftest ledger-complete/test-002 ()
"Regress test for Bug 252
http://bugs.ledger-cli.org/show_bug.cgi?id=252"
:tags '(complete regress)
(ledger-tests-with-temp-file
"2010/04/08 payee
account1 1 €
account2
"
(goto-char (point-max))
(newline)
(insert "2016/09/01 payee")
(ledger-fully-complete-xact)
(should
(equal (buffer-string)
"2010/04/08 payee
account1 1 €
account2
2016/09/01 payee
account1 1 €
account2
"))))
(ert-deftest ledger-complete/test-find-accounts-in-buffer ()
(let ((ledger "*** Expenses
account Expenses:Accomodation
account Assets:Cash ; some comment
account Assets:Current
alias 1187465S022
commodity EUR
format 1,000.00 EUR
tag ofxid
2018/05/07 * Company
Assets:Current -38.33 EUR
; ofxid: someid
Expenses:Utilities:Insurance 38.00 EUR
[Dimensions:Foo] 30.00 EUR
[Expenses:Accomodation] 8.33 EUR
[Dimensions:Equity] -38.33 EUR
(Something) 43.00 EUR
"))
(with-temp-buffer
(insert ledger)
(should (equal
(ledger-accounts-list-in-buffer)
(list ; I don't know why accounts are sorted in reverse order
"Something"
"Expenses:Utilities:Insurance"
"Expenses:Accomodation"
"Dimensions:Foo"
"Dimensions:Equity"
"Assets:Current"
"Assets:Cash"))))))
(provide 'complete-test)
;;; complete-test.el ends here
|