Add missing javascript dependencies to package.json. Move javascripts files to app/javascript. Add first javascript test. Change test mode
parent
414eb83f6d
commit
7ba020d04d
@ -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,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,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")
|
||||
})
|
||||
})
|
||||
@ -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)
|
||||
})
|
||||
Loading…
Reference in new issue