mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Fix JS and switch to Wallaby
This commit is contained in:
parent
0a43fbe58a
commit
065e7e02c9
@ -37,10 +37,22 @@ exports.config = {
|
||||
// Configure your plugins
|
||||
plugins: {
|
||||
babel: {
|
||||
// Do not use ES6 compiler in vendor code
|
||||
presets: ["es2015", "es2016", "react"],
|
||||
ignore: [/vendor/]
|
||||
}
|
||||
plugins: [
|
||||
'transform-object-rest-spread',
|
||||
'transform-class-properties',
|
||||
],
|
||||
presets: [
|
||||
[
|
||||
'env', {
|
||||
'browsers': [ '> 5% in US' ],
|
||||
'useBuiltIns': true,
|
||||
},
|
||||
],
|
||||
'es2015',
|
||||
'react',
|
||||
],
|
||||
ignore: [ /vendor/ ],
|
||||
},
|
||||
},
|
||||
|
||||
modules: {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
import "babel-polyfill";
|
||||
import "phoenix_html"
|
||||
|
||||
import React from "react";
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import Immutable from "immutable";
|
||||
import { Map } from "immutable";
|
||||
|
||||
import defaultState from "../store/default-state";
|
||||
|
||||
|
||||
148
assets/package-lock.json
generated
148
assets/package-lock.json
generated
@ -450,6 +450,12 @@
|
||||
"integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=",
|
||||
"dev": true
|
||||
},
|
||||
"babel-plugin-syntax-class-properties": {
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz",
|
||||
"integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=",
|
||||
"dev": true
|
||||
},
|
||||
"babel-plugin-syntax-exponentiation-operator": {
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz",
|
||||
@ -468,6 +474,12 @@
|
||||
"integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=",
|
||||
"dev": true
|
||||
},
|
||||
"babel-plugin-syntax-object-rest-spread": {
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz",
|
||||
"integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=",
|
||||
"dev": true
|
||||
},
|
||||
"babel-plugin-syntax-trailing-function-commas": {
|
||||
"version": "6.22.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz",
|
||||
@ -485,6 +497,18 @@
|
||||
"babel-runtime": "6.26.0"
|
||||
}
|
||||
},
|
||||
"babel-plugin-transform-class-properties": {
|
||||
"version": "6.24.1",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz",
|
||||
"integrity": "sha1-anl2PqYdM9NvN7YRqp3vgagbRqw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-helper-function-name": "6.24.1",
|
||||
"babel-plugin-syntax-class-properties": "6.13.0",
|
||||
"babel-runtime": "6.26.0",
|
||||
"babel-template": "6.26.0"
|
||||
}
|
||||
},
|
||||
"babel-plugin-transform-es2015-arrow-functions": {
|
||||
"version": "6.22.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz",
|
||||
@ -740,6 +764,16 @@
|
||||
"babel-runtime": "6.26.0"
|
||||
}
|
||||
},
|
||||
"babel-plugin-transform-object-rest-spread": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz",
|
||||
"integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-plugin-syntax-object-rest-spread": "6.13.0",
|
||||
"babel-runtime": "6.26.0"
|
||||
}
|
||||
},
|
||||
"babel-plugin-transform-react-display-name": {
|
||||
"version": "6.25.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.25.0.tgz",
|
||||
@ -789,15 +823,6 @@
|
||||
"regenerator-transform": "0.10.1"
|
||||
}
|
||||
},
|
||||
"babel-plugin-transform-runtime": {
|
||||
"version": "6.23.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz",
|
||||
"integrity": "sha1-iEkNRGUC6puOfvsP4J7E2ZR5se4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-runtime": "6.26.0"
|
||||
}
|
||||
},
|
||||
"babel-plugin-transform-strict-mode": {
|
||||
"version": "6.24.1",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz",
|
||||
@ -808,6 +833,44 @@
|
||||
"babel-types": "6.26.0"
|
||||
}
|
||||
},
|
||||
"babel-preset-env": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz",
|
||||
"integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-plugin-check-es2015-constants": "6.22.0",
|
||||
"babel-plugin-syntax-trailing-function-commas": "6.22.0",
|
||||
"babel-plugin-transform-async-to-generator": "6.24.1",
|
||||
"babel-plugin-transform-es2015-arrow-functions": "6.22.0",
|
||||
"babel-plugin-transform-es2015-block-scoped-functions": "6.22.0",
|
||||
"babel-plugin-transform-es2015-block-scoping": "6.26.0",
|
||||
"babel-plugin-transform-es2015-classes": "6.24.1",
|
||||
"babel-plugin-transform-es2015-computed-properties": "6.24.1",
|
||||
"babel-plugin-transform-es2015-destructuring": "6.23.0",
|
||||
"babel-plugin-transform-es2015-duplicate-keys": "6.24.1",
|
||||
"babel-plugin-transform-es2015-for-of": "6.23.0",
|
||||
"babel-plugin-transform-es2015-function-name": "6.24.1",
|
||||
"babel-plugin-transform-es2015-literals": "6.22.0",
|
||||
"babel-plugin-transform-es2015-modules-amd": "6.24.1",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "6.26.0",
|
||||
"babel-plugin-transform-es2015-modules-systemjs": "6.24.1",
|
||||
"babel-plugin-transform-es2015-modules-umd": "6.24.1",
|
||||
"babel-plugin-transform-es2015-object-super": "6.24.1",
|
||||
"babel-plugin-transform-es2015-parameters": "6.24.1",
|
||||
"babel-plugin-transform-es2015-shorthand-properties": "6.24.1",
|
||||
"babel-plugin-transform-es2015-spread": "6.22.0",
|
||||
"babel-plugin-transform-es2015-sticky-regex": "6.24.1",
|
||||
"babel-plugin-transform-es2015-template-literals": "6.22.0",
|
||||
"babel-plugin-transform-es2015-typeof-symbol": "6.23.0",
|
||||
"babel-plugin-transform-es2015-unicode-regex": "6.24.1",
|
||||
"babel-plugin-transform-exponentiation-operator": "6.24.1",
|
||||
"babel-plugin-transform-regenerator": "6.26.0",
|
||||
"browserslist": "2.11.3",
|
||||
"invariant": "2.2.2",
|
||||
"semver": "5.5.0"
|
||||
}
|
||||
},
|
||||
"babel-preset-es2015": {
|
||||
"version": "6.24.1",
|
||||
"resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz",
|
||||
@ -1168,6 +1231,16 @@
|
||||
"parse-asn1": "5.1.0"
|
||||
}
|
||||
},
|
||||
"browserslist": {
|
||||
"version": "2.11.3",
|
||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.11.3.tgz",
|
||||
"integrity": "sha512-yWu5cXT7Av6mVwzWc8lMsJMHWn4xyjSuGYi4IozbVTLUOEYPSagUB8kiMDUHA1fS3zjr8nkxkn9jdvug4BBRmA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"caniuse-lite": "1.0.30000792",
|
||||
"electron-to-chromium": "1.3.31"
|
||||
}
|
||||
},
|
||||
"brunch": {
|
||||
"version": "2.10.12",
|
||||
"resolved": "https://registry.npmjs.org/brunch/-/brunch-2.10.12.tgz",
|
||||
@ -1273,6 +1346,12 @@
|
||||
"map-obj": "1.0.1"
|
||||
}
|
||||
},
|
||||
"caniuse-lite": {
|
||||
"version": "1.0.30000792",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000792.tgz",
|
||||
"integrity": "sha1-0M6pgfgRjzlhRxr7tDyaHlu/AzI=",
|
||||
"dev": true
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
|
||||
@ -1367,42 +1446,21 @@
|
||||
"integrity": "sha1-+zgB1FNGdknvNgPH1hoCvRKb3m0="
|
||||
},
|
||||
"clean-css": {
|
||||
"version": "3.4.28",
|
||||
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.28.tgz",
|
||||
"integrity": "sha1-vxlF6C/ICPVWlebd6uwBQA79A/8=",
|
||||
"version": "4.0.13",
|
||||
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.0.13.tgz",
|
||||
"integrity": "sha1-/rKhdgYtcqbD5iTZITysagxIXoA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "2.8.1",
|
||||
"source-map": "0.4.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
|
||||
"integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-readlink": "1.0.1"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.4.4",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
|
||||
"integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"amdefine": "1.0.1"
|
||||
}
|
||||
}
|
||||
"source-map": "0.5.7"
|
||||
}
|
||||
},
|
||||
"clean-css-brunch": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/clean-css-brunch/-/clean-css-brunch-2.0.0.tgz",
|
||||
"integrity": "sha1-N8J0dsRwigCUzWRsnEZKwZcMSxc=",
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/clean-css-brunch/-/clean-css-brunch-2.10.0.tgz",
|
||||
"integrity": "sha1-ahUeZQlYnNNB3OBJgaHHUGKiLRg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"clean-css": "3.4.28"
|
||||
"clean-css": "4.0.13"
|
||||
}
|
||||
},
|
||||
"cliui": {
|
||||
@ -1522,9 +1580,10 @@
|
||||
"dev": true
|
||||
},
|
||||
"core-js": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz",
|
||||
"integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY="
|
||||
"version": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz",
|
||||
"integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=",
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -1881,6 +1940,12 @@
|
||||
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=",
|
||||
"dev": true
|
||||
},
|
||||
"electron-to-chromium": {
|
||||
"version": "1.3.31",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.31.tgz",
|
||||
"integrity": "sha512-XE4CLbswkZgZFn34cKFy1xaX+F5LHxeDLjY1+rsK9asDzknhbrd9g/n/01/acbU25KTsUSiLKwvlLyA+6XLUOA==",
|
||||
"dev": true
|
||||
},
|
||||
"elliptic": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
|
||||
@ -2110,7 +2175,6 @@
|
||||
"resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.16.tgz",
|
||||
"integrity": "sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=",
|
||||
"requires": {
|
||||
"core-js": "1.2.7",
|
||||
"isomorphic-fetch": "2.2.1",
|
||||
"loose-envify": "1.3.1",
|
||||
"object-assign": "4.1.1",
|
||||
|
||||
@ -20,10 +20,13 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-brunch": "^6.1.1",
|
||||
"babel-plugin-transform-runtime": "^6.23.0",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.23.0",
|
||||
"babel-preset-env": "^1.4.0",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"brunch": "~2.10.0",
|
||||
"clean-css-brunch": "~2.0.0",
|
||||
"clean-css-brunch": "~2.10.0",
|
||||
"core-js": "~2.5.3",
|
||||
"css-brunch": "~2.0.0",
|
||||
"javascript-brunch": "~2.0.0",
|
||||
"sass-brunch": "^2.10.0",
|
||||
|
||||
@ -16,5 +16,3 @@ config :chess, Chess.Repo,
|
||||
hostname: "localhost",
|
||||
port: System.get_env("POSTGRES_PORT") || "5432",
|
||||
pool: Ecto.Adapters.SQL.Sandbox
|
||||
|
||||
config :hound, driver: "phantomjs"
|
||||
|
||||
4
mix.exs
4
mix.exs
@ -38,9 +38,9 @@ defmodule Chess.Mixfile do
|
||||
{:phoenix_html, "~> 2.0"},
|
||||
{:phoenix_live_reload, "~> 1.0", only: :dev},
|
||||
{:gettext, "~> 0.13.1"},
|
||||
{:hound, "~> 1.0"},
|
||||
{:cowboy, "~> 1.0"},
|
||||
{:timex_ecto, "~> 3.0"}]
|
||||
{:timex_ecto, "~> 3.0"},
|
||||
{:wallaby, "~> 0.19.2", [runtime: false, only: :test]}]
|
||||
end
|
||||
|
||||
# Aliases are shortcuts or tasks specific to the current project.
|
||||
|
||||
9
mix.lock
9
mix.lock
@ -10,10 +10,10 @@
|
||||
"ecto": {:hex, :ecto, "2.2.8", "a4463c0928b970f2cee722cd29aaac154e866a15882c5737e0038bbfcf03ec2c", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"},
|
||||
"file_system": {:hex, :file_system, "0.2.4", "f0bdda195c0e46e987333e986452ec523aed21d784189144f647c43eaf307064", [:mix], [], "hexpm"},
|
||||
"fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [], []},
|
||||
"gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [], [], "hexpm"},
|
||||
"gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], [], "hexpm"},
|
||||
"hackney": {:hex, :hackney, "1.10.1", "c38d0ca52ea80254936a32c45bb7eb414e7a96a521b4ce76d00a69753b157f21", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"hound": {:hex, :hound, "1.0.4", "31db3c013f0ed321b5eb4c573bf3fbc0b74e12fc8da134f9f616527bf0906431", [:mix], [{:hackney, "~> 1.5", [hex: :hackney, repo: "hexpm", optional: false]}, {:poison, ">= 1.4.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"httpoison": {:hex, :httpoison, "0.11.0", "b9240a9c44fc46fcd8618d17898859ba09a3c1b47210b74316c0ffef10735e76", [:mix], [{:hackney, "~> 1.6.3", [hex: :hackney, optional: false]}]},
|
||||
"httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"},
|
||||
"mime": {:hex, :mime, "1.2.0", "78adaa84832b3680de06f88f0997e3ead3b451a440d183d688085be2d709b534", [:mix], [], "hexpm"},
|
||||
@ -31,5 +31,6 @@
|
||||
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"},
|
||||
"timex": {:hex, :timex, "3.1.24", "d198ae9783ac807721cca0c5535384ebdf99da4976be8cefb9665a9262a1e9e3", [:mix], [{:combine, "~> 0.7", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"timex_ecto": {:hex, :timex_ecto, "3.2.1", "461140751026e1ca03298fab628f78ab189e78784175f5e301eefa034ee530aa", [:mix], [{:ecto, "~> 2.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:timex, "~> 3.1", [hex: :timex, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"tzdata": {:hex, :tzdata, "0.5.15", "d49241b0ca52c0b7354cb28ab87d290c30270194a436f9dc649bdc56ba97ceb7", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"}}
|
||||
"tzdata": {:hex, :tzdata, "0.5.16", "13424d3afc76c68ff607f2df966c0ab4f3258859bbe3c979c9ed1606135e7352", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
|
||||
"unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm"},
|
||||
"wallaby": {:hex, :wallaby, "0.19.2", "358bbff251e3555e02566280d1795132da792969dd58ff89963536d013058719", [], [{:httpoison, "~> 0.12", [hex: :httpoison, repo: "hexpm", optional: false]}, {:poison, ">= 1.4.0", [hex: :poison, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}], "hexpm"}}
|
||||
|
||||
@ -1,49 +1,46 @@
|
||||
defmodule Chess.GamesTest do
|
||||
use ChessWeb.FeatureCase
|
||||
|
||||
test "visit homepage" do
|
||||
navigate_to "/"
|
||||
find_element(:css, "body")
|
||||
import Wallaby.Query, only: [css: 1, css: 2, button: 1]
|
||||
|
||||
assert title_text() == "Chess"
|
||||
test "visit homepage", %{session: session} do
|
||||
session
|
||||
|> visit("/")
|
||||
|> assert_has(css("header h1", text: "Chess"))
|
||||
end
|
||||
|
||||
test "can create a new game" do
|
||||
navigate_to "/"
|
||||
create_game()
|
||||
|
||||
assert page_has_chess_board()
|
||||
test "can create a new game", %{session: session} do
|
||||
session
|
||||
|> create_game()
|
||||
|> assert_has(css(".board"))
|
||||
end
|
||||
|
||||
test "can move a piece" do
|
||||
navigate_to "/"
|
||||
create_game()
|
||||
test "can move a piece", %{session: session} do
|
||||
session
|
||||
|> create_game()
|
||||
|
||||
click({:css, "#f4-r1"})
|
||||
session
|
||||
|> click(css("#f4-r1"))
|
||||
|> assert_has(square_selected("f4-r1"))
|
||||
|> assert_has(square_containing("f4-r1", "white.pawn"))
|
||||
|
||||
assert has_class?({:css, "#f4-r1"}, "selected")
|
||||
assert square_has_piece("f4-r1", "white", "pawn")
|
||||
|
||||
click({:css, "#f4-r3"})
|
||||
|
||||
assert !square_has_piece("f4-r1", "white", "pawn")
|
||||
assert square_has_piece("f4-r3", "white", "pawn")
|
||||
session
|
||||
|> click(css("#f4-r3"))
|
||||
|> refute_has(square_containing("f4-r1", "white.pawn"))
|
||||
|> assert_has(square_containing("f4-r3", "white.pawn"))
|
||||
end
|
||||
|
||||
defp create_game do
|
||||
click({:css, "form.create-game button[type='submit']"})
|
||||
defp create_game(session) do
|
||||
session
|
||||
|> visit("/")
|
||||
|> click(button("Create game"))
|
||||
end
|
||||
|
||||
defp title_text do
|
||||
find_element(:css, "header h1") |> visible_text
|
||||
defp square_selected(square) do
|
||||
css("##{square}.selected")
|
||||
end
|
||||
|
||||
defp page_has_chess_board do
|
||||
element_displayed?({:css, ".board"})
|
||||
end
|
||||
|
||||
defp square_has_piece(square, colour, piece) do
|
||||
has_class?({:css, "##{square}"}, colour) &&
|
||||
has_class?({:css, "##{square}"}, piece)
|
||||
defp square_containing(square, piece) do
|
||||
css("##{square}.#{piece}")
|
||||
end
|
||||
end
|
||||
|
||||
@ -3,10 +3,26 @@ defmodule ChessWeb.FeatureCase do
|
||||
|
||||
using do
|
||||
quote do
|
||||
use ChessWeb.ConnCase
|
||||
use Wallaby.DSL
|
||||
|
||||
use Hound.Helpers
|
||||
hound_session()
|
||||
alias Chess.Repo
|
||||
import Ecto
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
|
||||
import ChessWeb.Router.Helpers
|
||||
end
|
||||
end
|
||||
|
||||
setup tags do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Chess.Repo)
|
||||
|
||||
unless tags[:async] do
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Chess.Repo, {:shared, self()})
|
||||
end
|
||||
|
||||
metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for(Chess.Repo, self())
|
||||
{:ok, session} = Wallaby.start_session(metadata: metadata)
|
||||
{:ok, session: session}
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
Application.ensure_all_started(:hound)
|
||||
{:ok, _} = Application.ensure_all_started(:wallaby)
|
||||
|
||||
ExUnit.start
|
||||
|
||||
Ecto.Adapters.SQL.Sandbox.mode(Chess.Repo, :manual)
|
||||
|
||||
Application.put_env(:wallaby, :base_url, ChessWeb.Endpoint.url)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user