'use strict';

// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------

var rule = require('../rules/order-in-routes');
var RuleTester = require('eslint').RuleTester;

// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------

var eslintTester = new RuleTester();
eslintTester.run('order-in-components', rule, {
  valid: [
    {
      code: 'export default Route.extend({currentUser: service(), queryParams: {}, customProp: "test", model() {}, beforeModel() {}, actions: {}, _customAction() {}, _customAction2: function() {}, tSomeTask: task(function* () {}) });',
      parserOptions: {ecmaVersion: 6, sourceType: "module"},
    },
    {
      code: 'export default Route.extend({model() {}, actions: { test() { return this._customAction() } }, _customAction() {} });',
      parserOptions: {ecmaVersion: 6, sourceType: "module"},
    },
  ],
  invalid: [
    {
      code: 'export default Route.extend({queryParams: {}, currentUser: service(), customProp: "test", model() {}, beforeModel() {}, actions: {}, _customAction() {} });',
      parserOptions: {ecmaVersion: 6, sourceType: "module"},
      errors: [{
        message: 'Check order of properties',
      }],
    },
    {
      code: 'export default Route.extend({customProp: "test", queryParams: {}, model() {}, beforeModel() {}, actions: {}, _customAction() {} });',
      parserOptions: {ecmaVersion: 6, sourceType: "module"},
      errors: [{
        message: 'Check order of properties',
      }],
    },
    {
      code: 'export default Route.extend({customProp: "test", queryParams: {}, beforeModel() {}, model() {}, actions: {}, _customAction() {} });',
      parserOptions: {ecmaVersion: 6, sourceType: "module"},
      errors: [{
        message: 'Check order of properties',
      }],
    },
    {
      code: 'export default Route.extend({queryParams: {}, customProp: "test", model() {}, _customAction() {}, actions: {} });',
      parserOptions: {ecmaVersion: 6, sourceType: "module"},
      errors: [{
        message: 'Check order of properties',
      }],
    },
    {
      code: 'export default Route.extend({model() {}, customProp: "test", actions: {} });',
      parserOptions: {ecmaVersion: 6, sourceType: "module"},
      errors: [{
        message: 'Check order of properties',
      }],
    },
  ]
});

@@ -1071,16 +1071,509 @@
 %0A    %7D,%0A
+    %7B%0A      code: 'export default Route.extend(%7Bmodel() %7B%7D, render() %7B%7D, init() %7B%7D %7D);',%0A      parserOptions: %7BecmaVersion: 6, sourceType: %22module%22%7D,%0A    %7D,%0A    %7B%0A      code: 'export default Route.extend(%7BmergedProperties: %7B%7D, model() %7B%7D, actions: %7B%7D %7D);',%0A      parserOptions: %7BecmaVersion: 6, sourceType: %22module%22%7D,%0A    %7D,%0A    %7B%0A      code: 'export default Route.extend(%7BmergedProperties: %7B%7D, test: %22asd%22, model() %7B%7D %7D);',%0A      parserOptions: %7BecmaVersion: 6, sourceType: %22module%22%7D,%0A    %7D,%0A
   %5D,%0A  i
@@ -3003,16 +3003,489 @@
 %0A    %7D,%0A
+    %7B%0A      code: 'export default Route.extend(%7Btest: %22asd%22, mergedProperties: %7B%7D, model() %7B%7D %7D);',%0A      parserOptions: %7BecmaVersion: 6, sourceType: %22module%22%7D,%0A      errors: %5B%7B%0A        message: 'Check order of properties',%0A      %7D%5D,%0A    %7D,%0A    %7B%0A      code: 'export default Route.extend(%7Btest: %22asd%22, _test2() %7B%7D, model() %7B%7D %7D);',%0A      parserOptions: %7BecmaVersion: 6, sourceType: %22module%22%7D,%0A      errors: %5B%7B%0A        message: 'Check order of properties',%0A      %7D%5D,%0A    %7D,%0A
   %5D%0A%7D);%0A

Add tests