-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
132 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import ReactDOM from 'react-dom/client' | ||
import { createRoot } from 'react-dom/client' | ||
import News from './News' | ||
import mockNews from '../models/mockNews' | ||
|
||
describe('<News />', () => { | ||
it('renders the News area', () => { | ||
const div = document.createElement('div') | ||
const root = ReactDOM.createRoot(div).render(<News article={mockNews[0]} />) | ||
root.unmount(div) | ||
const root = createRoot(div).render(<News article={mockNews[0]} />) | ||
root.unmount() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import ReactDOM from 'react-dom' | ||
import { createRoot } from 'react-dom/client' | ||
import NinjaLevel from './NinjaLevel' | ||
|
||
describe('<NinjaLevel />', () => { | ||
it('renders the NinjaLevel area', () => { | ||
const div = document.createElement('div') | ||
const root = ReactDOM.createRoot(div).render(<NinjaLevel level={99} />) | ||
root.unmount(div) | ||
const root = createRoot(div).render(<NinjaLevel level={99} />) | ||
root.unmount() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { ThemeProvider } from '@material-ui/core/styles' | ||
import ReactDOM from 'react-dom' | ||
import { createRoot } from 'react-dom/client' | ||
import theme from '@/theme' | ||
import Typeset from './Typeset' | ||
|
||
describe('<Typeset />', () => { | ||
it('renders the Typeset area', () => { | ||
const div = document.createElement('div') | ||
const root = ReactDOM.createRoot(div).render(<ThemeProvider theme={theme}><Typeset><div>Some random contents</div><div>Here are some more</div></Typeset></ThemeProvider>) | ||
root.unmount(div) | ||
const root = createRoot(div).render(<ThemeProvider theme={theme}><Typeset><div>Some random contents</div><div>Here are some more</div></Typeset></ThemeProvider>) | ||
root.unmount() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import operateInitialize from './operateInitialize'; | ||
|
||
/** | ||
* @typedef {Object} Model | ||
* @property {string} name | ||
* @property {unknown} fields | ||
* @property {unknown} [key] | ||
*/ | ||
/** inferred return type | ||
* @param {schema} schema | ||
* @returns {Record<string, Model>} | ||
*/ | ||
|
||
export const initSchema = (schema) => { | ||
// Gather the model classes. | ||
const models = Object.keys(schema).reduce((acc, modelName) => { | ||
const modelInit = schema[modelName]; | ||
// use the model init function to create the model class | ||
const model = operateInitialize(modelInit); | ||
return { ...acc, [modelName]: model }; | ||
}, {}); | ||
return models; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
export const operateInitialize = (model) => { | ||
// loop over the fields and set them as properties on the model instance | ||
return Object.keys(model.fields).forEach((fieldName) => { | ||
Object.defineProperty(model.prototype, fieldName, { | ||
get() { | ||
return this._data[fieldName]; | ||
}, | ||
set(value) { | ||
this._data[fieldName] = value; | ||
}, | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters