Finish writing tests for front-end
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { Component } from '../../../lib/vues6.js'
|
||||
import { fake_players } from '../../module/fake_data.js'
|
||||
import { clone } from '../../module/util.js'
|
||||
import { api } from '../../module/api.js'
|
||||
|
||||
const template = `
|
||||
@@ -96,7 +94,7 @@ class AddPlayersComponent extends Component {
|
||||
* All available players, whether they are on the user's team or not.
|
||||
* @type {object[]}
|
||||
*/
|
||||
all_players = clone(fake_players)
|
||||
all_players = []
|
||||
|
||||
/**
|
||||
* Called when the page is instantiated.
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import {Component} from '../../../lib/vues6.js'
|
||||
import {fake_players} from '../../module/fake_data.js'
|
||||
import {GridCellRenderType} from '../Grid.component.js'
|
||||
import {api} from '../../module/api.js'
|
||||
import {clone} from '../../module/util.js'
|
||||
|
||||
const template = `
|
||||
<div class="page-draft-board">
|
||||
@@ -106,7 +104,7 @@ class DraftBoardComponent extends Component {
|
||||
header: '',
|
||||
key: 'stats',
|
||||
type: GridCellRenderType.Component,
|
||||
component: Vue.component('app-action-button'),
|
||||
component: window.Vue ? Vue.component('app-action-button') : undefined,
|
||||
button_color: (row, col) => '#CC5746',
|
||||
button_text: (row, col) => 'Draft',
|
||||
button_hidden: (row, col) => this.top_picks.includes(row),
|
||||
|
||||
@@ -120,7 +120,7 @@ class MyTeamComponent extends Component {
|
||||
header: '',
|
||||
key: 'name',
|
||||
type: GridCellRenderType.Component,
|
||||
component: Vue.component('app-action-button'),
|
||||
component: window.Vue ? Vue.component('app-action-button') : undefined,
|
||||
button_color: (row, col) => this.moving_player ? '#CC5746' : '#0582CA',
|
||||
button_text: (row, col) => {
|
||||
return this.moving_player ? 'Here' : 'Move'
|
||||
|
||||
@@ -99,7 +99,7 @@ class ScoresComponent extends Component {
|
||||
type: GridCellRenderType.HTML,
|
||||
key: 'winner',
|
||||
renderer: (_, data) => {
|
||||
if ( data?.winner ) {
|
||||
if ( data && data.winner ) {
|
||||
return `
|
||||
<div><b>Winner:</b> ${data.winner}</div>
|
||||
<div><b>Score: </b> ${data.winner_score} / ${data.loser_score}</div>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class API {
|
||||
_fetch = (...all) => fetch(...all)
|
||||
|
||||
constructor() {
|
||||
this.base_url = APP_BASE_PATH.replace('/app/', '/api/v1/')
|
||||
this.base_url = typeof window !== 'undefined' ? APP_BASE_PATH.replace('/app/', '/api/v1/') : '/api/v1/'
|
||||
}
|
||||
|
||||
async get_status() {
|
||||
@@ -47,7 +49,7 @@ class API {
|
||||
if ( !Array.isArray(parts) ) parts = [parts]
|
||||
|
||||
const url = this.build_url(...parts)
|
||||
const result = await fetch(url, {
|
||||
const result = await this._fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@@ -61,7 +63,7 @@ class API {
|
||||
|
||||
async get_request(...parts) {
|
||||
const url = this.build_url(...parts)
|
||||
const result = await fetch(url)
|
||||
const result = await this._fetch(url)
|
||||
return (await result.json()).data
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user