Skip to content

Commit edd7cb0

Browse files
authored
Merge pull request #1039 from dddjava/agent/refactor-js-test-structure
テストごとに大きく囲う
2 parents 6f7640c + dae874b commit edd7cb0

3 files changed

Lines changed: 330 additions & 184 deletions

File tree

jig-core/src/test/js/glossary.test.js

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -44,81 +44,83 @@ function setupDocument() {
4444
return doc;
4545
}
4646

47-
test.describe('glossary.js 絞り込み', () => {
48-
test('種類・説明有無・検索語でフィルタする', () => {
49-
const terms = [
50-
{title: 'Account', description: 'desc', kind: 'クラス'},
51-
{title: 'Order', description: '', kind: 'クラス'},
52-
{title: 'Repo', description: 'data', kind: 'パッケージ'},
53-
{title: 'Submit', description: 'action', kind: 'メソッド'},
54-
];
55-
const controls = {
56-
showEmptyDescription: {checked: false},
57-
showPackage: {checked: false},
58-
showClass: {checked: true},
59-
showMethod: {checked: true},
60-
showField: {checked: true},
61-
searchInput: {value: 'acc'},
62-
};
63-
64-
const result = glossary.getFilteredTerms(terms, controls);
65-
66-
assert.deepEqual(result, [terms[0]]);
47+
test.describe('glossary.js', () => {
48+
test.describe('絞り込み', () => {
49+
test('種類・説明有無・検索語でフィルタする', () => {
50+
const terms = [
51+
{title: 'Account', description: 'desc', kind: 'クラス'},
52+
{title: 'Order', description: '', kind: 'クラス'},
53+
{title: 'Repo', description: 'data', kind: 'パッケージ'},
54+
{title: 'Submit', description: 'action', kind: 'メソッド'},
55+
];
56+
const controls = {
57+
showEmptyDescription: {checked: false},
58+
showPackage: {checked: false},
59+
showClass: {checked: true},
60+
showMethod: {checked: true},
61+
showField: {checked: true},
62+
searchInput: {value: 'acc'},
63+
};
64+
65+
const result = glossary.getFilteredTerms(terms, controls);
66+
67+
assert.deepEqual(result, [terms[0]]);
68+
});
6769
});
68-
});
6970

70-
test.describe('glossary.js CSV', () => {
71-
test('CSV値はクォートし、改行とダブルクォートを処理する', () => {
72-
const value = '"a"\r\nline';
71+
test.describe('CSV', () => {
72+
test('CSV値はクォートし、改行とダブルクォートを処理する', () => {
73+
const value = '"a"\r\nline';
7374

74-
const escaped = glossary.escapeCsvValue(value);
75+
const escaped = glossary.escapeCsvValue(value);
7576

76-
assert.equal(escaped, '"""a""\nline"');
77-
});
77+
assert.equal(escaped, '"""a""\nline"');
78+
});
7879

79-
test('CSVにヘッダーと行を出力する', () => {
80-
const terms = [
81-
{simpleText: 'Account', title: '口座', description: 'desc', kind: 'クラス', fqn: 'app.Account'},
82-
];
80+
test('CSVにヘッダーと行を出力する', () => {
81+
const terms = [
82+
{simpleText: 'Account', title: '口座', description: 'desc', kind: 'クラス', fqn: 'app.Account'},
83+
];
8384

84-
const csv = glossary.buildGlossaryCsv(terms);
85+
const csv = glossary.buildGlossaryCsv(terms);
8586

86-
assert.equal(
87-
csv,
88-
'"用語(英名)","用語","説明","種類","識別子"\r\n' +
89-
'"Account","口座","desc","クラス","app.Account"'
90-
);
87+
assert.equal(
88+
csv,
89+
'"用語(英名)","用語","説明","種類","識別子"\r\n' +
90+
'"Account","口座","desc","クラス","app.Account"'
91+
);
92+
});
9193
});
92-
});
9394

94-
test.describe('glossary.js データ読み込み', () => {
95-
test('glossary-dataから用語一覧を取得する', () => {
96-
const doc = setupDocument();
97-
const dataElement = new Element('script');
98-
dataElement.textContent = JSON.stringify({terms: [{title: 'Account'}]});
99-
doc.elementsById.set('glossary-data', dataElement);
95+
test.describe('データ読み込み', () => {
96+
test('glossary-dataから用語一覧を取得する', () => {
97+
const doc = setupDocument();
98+
const dataElement = new Element('script');
99+
dataElement.textContent = JSON.stringify({terms: [{title: 'Account'}]});
100+
doc.elementsById.set('glossary-data', dataElement);
100101

101-
const terms = glossary.getGlossaryData();
102+
const terms = glossary.getGlossaryData();
102103

103-
assert.equal(terms.length, 1);
104-
assert.equal(terms[0].title, 'Account');
104+
assert.equal(terms.length, 1);
105+
assert.equal(terms[0].title, 'Account');
106+
});
105107
});
106-
});
107108

108-
test.describe('glossary.js 描画', () => {
109-
test('用語一覧をDOMに描画する', () => {
110-
const doc = setupDocument();
111-
const list = new Element('div');
112-
list.innerHTML = 'existing';
113-
doc.elementsById.set('term-list', list);
114-
115-
glossary.renderGlossaryTerms([
116-
{title: 'Account', simpleText: 'Account', fqn: 'app.Account', kind: 'クラス', description: 'desc'},
117-
{title: 'Order', simpleText: 'Order', fqn: 'app.Order', kind: 'クラス', description: ''},
118-
]);
119-
120-
assert.equal(list.innerHTML, '');
121-
assert.equal(list.children.length, 1);
122-
assert.equal(list.children[0].children.length, 2);
109+
test.describe('描画', () => {
110+
test('用語一覧をDOMに描画する', () => {
111+
const doc = setupDocument();
112+
const list = new Element('div');
113+
list.innerHTML = 'existing';
114+
doc.elementsById.set('term-list', list);
115+
116+
glossary.renderGlossaryTerms([
117+
{title: 'Account', simpleText: 'Account', fqn: 'app.Account', kind: 'クラス', description: 'desc'},
118+
{title: 'Order', simpleText: 'Order', fqn: 'app.Order', kind: 'クラス', description: ''},
119+
]);
120+
121+
assert.equal(list.innerHTML, '');
122+
assert.equal(list.children.length, 1);
123+
assert.equal(list.children[0].children.length, 2);
124+
});
123125
});
124126
});

0 commit comments

Comments
 (0)