mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 13:38:18 -08:00
Add missing javascript dependencies to package.json. Move javascripts files to app/javascript. Add first javascript test. Change test mode
This commit is contained in:
parent
414eb83f6d
commit
7ba020d04d
13 changed files with 83 additions and 54 deletions
1
.prettierrc
Normal file
1
.prettierrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require bootstrap
|
||||
//= require turbolinks
|
||||
//= require_tree .
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
document.addEventListener("turbolinks:load", function() {
|
||||
const schoolDropdown = document.querySelector('#select-school');
|
||||
if (schoolDropdown) {
|
||||
document.querySelector('#select-school').addEventListener('change', (event) => {
|
||||
window.location = event.target.value;
|
||||
});
|
||||
|
||||
document.querySelector('#select-district').addEventListener('change', (event) => {
|
||||
window.location = event.target.value;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
export default class Jester {
|
||||
constructor(){}
|
||||
|
||||
hello(){
|
||||
return "Hello"
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1,15 @@
|
|||
// Entry point for the build script in your package.json
|
||||
|
||||
import Rails from "@rails/ujs";
|
||||
import Turbolinks from "turbolinks";
|
||||
import * as ActiveStorage from "@rails/activestorage";
|
||||
// import "channels";
|
||||
|
||||
Rails.start();
|
||||
Turbolinks.start();
|
||||
ActiveStorage.start();
|
||||
import { initializeListenersForNavDropdowns } from "./dashboard.js";
|
||||
import { initializeListenersForHomeDropdowns } from "./home.js";
|
||||
|
||||
initializeListenersForNavDropdowns();
|
||||
initializeListenersForHomeDropdowns();
|
||||
|
|
|
|||
0
app/javascript/channels/.keep
Normal file
0
app/javascript/channels/.keep
Normal file
14
app/javascript/dashboard.js
Normal file
14
app/javascript/dashboard.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export function initializeListenersForNavDropdowns(){
|
||||
document.addEventListener("turbolinks:load", function() {
|
||||
const schoolDropdown = document.querySelector('#select-school');
|
||||
if (schoolDropdown) {
|
||||
document.querySelector('#select-school').addEventListener('change', (event) => {
|
||||
window.location = event.target.value;
|
||||
});
|
||||
|
||||
document.querySelector('#select-district').addEventListener('change', (event) => {
|
||||
window.location = event.target.value;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
export function initializeListenersForHomeDropdowns(){
|
||||
document.addEventListener('turbolinks:load', () => {
|
||||
const districtDropdown = document.querySelector('#district-dropdown');
|
||||
if (districtDropdown) {
|
||||
districtDropdown.addEventListener('change', event => {
|
||||
|
|
@ -23,3 +24,5 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
10
package.json
10
package.json
|
|
@ -4,11 +4,15 @@
|
|||
"dependencies": {
|
||||
"@babel/preset-env": "^7.15.8",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"esbuild": "^0.13.6"
|
||||
"esbuild": "^0.13.6",
|
||||
"@rails/actioncable": "^6.0.0",
|
||||
"@rails/activestorage": "^6.0.0",
|
||||
"@rails/ujs": "^6.0.0",
|
||||
"turbolinks": "^5.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "esbuild app/javascript/*.* --bundle --outdir=app/assets/builds",
|
||||
"test": "jest"
|
||||
"test": "jest --env=jsdom"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^27.2.5"
|
||||
|
|
@ -19,7 +23,7 @@
|
|||
],
|
||||
"moduleDirectories": [
|
||||
"node_modules",
|
||||
"app/assets/javascripts"
|
||||
"app/javascript"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
import Jester from "jester"
|
||||
|
||||
describe('this test should pass', () => {
|
||||
test('very first test', () => {
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
|
||||
test('Jester.hello returns greeting', () =>{
|
||||
const jester = new Jester()
|
||||
expect(jester.hello()).toBe("Hello")
|
||||
})
|
||||
})
|
||||
12
spec/javascript/home.spec.js
Normal file
12
spec/javascript/home.spec.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import {initializeListenersForHomeDropdowns } from "home"
|
||||
|
||||
it("returns true when called", () =>{
|
||||
|
||||
document.body.innerHTML =
|
||||
'<div>' +
|
||||
' <select id="school-dropdown"></select>' +
|
||||
' <select id="district-dropdown"></select>' +
|
||||
'</div>';
|
||||
|
||||
expect(initializeListenersForHomeDropdowns()).toBe(true)
|
||||
})
|
||||
27
yarn.lock
27
yarn.lock
|
|
@ -1079,6 +1079,23 @@
|
|||
"@types/yargs" "^16.0.0"
|
||||
chalk "^4.0.0"
|
||||
|
||||
"@rails/actioncable@^6.0.0":
|
||||
version "6.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-6.1.4.tgz#c3c5a9f8302c429af9722b6c50ab48049016d2a3"
|
||||
integrity sha512-0LmSKJTuo2dL6BQ+9xxLnS9lbkyfz2mBGeBnQ2J7o9Bn0l0q+ZC6VuoZMZZXPvABI4QT7Nfknv5WhfKYL+boew==
|
||||
|
||||
"@rails/activestorage@^6.0.0":
|
||||
version "6.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-6.1.4.tgz#7772f539cc846df5f4364fc57ccb48860f9e966e"
|
||||
integrity sha512-1Tm8uaVBhLTDEG4YaFPvqguhjbUGSPVItm0CfkRpIFZIkybWzFAxatIrk4YVOOxB8ZdXS7GdeYa1qVwjdiDkgQ==
|
||||
dependencies:
|
||||
spark-md5 "^3.0.0"
|
||||
|
||||
"@rails/ujs@^6.0.0":
|
||||
version "6.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-6.1.4.tgz#093d5341595a02089ed309dec40f3c37da7b1b10"
|
||||
integrity sha512-O3lEzL5DYbxppMdsFSw36e4BHIlfz/xusynwXGv3l2lhSlvah41qviRpsoAlKXxl37nZAqK+UUF5cnGGK45Mfw==
|
||||
|
||||
"@sinonjs/commons@^1.7.0":
|
||||
version "1.8.3"
|
||||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
|
||||
|
|
@ -3531,6 +3548,11 @@ source-map@^0.7.3:
|
|||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
|
||||
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
|
||||
|
||||
spark-md5@^3.0.0:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/spark-md5/-/spark-md5-3.0.2.tgz#7952c4a30784347abcee73268e473b9c0167e3fc"
|
||||
integrity sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw==
|
||||
|
||||
sprintf-js@~1.0.2:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
||||
|
|
@ -3683,6 +3705,11 @@ tr46@^2.1.0:
|
|||
dependencies:
|
||||
punycode "^2.1.1"
|
||||
|
||||
turbolinks@^5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/turbolinks/-/turbolinks-5.2.0.tgz#e6877a55ea5c1cb3bb225f0a4ae303d6d32ff77c"
|
||||
integrity sha512-pMiez3tyBo6uRHFNNZoYMmrES/IaGgMhQQM+VFF36keryjb5ms0XkVpmKHkfW/4Vy96qiGW3K9bz0tF5sK9bBw==
|
||||
|
||||
type-check@~0.3.2:
|
||||
version "0.3.2"
|
||||
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue