From ab5313bf716205d27cde2c80f17ddec2f5aa1ae2 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Sat, 6 Aug 2022 21:07:14 +0800 Subject: [PATCH] Add some tests --- .../tests/rules/member-ordering.test.ts | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index 91ec61d4cc2..32cf004cf7a 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -1264,6 +1264,16 @@ class Foo { `, options: [{ default: ['method', 'field', 'static-initialization'] }], }, + { + code: ` +class Foo { + f = 1; + static {} + m() {} +} + `, + options: [{ default: ['field', 'static-initialization', 'method'] }], + }, ` interface Foo { [Z: string]: any; @@ -4050,6 +4060,82 @@ class Foo { }, ], }, + { + code: ` +class Foo { + f = 1; + static {} + m() {} +} + `, + options: [{ default: ['static-initialization', 'field', 'method'] }], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'static block', + rank: 'field', + }, + line: 4, + column: 3, + }, + ], + }, + { + code: ` +class Foo { + static {} + f = 1; + m() {} +} + `, + options: [{ default: ['field', 'static-initialization', 'method'] }], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'f', + rank: 'static initialization', + }, + line: 4, + column: 3, + }, + ], + }, + { + code: ` +class Foo { + private mp() {} + static {} + public m() {} + @dec + md() {} +} + `, + options: [ + { default: ['decorated-method', 'static-initialization', 'method'] }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'static block', + rank: 'method', + }, + line: 4, + column: 3, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'md', + rank: 'method', + }, + line: 6, + column: 3, + }, + ], + }, ], };