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
// src/tests/unit/widgets/Profile.ts | |
describe("Profile", () => { | |
it("default renders correctly", () => { | |
const h = harness(() => w(Profile, {})); | |
h.expect(profileAssertion); | |
}); | |
it("renders given username correctly", () => { | |
// update the expected result with a given username | |
const namedAssertion = profileAssertion.setChildren("~welcome", [ | |
"Welcome Kel Varnsen!" |
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
// tests/unit/widgets/Profile.ts | |
// Add the assertionTemplate module | |
import assertionTemplate from "@dojo/framework/testing/assertionTemplate"; | |
... | |
// Create my assertion | |
const profileAssertion = assertionTemplate(() => | |
v("h1", { classes: [css.root], "~key": "welcome" }, ["Welcome Stranger!"]) | |
); | |
describe("Profile", () => { | |
it("default renders correctly", () => { |
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
// src/widgets/Profile.ts | |
export interface ProfileProperties { | |
username?: string; | |
} | |
export default class Profile extends WidgetBase<ProfileProperties> { | |
protected render() { | |
const { username } = this.properties; | |
return v("h1", { classes: [css.root] }, [ | |
`Welcome ${username || "Stranger"}!` | |
]); |
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
// tests/unit/widgets/Profile.ts | |
const { describe, it } = intern.getInterface("bdd"); | |
import harness from "@dojo/framework/testing/harness"; | |
import { w, v } from "@dojo/framework/widget-core/d"; | |
import Profile from "../../../src/widgets/Profile"; | |
import * as css from "../../../src/widgets/styles/Profile.m.css"; | |
describe("Profile", () => { | |
it("default renders correctly", () => { | |
const h = harness(() => w(Profile, { username: "Dojo User" })); | |
h.expect(() => v("h1", { classes: [css.root] }, ["Welcome Dojo User!"])); |
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
import { resolve } from 'path'; | |
import { v } from '@dojo/framework/widget-core/d'; | |
import * as sharp from 'sharp'; | |
export default async function (path: string) { | |
path = resolve(__dirname, path); | |
// resize my images | |
const images = [ | |
await sharp(path).resize(200).toBuffer(), | |
await sharp(path).resize(300).toBuffer(), | |
await sharp(path).resize(400).toBuffer(), |
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
import WidgetBase from "@dojo/framework/widget-core/WidgetBase"; | |
import { dom } from "@dojo/framework/widget-core/d"; | |
import Block from "@dojo/framework/widget-core/meta/Block"; | |
import { tsx } from "@dojo/framework/widget-core/tsx"; | |
import fromMarkdown from "../blocks/markdown.block"; | |
import * as css from "./styles/About.m.css"; | |
export default class About extends WidgetBase { | |
protected render() { | |
const node = document.createElement("div"); | |
// Use my block |
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
import * as fs from 'fs'; | |
import { resolve } from 'path'; | |
import { Converter } from 'showdown'; | |
const mdConverter = new Converter(); | |
export default function (path: string) { | |
path = resolve(__dirname, path); | |
const file = fs.readFileSync(path, 'utf8'); | |
// convert Markdown to HTML | |
const html = mdConverter.makeHtml(file); | |
return html |
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
import { Store } from "@dojo/framework/stores/Store"; | |
import { StoreContainer } from "@dojo/framework/stores/StoreInjector"; | |
import { APIExplorer } from "../widgets/APIExplorer"; | |
import { State } from "../interfaces"; | |
import { | |
fetchItemsProcess, | |
fetchResultProcess | |
} from "../processes/starwarsProcesses"; |
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
const store = new Store(); | |
const registry = registerStoreInjector(store); | |
class App extends WidgetBase { | |
protected render() { | |
return <APIExplorerContainer />; | |
} | |
} | |
const r = renderer(() => <App />); |
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
export const fetchItemsProcess = createProcess("fetch-items", [fetchItems]); | |
export const fetchResultProcess = createProcess("fetch-result", [fetchResult]); |