import test from 'ava';
import extractAssetNames from './extractAssetNames';
var cases = [{
  // double quote
  code: "rule.\u3064\u304F\u308B(\"\u30D7\u30EC\u30A4\u30E4\u30FC\")",
  assetNames: ['プレイヤー']
}, {
  // 2 assets per line
  code: "rule.\u3064\u304F\u308B('\u30D7\u30EC\u30A4\u30E4\u30FC')rule.\u3064\u304F\u308B('\u30B9\u30E9\u30A4\u30E0')",
  assetNames: ['プレイヤー', 'スライム']
}, {
  // しょうかんする
  code: "this.\u3057\u3087\u3046\u304B\u3093\u3059\u308B('\u30DC\u30E0')",
  assetNames: ['ボム']
}, {
  // へんしんする
  code: "this.\u3078\u3093\u3057\u3093\u3059\u308B('\u8D64\u8272\u306E\u30B9\u30E9\u30A4\u30E0')",
  assetNames: ['赤色のスライム']
}, {
  // real code
  code: "\n// import 'https://unpkg.com/@hackforplay/common@^0.11/dist/register.js';\n\nrule.\u30B2\u30FC\u30E0\u304C\u306F\u3058\u307E\u3063\u305F\u3068\u304D(async function() {\n\t// \u30DE\u30C3\u30D7\uFF08\u03B2\u7248\uFF09\u306E\u30B3\u30FC\u30C9\u306F\u3001\u3053\u306E\u4E0B\u306B\u8CBC\u308A\u4ED8\u3051\u308B\n\n\tHack.changeMap('map1'); // map1 \u3092\u30ED\u30FC\u30C9\n\n\trule.\u3064\u304F\u308B('\u30D7\u30EC\u30A4\u30E4\u30FC', 3, 5, 'map1', ('\u25BC \u3080\u304D', Dir.\u3057\u305F));\n\n\trule.\u3064\u304F\u308B('\u9752\u8272\u306E\u30B9\u30E9\u30A4\u30E0', 1, 4, 'map1', ('\u25BC \u3080\u304D', Dir.\u3072\u3060\u308A))\n\n\t/*+ \u30B2\u30FC\u30E0\u304C\u306F\u3058\u307E\u3063\u305F\u3068\u304D */\n});",
  assetNames: ['プレイヤー', '青色のスライム']
}, {
  // skill
  code: "this.skill = '\u30D3\u30FC\u30E0'",
  assetNames: ['ビーム']
}, {
  code: '',
  assetNames: []
}];
var invalids = [{
  code: {}
}];
test('extractAssetNames', function (t) {
  for (var _i = 0; _i < cases.length; _i++) {
    var _cases$_i = cases[_i],
        code = _cases$_i.code,
        assetNames = _cases$_i.assetNames;
    t.deepEqual(extractAssetNames(code), assetNames);
  }

  var _loop = function _loop() {
    var code = invalids[_i2].code;
    t.throws(function () {
      return extractAssetNames(code);
    }); // TypeError
  };

  for (var _i2 = 0; _i2 < invalids.length; _i2++) {
    _loop();
  }
});