Skip to content

Commit

Permalink
feat: telling time worksheet
Browse files Browse the repository at this point in the history
Closes #50.
  • Loading branch information
asartalo committed Jun 14, 2022
1 parent 709596b commit 663706a
Show file tree
Hide file tree
Showing 16 changed files with 826 additions and 11 deletions.
13 changes: 7 additions & 6 deletions cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,28 @@ it('can visit all subpages', () => {
clickWorksheetLink(/subtraction.+fill.+blank/i);
cy.hasCustomizeFormHeading(/subtraction.+fill.+blank/i);

goBackHome();

// Pattern Worksheets
goBackHome();
clickWorksheetLink(/patterns/i);
cy.hasCustomizeFormHeading(/patterns/i);

goBackHome();

// Place Value Worksheets
goBackHome();
clickWorksheetLink(/place values/i);
cy.hasCustomizeFormHeading(/place values/i);

goBackHome();

// Numbers to Words
goBackHome();
clickWorksheetLink(/numbers to words/i);
cy.hasCustomizeFormHeading(/numbers to words/i);

// Numbers to Words
goBackHome();
clickWorksheetLink(/telling time/i);
cy.hasCustomizeFormHeading(/telling time/i);

// Settings Page
goBackHome();
cy.findByRole('button', { name: /open menu/i }).click();
cy.findByRole('navigation', { name: /sidebar/i })
.find('a:contains("Settings")')
Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/worksheet_telling_time.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
it('can create telling time worksheet', () => {
cy.visitWorksheetTellingTime();

cy.findByLabelText(/count/i).clearType(7);

cy.withinPreview(() => {
cy.problemListItems()
.should('have.length', 7);
});
});
3 changes: 2 additions & 1 deletion cypress/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare namespace Cypress {
visitWorksheetVerticalAddition(): Chainable<AUTWindow>;
visitWorksheetSubtractionWithFigures(): Chainable<AUTWindow>;
visitWorksheetSubtractionFillInTheBlanks(): Chainable<AUTWindow>;
visitWorksheetTellingTime(): Chainable<AUTWindow>;
}

interface Chainable<Subject> {
Expand All @@ -25,7 +26,7 @@ declare namespace Cypress {
reactComponent(fn?: (prevSubject: Subject) => void): Chainable<Subject>;
setNumberRange(label: string | RegExp, min: number, max: number): Chainable<Subject>;
findPaperPage(page: number): Chainable<Subject>;
clearType(value: string): Chainable<Subject>;
clearType(value: string | number): Chainable<Subject>;
hasCustomizeFormHeading(text: LabelPattern): Chainable<Subject>;
problemListItems(): Chainable<Subject>;
answerListItems(): Chainable<Subject>;
Expand Down
1 change: 1 addition & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const paths = {
worksheetVerticalAddition: '/worksheet-vertical-addition',
worksheetSubtractionWithFigures: '/worksheet-subtraction-with-figures',
worksheetSubtractionFillInTheBlanks: '/worksheet-subtraction-fill-in-the-blanks',
worksheetTellingTime: '/worksheet-telling-time',
};

const pathNames = Object.keys(paths);
Expand Down
5 changes: 1 addition & 4 deletions src/components/forms/CustomizeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SectionPageTitle from '../../elements/SectionPageTitle';
import PaperSize, { Orientation } from '../../lib/PaperSize';
import PrintHelpDialog from './PrintHelpDialog';
import SelectFooterField from './SelectFooterField';
import zeroPad from '../../lib/zeroPad';

interface CustomizeFormProps {
onBeforePrint?: () => boolean;
Expand All @@ -26,10 +27,6 @@ interface EventWithSubmitter extends Event {
submitter: HTMLButtonElement | undefined;
}

function zeroPad(n: number): string {
return n > 9 ? n.toString() : `0${n}`;
}

function timeStamp(): string {
const now = new Date();
return `${now.getFullYear()}-${zeroPad(now.getMonth())}-${zeroPad(now.getDate())}`;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/RandomNumberGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import NumberGenerator from './NumberGenerator';
import { maxMustNotBeLessThanMin } from './numberGeneratorErrors';
import Range from './Range';

export type MathRandom = () => number;

Expand Down Expand Up @@ -57,6 +58,10 @@ class RandomNumberGenerator implements NumberGenerator {
return asInteger(this.rand(), max, min);
}

integerR(range: Range): number {
return this.integer(range.to, range.from);
}

integerBiasLess(max: number, min = 0): number {
return asInteger(circular(this.rand()), max, min);
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/linkMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const SubtractionFillInTheBlanksPage = lazy(() => import('../pages/subtractionFi
const PatternsPage = lazy(() => import('../pages/patterns/PatternsPage'));
const PlaceValuesPage = lazy(() => import('../pages/placeValues/PlaceValuesPage'));
const NumbersToWordsPage = lazy(() => import('../pages/numbersToWords/NumbersToWordsPage'));
const TellingTimePage = lazy(() => import('../pages/tellingTime/TellingTimePage'));
const ExperimentsPage = lazy(() => import('../pages/experiments/ExperimentsPage'));
const SettingsPage = lazy(() => import('../pages/settings/SettingsPage'));

Expand Down Expand Up @@ -72,6 +73,10 @@ export const mathLinks: SectionLinks = new Map([
text: 'Numbers to Words',
loader: NumbersToWordsPage,
}],
['/worksheet-telling-time', {
text: 'Telling Time',
loader: TellingTimePage,
}],
]);

export const miscLinks: SectionLinks = new Map([
Expand Down
3 changes: 3 additions & 0 deletions src/lib/zeroPad.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function zeroPad(n: number): string {
return n < 10 ? `0${n}` : n.toString();
}
Loading

0 comments on commit 663706a

Please sign in to comment.