├── .babelrc
├── .eslintignore
├── .eslintrc
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── dependabot.yml
└── workflows
│ └── lint-and-test.yml
├── .gitignore
├── .npmignore
├── .nvmrc
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── jest.config.js
├── package.json
├── src
├── components
│ ├── Case.tsx
│ ├── Default.tsx
│ ├── For.tsx
│ ├── Switch.tsx
│ └── tests
│ │ ├── For.test.tsx
│ │ ├── Switch.test.tsx
│ │ └── __snapshots__
│ │ ├── For.test.tsx.snap
│ │ └── Switch.test.tsx.snap
├── directives
│ ├── elements.ts
│ ├── index.ts
│ ├── makeDirective.ts
│ └── tests
│ │ ├── __snapshots__
│ │ └── dir.snapshot.test.tsx.snap
│ │ ├── dir.snapshot.test.tsx
│ │ └── makeDirective.test.tsx
├── helpers
│ └── test-helpers.ts
├── hooks
│ ├── tests
│ │ └── useClassName.test.ts
│ └── useClassName.ts
├── index.ts
└── types
│ ├── classes.ts
│ ├── directive.ts
│ ├── for.ts
│ └── switch.ts
├── tsconfig.eslint.json
├── tsconfig.json
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
3 | "plugins": []
4 | }
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 | jest.config.js
3 | node_modules
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "airbnb",
4 | "airbnb-typescript",
5 | "airbnb/hooks",
6 | "plugin:@typescript-eslint/recommended",
7 | "plugin:prettier/recommended",
8 | "prettier"
9 | ],
10 | "plugins": ["react", "@typescript-eslint"],
11 | "env": {
12 | "browser": true,
13 | "es6": true,
14 | "jest": false
15 | },
16 | "parser": "@typescript-eslint/parser",
17 | "parserOptions": {
18 | "ecmaFeatures": {
19 | "jsx": true
20 | },
21 | "ecmaVersion": 2020,
22 | "sourceType": "module",
23 | "project": "./tsconfig.eslint.json"
24 | },
25 | "rules": {
26 | "@typescript-eslint/no-explicit-any": "off",
27 | "@typescript-eslint/no-non-null-assertion": "off",
28 | "react/function-component-definition": "off",
29 | "import/extensions": ["off"],
30 | "react/no-unstable-nested-components": ["warn", { "allowAsProps": true }],
31 | "import/no-extraneous-dependencies": [
32 | "warn",
33 | {
34 | "devDependencies": [
35 | "**/*.test.ts",
36 | "**/*.spec.ts",
37 | "**/*.test.tsx",
38 | "**/*.spec.tsx"
39 | ],
40 | "optionalDependencies": false,
41 | "peerDependencies": true
42 | }
43 | ],
44 | "comma-dangle": "off",
45 | "import/no-cycle": "off",
46 | "jsx-a11y/control-has-associated-label": "off",
47 | "jsx-a11y/label-has-associated-control": "off",
48 | "jsx-a11y/click-events-have-key-events": "off",
49 | "react/require-default-props": "off",
50 | "jsx-a11y/interactive-supports-focus": "off",
51 | "@typescript-eslint/no-use-before-define": "off",
52 | "@typescript-eslint/no-unused-expressions": ["error"],
53 | "no-plusplus": "off",
54 | "react/destructuring-assignment": "off",
55 | "react-hooks/exhaustive-deps": "off",
56 | "import/prefer-default-export": "off",
57 | "react/prop-types": "off",
58 | "no-unused-vars": "error",
59 | "no-console": "warn",
60 | "no-underscore-dangle": "off",
61 | "react/jsx-props-no-spreading": "off",
62 | "prettier/prettier": [
63 | "error",
64 | {
65 | "endOfLine": "auto"
66 | }
67 | ]
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Additional context**
32 | Add any other context about the problem here.
33 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | # Enable version updates for npm
9 | - package-ecosystem: 'npm'
10 | # Look for `package.json` and `lock` files in the `root` directory
11 | directory: '/'
12 | # Check the npm registry for updates every day (weekdays)
13 | target-branch: 'dependencies'
14 | schedule:
15 | interval: 'daily'
16 |
--------------------------------------------------------------------------------
/.github/workflows/lint-and-test.yml:
--------------------------------------------------------------------------------
1 | name: Lint and Test
2 |
3 | on:
4 | push:
5 | branches: [ master, develop, dependencies ]
6 | pull_request:
7 | branches: [ master, develop, dependencies ]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v3
15 | - uses: actions/setup-node@v3
16 | with:
17 | node-version: 16
18 | - run: yarn
19 | - run: yarn lint
20 | - run: yarn test
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | coverage
4 | src/Playground.tsx
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | coverage
3 | src/Playground.tsx
4 | .eslintrc
5 | .nvmrc
6 | jest.config.js
7 | tsconfig.json
8 | tsconfig.eslint.json
9 | .eslintignore
10 | .babelrc
11 | .github
12 | LICENSE
13 |
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | v16.15.0
2 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | mkhstar.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Musah Kusi Hussein
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # react-directive
3 |
4 | > A conditional, className and listing directive for react apps
5 |
6 | [](https://www.npmjs.com/package/react-directive) [](https://standardjs.com)
7 |
8 | ## Install
9 |
10 | ```bash
11 | # npm
12 | npm i react-directive
13 |
14 | # yarn
15 | yarn add react-directive
16 | ```
17 |
18 | # Introduction
19 | `react-directive` is a library for creating conditional or listing directives in a react app.
20 | It takes a lot of inspiration from [Vue.js'](https://vuejs.org/) conditional, class bindings and listing directives such as `v-if`, `v-for`, and `:class`.
21 | Its two main purposes are listed below.
22 | - To avoid the headache of using conditional (ternary) operators or higher order array methods such as map for list rendering.
23 | - To keep JSX clean and concise.
24 |
25 | # Usage
26 | To use `react-directive` import it to your component.
27 | ```jsx
28 | import React from 'react';
29 | import directive from 'react-directive';
30 |
31 | const Component = () => {
32 | return (
33 | // This is the same as a div element but has more features like dirIf, dirFor, extended className etc.
34 |
35 | { /* Any children for the div element */ }
36 |
37 | );
38 | }
39 | ```
40 |
41 | # Conditional Rendering
42 |
43 | `react-directive` provides directives such as `dirIf`, `dirShow` and components ``, `` `` to render (show) or remove (hide) an element from the page.
44 |
45 |
46 | ## Prop `dirIf`
47 |
48 | The prop `dirIf` is used to conditionally render a block. The block will only be rendered if the directive’s expression returns a **truthy** value (Check out truthy and falsy values in javascript [here](https://developer.mozilla.org/en-US/docs/Glossary/Truthy)). It works like `v-if` for `Vuejs` and `ngIf` for angular.
49 |
50 | Currently, there is no support for `else` and `else-if` yet. ( You can use the `` component to handle such cases. More on that later ).
51 |
52 | **Note**: `undefined` is the only exceptional falsy value that evaluates to `true` because the default value for `dirIf` is true
53 |
54 | ### Usage
55 |
56 | The example component below renders a `div` element only if the name's length is greater than `4` otherwise it will just render a `null` value. If you want to keep the `node` and only toggle style's display value, use the `dirShow` prop instead.
57 |
58 | ```jsx
59 | import React, { useState } from 'react';
60 | import directive from 'react-directive';
61 |
62 | const Component = () => {
63 | const [currentName, setCurrentName] = useState('Musah');
64 |
65 | return (
66 | 4}>
67 | Div contents
68 |
69 | );
70 | }
71 | /*
72 | When dirIf is truthy, it renders
73 |
Div contents
74 |
75 | When dirIf is falsy, it renders nothing
76 | */
77 | ```
78 |
79 |
80 | ## Prop `dirShow`
81 |
82 | The prop `dirShow` is used to conditionally show a block. The block will only be shown if the directive’s expression returns a **truthy** value. It works like `v-show` for `Vuejs`.
83 |
84 | **Note**: `dirShow` takes precedence to any another display for styles. For example if you set the display to block and `dirShow` is `false`, it will still hide the element.
85 | **Note**: `undefined` is the only exceptional falsy value that evaluates to `true` because the default value for `dirShow` is true
86 |
87 | ### Usage
88 | The example component below shows a `div` element only if the name's length is greater than `4` otherwise it will hide the `div` element by add the `display:none` to its styles.
89 |
90 |
91 |
92 | ```jsx
93 | import React, { useState } from 'react';
94 | import directive from 'react-directive';
95 |
96 | const Component = () => {
97 | const [currentName, setCurrentName] = useState('Musah');
98 |
99 | return (
100 | 4}>
101 | Div contents
102 |
103 | );
104 | }
105 | /*
106 | When dirShow is truthy, it renders
107 |
Div contents
108 |
109 | When dirShow is falsy, it renders
110 |
Div contents
111 | */
112 | ```
113 |
114 | ## Component ``
115 |
116 | The `` component is used to conditionally render a `` that resolves to a truthy value. Otherwise it renders `` (If it exists).
117 |
118 | ### Usage
119 | The example component below shows the `div` element with contents `Case 2` because it is the first case that resolves to a truthy value.
120 |
121 | Note that the `when` prop for the `` component supports either a (truthy | falsy) value or a function that returns a (truthy | falsy) value.
122 | It is recommended to use the function version if the calculation is intensive. This helps in short circuiting (lazy evaluation) when the case is not reached.
123 |
124 |
125 |
126 | ```jsx
127 | import React, { useState } from 'react';
128 | import { Switch, Case, Default } from 'react-directive';
129 |
130 | const Component = props => {
131 | const [currentName, setCurrentName] = useState('Musah');
132 |
133 | // This makes it more concise to render an element instead of using nested ternary operator.
134 | // Fun fact: I was getting lots of eslint problems because of using ternary operators which was one of my main motivations for building this library.
135 | return (
136 |
137 |
138 |
Case 1
139 |
140 | 4}>
141 |
Case 2
142 |
143 | {/* The case below resolves to true but the case above will render because it is the first match */}
144 |
145 |
156 | */
157 | ```
158 |
159 |
160 | # Class Names
161 | A common need for data binding is manipulating an element's class list.
162 | `react-directive` provides the hook `useClassName` and an extended version of the `className` prop to handle this issue
163 |
164 | ## Hook `useClassName`
165 | A simple hook for generating class names.
166 |
167 | ### Usage
168 | The hook takes in two optional parameters: `classes` and `deps` (dependencies).
169 |
170 | - `classes` can be a string, an array of strings, an object with class names as keys and truthy values, or an array of such objects.
171 |
172 | - `deps` is an optional dependencies array that tells the hook to re-run when one of its values changes.
173 |
174 | **Note**: When dependencies are not passed, it will fallback to re-calculate the class names based on the classes argument itself. Also it is advisable to pass an array of primitive values or cached values. So that it doesn't re-calculate unnecessarily. Think of it like a `useEffect` dependency.
175 |
176 | Here are some basic examples:
177 |
178 | ```tsx
179 | import { useClassName } from 'react-directive';
180 |
181 | function Component() {
182 | const className = useClassName({
183 | active: true,
184 | disabled: false,
185 | });
186 |
187 | return
Contents
;
188 | }
189 |
190 | // Renders
Contents
191 | ```
192 |
193 | You can also pass an array of objects, strings, or a combination of both:
194 |
195 | ```tsx
196 | import { useState } from 'react'
197 | import { useClassName } from 'react-directive';
198 |
199 | function Component() {
200 | const [isActive, setIsActive] = useState(true);
201 | const [isDisabled, setIsDisabled] = useState(false);
202 | const className = useClassName([
203 | 'highlighted',
204 | { active: isActive, disabled: isDisabled },
205 | ], [isActive, isDisabled]); // Optional deps to tell it to re-calculate based on isActive and isDisabled values
206 |
207 | return
Contents
;
208 | }
209 | // Renders
Contents
210 | // This is useful if you have some other classNames that doesn't have to react to any value
211 | ```
212 |
213 | ## Prop `className`
214 | `react-directive` extends the default className of React to support what the `useClassName` hook supports above. To pass the dependencies, use `classNameDeps` props.
215 |
216 | Here are some basic examples:
217 |
218 | ```tsx
219 | import { useState } from 'react'
220 | import directive from 'react-directive';
221 |
222 | function Component() {
223 | const [isActive, setIsActive] = useState(true);
224 | const [isDisabled, setIsDisabled] = useState(false);
225 |
226 | return Contents;
227 | }
228 | // Renders
Contents
229 | // classNameDeps is optional but makes it more efficient and performant.
230 | ```
231 |
232 |
233 | # List Rendering
234 |
235 | `react-directive` provides the directive `dirFor` and the component `` to generate lists. This makes it more readable than using `Array.prototype.map`.
236 |
237 |
238 | ## Usage
239 | The `` component takes in an object with two properties: `each` and `children`
240 |
241 | - `each` is an array of items that you want to render.
242 |
243 | - `children` is a function that takes in two arguments: `value` and `index`. `value` is the current item in the `each` array and `index` is its index in the array.
244 |
245 | **Note**: Make sure to pass a unique key prop to the elements rendered by the children function. This is important for React to keep track of the elements and render updates efficiently.
246 |
247 |
248 | Here is a basic example:
249 |
250 | ```tsx
251 | import { For } from 'react-directive';
252 |
253 | function Component() {
254 | const items = ['Item 1', 'Item 2', 'Item 3'];
255 |
256 | return (
257 |
258 | {(value, index) =>
267 | */
268 | ```
269 |
270 | You might have noticed that we are passing a function. It is important to know that if you want the values of the elements in the list you passed, you must pass a function to be able to access them. This works like ``.
271 |
272 | ## Prop `dirFor`
273 | `react-directive` includes a prop that takes an `array` of items you want to render. The children prop is a function or React node that is called for each item in the array. The function takes in two arguments: `currentItem` and `index`. `currentItem` is the current item in the `dirFor` array and `index` is its index in the array.
274 |
275 | **Note**: Make sure to pass a unique key prop to the elements rendered by the children function using `dirKey` (More later). This is important for React to keep track of the elements and render updates efficiently. It fallsback to using the `index` of the item if not provided
276 |
277 | Here is a basic example:
278 |
279 | ```tsx
280 | import directive from 'react-directive';
281 |
282 | function Component() {
283 | const items = ['Item 1', 'Item 2', 'Item 3'];
284 |
285 | return (
286 | // this means the current item. Used because the items are unique. If they are not
287 | {(currentItem) => currentItem}
288 | );
289 | }
290 |
291 | /* renders
292 |
175 |
176 | ,
177 | "No default case"
178 | );
179 | });
180 | });
181 |
--------------------------------------------------------------------------------
/src/components/tests/__snapshots__/For.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[` snapshots matches the snapshot with an array of numbers 1`] = `
4 | [
5 |
6 | 1
7 |
,
8 |
9 | 2
10 |
,
11 |
12 | 3
13 |
,
14 | ]
15 | `;
16 |
17 | exports[` snapshots matches the snapshot with an array of strings 1`] = `
18 | [
19 |
20 | a
21 |
,
22 |
23 | b
24 |
,
25 |
26 | c
27 |
,
28 | ]
29 | `;
30 |
31 | exports[` snapshots matches the snapshot with an empty array 1`] = `null`;
32 |
33 | exports[` snapshots passes the correct value and index to children 1`] = `
34 | [
35 |
36 | Name: Musah, School Hacettepe, From Kumasi, Index: 0
37 |
,
38 |
39 | Name: Shakino, School Okess, From Oman, Index: 1
40 |
,
41 |
42 | Name: Sala, School UOEW, From Kumasi, Index: 2
43 |
,
44 | ]
45 | `;
46 |
--------------------------------------------------------------------------------
/src/components/tests/__snapshots__/Switch.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[` snapshots matches the snapshot with the default case 1`] = `
4 |
5 | Default case
6 |
7 | `;
8 |
9 | exports[` snapshots matches the snapshot with the default case: No default case 1`] = `null`;
10 |
11 | exports[` snapshots matches the snapshot with the matching case 1`] = `
12 |
13 | Case 1
14 |
15 | `;
16 |
17 | exports[` snapshots matches the snapshot with the matching case 2`] = `
18 |