Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
fix: move tests from single directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mg901 committed Jan 16, 2019
1 parent f84fc6b commit e73fd40
Show file tree
Hide file tree
Showing 111 changed files with 475 additions and 1,424 deletions.
2 changes: 2 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[options]
esproposal.export_star_as=enable
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/
es/
lib/
coverage/
__tests__
.env

npm-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
collectCoverage: false,
roots: ['<rootDir>/src'],
roots: ['<rootDir>/__tests__'],
transform: {
'^.+\\.js$': 'babel-jest',
},
Expand Down
4 changes: 4 additions & 0 deletions src/calculators/calc-leading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow

export const calcLeading = (base: number[], lineHeight: number) =>
Math.round(base[0] * lineHeight);
5 changes: 0 additions & 5 deletions src/calculators/calc-leading/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/calculators/calc-leading/index.spec.js

This file was deleted.

1 change: 0 additions & 1 deletion src/calculators/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
// https://www.modularscale.com/
// from https://github.com/modularscale/modularscale.com/blob/master/source/javascripts/_ms.js.erb#L27-L52

import type { Breakpoint } from '../../models';
import type { Breakpoint } from '../models/breakpoints';

type CalcStartPosition = (number, number[]) => number;
const calcStartPosition: CalcStartPosition = (step, base) =>
const calcStartPosition = (step: number, base: number[]) =>
Math.round(
(step / base.length - Math.floor(step / base.length)) * base.length,
);

type CalcFontSize = (number, number[], number) => number;
const calcFontSize: CalcFontSize = (step, base, ratio) =>
const calcFontSize = (step: number, base: number[], ratio: number) =>
Math.pow(ratio, Math.floor(step / base.length));

/* eslint-disable no-param-reassign, no-plusplus */
Expand All @@ -32,8 +30,7 @@ const normalizeBases = (base, baseHigh, ratio) => {
};
/* eslint-enable */

type ModularScale = (number) => (Breakpoint) => number;
export const modularScale: ModularScale = (step) => ({ base, ratio }) => {
export const modularScale = (step: number) => ({ base, ratio }: Breakpoint) => {
if (base.length === 1) {
return Math.pow(ratio, step) * parseFloat(base);
}
Expand Down
15 changes: 0 additions & 15 deletions src/calculators/modular-scale/index.spec.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/constants/all-characters-after-colon.spec.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/constants/all-characters-before-colon.spec.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/constants/all-round-brackets.spec.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/constants/ampersand.spec.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/constants/dash-hyphen-whitespace-any-characters.spec.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/constants/em-font-size-at-beginning-of-string.spec.js

This file was deleted.

22 changes: 0 additions & 22 deletions src/constants/em-font-size.spec.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/constants/font-size-prop.spec.js

This file was deleted.

27 changes: 0 additions & 27 deletions src/constants/font-size.spec.js

This file was deleted.

47 changes: 2 additions & 45 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,8 @@
// @flow

export * as regexes from './regexes';
export * as ratios from './ratios';
export const COMMA_AND_NEW_LINE = ',\n'; // postcss
export const HALF = 0.5;
export const BROWSER_VIEWPORT_WIDTH = '100vw';
export const BROWSER_DEFAULT_FONT_SIZE = 16;

// ratios
export const AUGMENTED_FOURTH = 1.41421;
export const DOUBLE_OCTAVE = 4;
export const GOLDEN_SECTION = 1.618034;
export const MAJOR_ELEVENTH = 2.666666667;
export const MAJOR_SECOND = 1.125;
export const MAJOR_SEVENTH = 1.875;
export const MAJOR_SIXTH = 1.666666667;
export const MAJOR_TENTH = 2.5;
export const MAJOR_THIRD = 1.25;
export const MAJOR_TWELFTH = 3;
export const MINOR_SECOND = 1.066666667;
export const MINOR_SEVENTH = 1.777777778;
export const MINOR_THIRD = 1.2;
export const OCTAVE = 2;
export const PERFECT_FIFTH = 1.5;
export const PERFECT_FOURTH = 1.333333333;
export const PHI = 1.618034;

// regexes
export const SPACE_AT_WORD_SPACE = /\sat\s/;
export const POSITIVE_OR_NEGATIVE_INTEGER_OR_FLOATING_NUMBER_AT_BEGINNING_OF_STRING = /^-?\d+(\.\d+)?$/;
export const DASH_HYPHEN_WHITESPACE_ANY_CHARACTERS = /[-_\s]+(.)?/g;
export const FONT_SIZE = /\b\d+(\.\d+)?(px|em)\b/g;
export const PX_OR_EM_FONT_SIZE_AT_BEGINNING_OF_STRING = /^\d+(\.\d+)?(px|em)\b/g;
export const PX_OR_EM_FONT_SIZE = /\d+(\.\d+)?(px|em)/;
export const PX_FONT_SIZE = /\d+(\.\d+)?px/;
export const SEPARATE_STRING_INTO_WORDS_WITH_CAPITAL_LETTER = /(?=[A-Z])/;
export const EM_FONT_SIZE = /\d+(\.\d+)?em/;
export const ALL_CHARACTERS_AFTER_COLON = /:.+\b/; // postcss
export const ALL_CHARACTERS_BEFORE_COLON = /^\(.+\):?/; // postcss
export const ALL_ROUND_BRACKETS = /[()]/g; // postcss
export const AMPERSAND = /&/; // postcss
export const LAST_COMMA = /,\s*$/; // postcss
export const LINE_BREAKS_AND_SPACES = /[\n\s]/g; // postcss
export const REM_FONT_SIZE = /\d+(\.\d+)?rem/; // postcss
export const REVERCE_BRACKET = /\)/; // postcss
export const STEP_UNIT = /step/; // postcss
export const STEP_FUNCTION_WITH_VALUE = /^step\(.+?\)$/; // postcss
export const STEP_FONT_SIZE_AT_BEGINNING_OF_STRING = /^-?\d+(\.\d+)?step$/; // postcss
export const FONT_SIZE_PROP = /^font-size$/; // postcss
export const STEP_WITH_BRACKET = /step\(/; // postcss
export const EM_FONT_SIZE_AT_BEGINNING_OF_STRING = /^\d+(\.\d+)?em\b/g; // postcss
export const POSITIVE_OR_NEGATIVE_INTEGER_OR_FLOATING_NUMBER_AT_END_OF_STRING = /-?\b\d+(\.\d+)?\b\s*$/g; // postcss
12 changes: 0 additions & 12 deletions src/constants/last-comma.spec.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/constants/line-breaks-and-spaces.spec.js

This file was deleted.

This file was deleted.

Loading

0 comments on commit e73fd40

Please sign in to comment.