Skip to content

Commit

Permalink
Add in QUnit, see: #3
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Jun 24, 2022
1 parent b84acd6 commit 6b79fda
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Mean Share And Balance
Mean: Share and Balance
================

"Mean Share And Balance" is an educational simulation in HTML5, by <a href="https://phet.colorado.edu/" target="_blank">PhET Interactive Simulations</a>
"Mean: Share and Balance" is an educational simulation in HTML5, by <a href="https://phet.colorado.edu/" target="_blank">PhET Interactive Simulations</a>
at the University of Colorado Boulder.

*This simulation is under development and has not been published.*
Expand Down
15 changes: 15 additions & 0 deletions js/mean-share-and-balance-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2020-2021, University of Colorado Boulder

/**
* Unit tests for ratio-and-proportion.
*
* @author
*/

import qunitStart from '../../chipper/js/sim-tests/qunitStart.js';

QUnit.test( 'helloWorld', assert => {
assert.ok( true, 'hello world passed' );
} );

qunitStart();
148 changes: 148 additions & 0 deletions mean-share-and-balance-tests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<!DOCTYPE HTML>
<!-- Top-level HTML file for mean-share-and-balance generated by 'grunt generate-development-html' -->
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="phet-sim-level" content="development">
<link rel="stylesheet" href="../sherpa/lib/qunit-2.10.0.css">
<title>mean-share-and-balance</title>
</head>

<!-- body is only made black for the loading phase so that the splash screen is black -->
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>

<script type="text/javascript">

window.phet = window.phet || {};
window.phet.chipper = window.phet.chipper || {};
window.phet.chipper.packageObject =
{
"name": "mean-share-and-balance",
"version": "1.0.0-dev.4",
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/phetsims/mean-share-and-balance.git"
},
"devDependencies": {
"grunt": "~1.5.3"
},
"phet": {
"requirejsNamespace": "MEAN_SHARE_AND_BALANCE",
"simulation": true,
"runnable": true,
"supportedBrands": [
"phet",
"adapted-from-phet",
"phet-io"
],
"generatedUnitTests": true,
"supportsOutputJS": true,
"simFeatures": {
"supportsInteractiveDescription": true
}
},
"eslintConfig": {
"extends": "../chipper/eslint/sim_eslintrc.js",
"overrides": [
{
"files": [
"**/*.ts"
],
"rules": {
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/no-explicit-any": "error"
}
}
]
}
};
window.phet.chipper.stringRepos =
[
{
"repo": "joist",
"requirejsNamespace": "JOIST"
},
{
"repo": "mean-share-and-balance",
"requirejsNamespace": "MEAN_SHARE_AND_BALANCE"
},
{
"repo": "scenery-phet",
"requirejsNamespace": "SCENERY_PHET"
},
{
"repo": "sun",
"requirejsNamespace": "SUN"
},
{
"repo": "tambo",
"requirejsNamespace": "TAMBO"
},
{
"repo": "twixt",
"requirejsNamespace": "TWIXT"
}
];

// Identify the brand (assume generated brand if not provided with query parameters)
const brandMatch = location.search.match( /brand=([^&]+)/ );
const brand = brandMatch ? decodeURIComponent( brandMatch[ 1 ] ) : 'adapted-from-phet';

// Preloads, with more included for phet-io brand
let preloads = [
'../sherpa/lib/jquery-2.1.0.js',
'../sherpa/lib/lodash-4.17.4.js',
'../sherpa/lib/FileSaver-b8054a2.js',
'../sherpa/lib/himalaya-1.1.0.js',
'../sherpa/lib/flatqueue-1.2.1.js',
'../sherpa/lib/he-1.1.1.js',
'../assert/js/assert.js',
'../query-string-machine/js/QueryStringMachine.js',
'../chipper/js/initialize-globals.js',
'../sherpa/lib/seedrandom-2.4.2.js',
'../sherpa/lib/base64-js-1.2.0.js',
'../sherpa/lib/TextEncoderLite-3c9f6f0.js',
'../tandem/js/PhetioIDUtils.js',
'../perennial-alias/js/common/SimVersion.js',
'../sherpa/lib/qunit-2.10.0.js',
'../chipper/js/sim-tests/qunit-connector.js'
];

if ( brand === 'phet-io' ) {
preloads = preloads.concat( [
'../chipper/js/phet-io/phetioCompareAPIs.js',
'../phet-io/js/phet-io-initialize-globals.js'
] );
}

// Loads a synchronously-executed asynchronously-downloaded script tag, with optional data-main parameter.
// See http://www.html5rocks.com/en/tutorials/speed/script-loading/ for more about script loading. It helps to
// load all of the scripts with this method, so they are treated the same (and placed in the correct execution
// order).
const loadURL = ( preloadURL, type = 'text/javascript' ) => {
const script = document.createElement( 'script' );
script.type = type;
script.src = preloadURL;
script.async = false;
script.setAttribute( 'crossorigin', 'use-credentials' );
document.head.appendChild( script );
};

// Kick off string loading immediately
loadURL( '../chipper/js/load-unbuilt-strings.js' );

// Queue all of the preloads to be loaded.
preloads.forEach( preload => loadURL( preload ) );

// Module loading in compilation-free (development) mode will be kicked off once strings are loaded.
// This is done in load-unbuilt-strings.js
window.phet.chipper.loadModules = () => loadURL( '../chipper/dist/js/mean-share-and-balance/js/mean-share-and-balance-tests.js', 'module' );
</script>
</body>
</html>
8 changes: 4 additions & 4 deletions mean-share-and-balance_a11y_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!--have to scroll right and left! allows to resize also-->
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>A11y View: Mean Share And Balance</title>
<title>A11y View: Mean: Share and Balance</title>

<style>
html {
Expand Down Expand Up @@ -155,7 +155,7 @@

<div id="content">
<div id="intro">
<h1>A11y View: Mean Share And Balance</h1>
<h1>A11y View: Mean: Share and Balance</h1>
<details>
<summary>About the A11y View Tool</summary>
<p>
Expand All @@ -170,7 +170,7 @@ <h1>A11y View: Mean Share And Balance</h1>
<!--The sim and alert containers will both be placed in here -->
<div id="left" class="left">
<div class="aspect-ratio">
<iframe id="iframe" allowfullscreen scrolling="no" title="Interact with Mean Share And Balance"></iframe>
<iframe id="iframe" allowfullscreen scrolling="no" title="Interact with Mean: Share and Balance"></iframe>
</div>
<div id="alerts">
<h3>Activity log of Responsive Descriptions</h3>
Expand All @@ -189,7 +189,7 @@ <h3>Activity log of Responsive Descriptions</h3>
<!--The PDOM copy will be placed in this container -->
<div class="right" id="right">
<div id="pdom">
<h3>State Descriptions for Mean Share And Balance</h3>
<h3>State Descriptions for Mean: Share and Balance</h3>
<details>
<summary>About State Descriptions</summary>
State Descriptions provide on-demand access to a full description of the current state of the simulation. This lengthy description is accessible to the learner from the moment the simulation loads, and during any point as they explore. The dynamic parts of the State Descriptions update silently as the learner interacts and makes changes.
Expand Down
4 changes: 3 additions & 1 deletion mean-share-and-balance_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"adapted-from-phet",
"phet-io"
],
"generatedUnitTests": true,
"supportsOutputJS": true,
"simFeatures": {
"supportsInteractiveDescription": true
Expand All @@ -53,7 +54,8 @@
"**/*.ts"
],
"rules": {
"@typescript-eslint/explicit-member-accessibility": "error"
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/no-explicit-any": "error"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"adapted-from-phet",
"phet-io"
],
"generatedUnitTests": true,
"supportsOutputJS": true,
"simFeatures": {
"supportsInteractiveDescription": true
Expand Down

0 comments on commit 6b79fda

Please sign in to comment.