This is a Javascript library useful to handle theater plays, their set of scenes, acts, roles and which scenes can be played with a given subset of roles.
This is used to compute possible scenes to rehearse given the list of present actors (and the roles they can play).
You will need to first install npm
on your system, so the dependencies can then be tracked with it.
I installed these to make the whole thing build and run with tests:
npm install --save-dev jest vite gas-tap
The library is useful as a Google AppScript library. I use the clasp
tool to sync to my copy of it.
sudo npm install -g @google/clasp
Typical commands to sync with it are:
clasp login
clasp clone <script_id>
clasp push
I was using the gas-tap
from AppScript when developing on the Appscript IDE. So I kept it here.
npm install --save-dev jest gas-tap
Tests on a stand-alone need a minimum of stubbing out the infra that is provided by AppScript.
// LOCAL_ONLY START
// myFunction.test.js (using Jest as an example)
const { test } = require('gas-tap'); // Import gas-tap's test function
// Mock the Apps Script Logger (or other services)
global.Logger = {
log: jest.fn(), // Create a mock log function
};
// LOCAL_ONLY END
// Your test
test('myFunction should return correct greeting', () => {
const myFunction = require('../src/myFunction'); // Your code
const result = myFunction('Test');
expect(result).toBe('Hello, Test!');
expect(Logger.log).toHaveBeenCalledWith('Hello, Test!'); // Check the log
});
// Run your tests with Jest:
// npm test
If the tests are simple, the only thing that needs stubbing is the Logger
:
// test.js (or wherever you run your tests)
global.Logger = {
log: () => {}, // Empty function (or you could console.log here)
};